please take a look at this example:
and tell me if something is unclear
Area bank;
@Override
public void onStart() throws InterruptedException {
String userOptions[] = {"Varrock", "Falador", "Edgeville"};
String userChoice = ""+(String)JOptionPane.showInputDialog(null, "Choose a location", "Bank Walker", JOptionPane.PLAIN_MESSAGE, null, userOptions, userOptions[1]);
String taskOptions[] = {"fletch", "craft"};
String task = ""+(String)JOptionPane.showInputDialog(null, "Choose a action", "Bank Walker", JOptionPane.PLAIN_MESSAGE, null, actionOptions, actionOptions[1]);
//we set the Area bank varible to the bank we want to use later on to be used in the WalkBank method;
switch(userChoice) {
case "Varrock":
bank = Banks.FALADOR_WEST;
break;
case "Falador":
bank = Banks.FALADOR_WEST;
break;
case "Edgeville":
bank = Banks.GRAND_EXCHANGE;
break;
}
combat.toggleAutoRetaliate(false);
}
@Override
public int onLoop() throws InterruptedException {
//only actives the task if the WalkBank method returned true (so the player is at the bank)
if(WalkBank) {
//based on the task we do something diffrent so if task = fletch then it activates the method you have in the return statement (uses return so you return diffrent int values)
switch(task) {
case "fletch":
return Fletch();
case "craft":
return Craft();
}
}
//if walk bank fails it will try again in 700 ms
return 700;
}
public int Craft() {
//code for crafting
//if you'd want to fletching if something happens example run out of supplies you could use task = "fletch"; at what ever point in code here
//the amount you return here will count as sleep for x ms
return 100;
}
public int Fletch() {
//code for fletching
//if you'd want to crafting if something happens example run out of supplies you could use task = "craft"; at what ever point in code here
//the amount you return here will count as sleep for x ms
return 100;
}
//returns true if at the bank if its not at the bank it will try walk there and return false in the method in the onloop
public boolean WalkBank() {
if (bank.contains(myPosition())) {
return true;
} else {
getWalking().webWalk(bank);
return false;
}
}
this can be used to support big scripts if you'd have a wcing script you can have tasks: woodcutting/walk bank/bank/walk trees
in woodcutting you would put task = "walk bank" after your inventory is full making the script swap to the task walk bank.
then in walk bank you would instead of return true have task = "bank"
then in that task if you inventory is empty (or only axe in inventory remains) you would use task = "walk trees" ect that way you can create a logical flow in your script and have many diffrent actions most often in a setup like this you would have the task preset to 1 of the tasks so the script starts at task a and from there on just goes though all tasks and repeat i know it can be a tiny bit complex but the code above with the explanation should give you some of the groundwork to write a clean wcing script or any other script of the sorts