peilis Posted December 7, 2015 Share Posted December 7, 2015 Hello, How should i define the "if" statement for finishing my script ? It should finish then there is no specific item in the bank. So then that condition is met, it will go to a state that will stop the script / logout. private State getState() { Item something = bank.getItem("specific item"); if (something == null) return State.FINISHED; if (something.getAmount() == 0) return State.FINISHED; case FINISHED: stop(); logoutTab.logOut(); break; So i tried 2 different ways, yet what happens is : i start the script and the condition for it is met and it just do the stuff in FINISHED state. This is my first script, so im not used to the osbot api and not sure how some method works. Quote Link to comment Share on other sites More sharing options...
Ispecyou Posted December 7, 2015 Share Posted December 7, 2015 (edited) Hopefully thats your problem private State getState() { Item something = bank.getItem("specific item"); if (something == null) return State.FINISHED; } private State onLoop() { case FINISHED: if (something.getAmount() == 0){ stop(); logoutTab.logOut(); } break; Edited December 7, 2015 by Ispecyou Quote Link to comment Share on other sites More sharing options...
Vilius Posted December 7, 2015 Share Posted December 7, 2015 Hi, I see you are Lithuanian so if you got any problems you could ask me, I could help you in your native toungue And I think do as @Ispecyou told. Quote Link to comment Share on other sites More sharing options...
peilis Posted December 7, 2015 Author Share Posted December 7, 2015 I tried to do as Ispecyou showed, yet it looks like my client freezes then i try to use .getAmount() method. I can see people walking arround, yet i cannot stop the script, nor exit the client, the only way to exit is to kill process. private State getState() { Item something = bank.getItem("specific item"); boolean something = bank.contains("specific item"); } These 2 lines in getState() will return null or false not sure why it is like that. But it works if i start the script while bank is open. private State getState() { boolean something = bank.contains("specific item"); if (!something) return State.FINISHED; } Yet, im quite confused why it does not get the correct value while bank is closed. Item something = bank.getItem("specific item"); Maybe there is another better way of doing it ? Not necessary according to what i have ? - no specific item left in bank -> go to state. Quote Link to comment Share on other sites More sharing options...
Ispecyou Posted December 8, 2015 Share Posted December 8, 2015 Its because you are checking if something is in bank, when the bank isnt oppend. So first make the script check if the bank is opped if so then check if bank cointains item. Quote Link to comment Share on other sites More sharing options...