- Joined
- Jan 14, 2017
- Messages
- 3
- Thread Author
- #1
I'm trying to make an onion picker.
Been trying to use This
publicclass main extendsAbstractScript{
publicTimer t;
publicstaticint runEnergy =0;
publicvoid onStart(){
log("hello");
t =newTimer();
}
publicvoid onPaint(Graphics2D g){
g.setColor(newColor(0,205,102,120));
g.fillRect(20,123,150,90);
g.setColor(Color.LIGHT_GRAY);
g.drawString("Mauricimoo OnionPicker",25,135);
g.drawString("here you go, it probably works fine",25,170);
}
Area onionArea =newArea(3186,3269,3192,3266,0);
Area bankArea =newArea(3092,3240,3094,3246,0);
Area gateArea =newArea(3185,3268,3186,3269,0);
publicvoid onExit(){
log("cya");
}
@Override
publicint onLoop(){
GameObject onion = getGameObjects().closest(b -> b !=null&& b.getName().equals("Onion"));
NPC banker = getNpcs().closest(b -> b.getName().equals("Banker"));
GameObject gate = getGameObjects().closest(g -> g !=null&& gateArea.contains(g)&& g.hasAction("Open"));
if(getInventory().isFull()&&!bankArea.contains(getLocalPlayer())){
getWalking().walk(bankArea.getRandomTile());
}
if(getInventory().isFull()&& bankArea.contains(getLocalPlayer())){
sleep(200,400);
banker.interact("Bank");
sleepUntil(()-> getBank().isOpen(),8000);
sleep(100,800);
getBank().depositAllItems();
sleep(600,1200);
getBank().close();
sleep(1200,1500);
}
if(onionArea.contains(getLocalPlayer())&&!getInventory().isFull()){
onion.interact();
sleep(900,1200);
}
if(!onionArea.contains(getLocalPlayer())&&!getInventory().isFull()){
getWalking().walk(onionArea.getRandomTile());
if(gate.exists()&& gate.distance()<=2){
gate.interact("Open"); sleep(1600,2400);
}
}
returnCalculations.random(50,80);
}
}
and combine with this
public class Walking extends Task {
private final static Coordinate bankCoord = new Coordinate(x, y);
private Web web; // Custom web, gets loaded in constructor
public Walking() {
try {
web = FileWeb.fromByteArray(Resources.getAsByteArray("path/to/webfile")); // load the web with the Resources class, make sure to address this resource in your manifest
} catch (Exception e) {
e.printStackTrace();
web = null;
}
}
@Override
public void execute() {
//Use this if you use the default web:
final WebPath path = Traversal.getDefaultWeb().getPathBuilder().buildTo(bankCoord);
//Or this if you use your own web
final WebPath path = null;
if (web != null) { // Make sure the web got loaded properly
path = web.getPathBuilder().buildTo(bankCoord);
}
if (path != null) { // IMPORTANT: if the path should be null, the pathbuilder could not manage to build a path with the given web, so always nullcheck!
path.step();
}
}
@Override
public boolean validate() {
//validate
}
}
because i'm trying to learn the basics but they are both outdated. Any help would be awesome.
Been trying to use This
publicclass main extendsAbstractScript{
publicTimer t;
publicstaticint runEnergy =0;
publicvoid onStart(){
log("hello");
t =newTimer();
}
publicvoid onPaint(Graphics2D g){
g.setColor(newColor(0,205,102,120));
g.fillRect(20,123,150,90);
g.setColor(Color.LIGHT_GRAY);
g.drawString("Mauricimoo OnionPicker",25,135);
g.drawString("here you go, it probably works fine",25,170);
}
Area onionArea =newArea(3186,3269,3192,3266,0);
Area bankArea =newArea(3092,3240,3094,3246,0);
Area gateArea =newArea(3185,3268,3186,3269,0);
publicvoid onExit(){
log("cya");
}
@Override
publicint onLoop(){
GameObject onion = getGameObjects().closest(b -> b !=null&& b.getName().equals("Onion"));
NPC banker = getNpcs().closest(b -> b.getName().equals("Banker"));
GameObject gate = getGameObjects().closest(g -> g !=null&& gateArea.contains(g)&& g.hasAction("Open"));
if(getInventory().isFull()&&!bankArea.contains(getLocalPlayer())){
getWalking().walk(bankArea.getRandomTile());
}
if(getInventory().isFull()&& bankArea.contains(getLocalPlayer())){
sleep(200,400);
banker.interact("Bank");
sleepUntil(()-> getBank().isOpen(),8000);
sleep(100,800);
getBank().depositAllItems();
sleep(600,1200);
getBank().close();
sleep(1200,1500);
}
if(onionArea.contains(getLocalPlayer())&&!getInventory().isFull()){
onion.interact();
sleep(900,1200);
}
if(!onionArea.contains(getLocalPlayer())&&!getInventory().isFull()){
getWalking().walk(onionArea.getRandomTile());
if(gate.exists()&& gate.distance()<=2){
gate.interact("Open"); sleep(1600,2400);
}
}
returnCalculations.random(50,80);
}
}
and combine with this
public class Walking extends Task {
private final static Coordinate bankCoord = new Coordinate(x, y);
private Web web; // Custom web, gets loaded in constructor
public Walking() {
try {
web = FileWeb.fromByteArray(Resources.getAsByteArray("path/to/webfile")); // load the web with the Resources class, make sure to address this resource in your manifest
} catch (Exception e) {
e.printStackTrace();
web = null;
}
}
@Override
public void execute() {
//Use this if you use the default web:
final WebPath path = Traversal.getDefaultWeb().getPathBuilder().buildTo(bankCoord);
//Or this if you use your own web
final WebPath path = null;
if (web != null) { // Make sure the web got loaded properly
path = web.getPathBuilder().buildTo(bankCoord);
}
if (path != null) { // IMPORTANT: if the path should be null, the pathbuilder could not manage to build a path with the given web, so always nullcheck!
path.step();
}
}
@Override
public boolean validate() {
//validate
}
}
because i'm trying to learn the basics but they are both outdated. Any help would be awesome.