Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question Updated webpath skeleton?

Joined
Jan 14, 2017
Messages
3
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.
 
Joined
May 4, 2019
Messages
5
Not sure what your question is, but I believe default web pathing is currently broken. Next best thing would probably be RegionPath.

unless you've built your own web and are trying to import it?
 
Joined
Apr 21, 2019
Messages
40
Building your own web would work. Its a tedious process that must be done by hand, and can be finicky at times especially if traversing objects that block your path, or especially different levels, but it can be done. There is a tool within the bot store that can help you with this process of generating the web.
 
Top