KevDev Posted March 7, 2018 Posted March 7, 2018 Sorry if this is a stupid question, I'm new to writing bots. What's the proper way to use the return value of something like bank.withdraw(x, 1); is something like this safe or is there some convention? while (!bank.withdraw(x, 1)) { sleep(random(100, 500)); }
d0zza Posted March 7, 2018 Posted March 7, 2018 You should learn how to write a basic java program before trying to script. There are plenty of online resources that are great to learn from but if you don’t know what a return value is or how to use it you’re going to have a very hard time scripting. 2
Mr Asshole Posted March 7, 2018 Posted March 7, 2018 34 minutes ago, KevDev said: Sorry if this is a stupid question, I'm new to writing bots. What's the proper way to use the return value of something like bank.withdraw(x, 1); is something like this safe or is there some convention? while (!bank.withdraw(x, 1)) { sleep(random(100, 500)); } while (!inventory.contains("itemname")){ bank.withdraw(x,1); sleep(500); } Will attempt to withdraw the item until the boolean is true which is when item is in your inventory.
Chris Posted March 7, 2018 Posted March 7, 2018 do not use while loops NO bank.withdraw returns a boolean result if (bank.withdraw(...)){ //we got an item } You can see return types per method here http://osbot.org/api
Duhstin Posted March 7, 2018 Posted March 7, 2018 You're already in a loop, no need to start another one. Use what @Chris said. I suggest learning more before trying to script.
inababila Posted March 7, 2018 Posted March 7, 2018 Learn java basics, check the API and some scripts written in here, and use conditional sleep and some failsafe checks.
H0rn Posted March 7, 2018 Posted March 7, 2018 if (getBank().withdraw("CamelToe",69)) { log ("We withdrew a camel toe."); } else { log ("Camel toe was not withdrawn"); }