Tylersbored Posted March 13, 2017 Share Posted March 13, 2017 (edited) I am trying to make my mule accept a trade but for some reason, he wont execute the command, or nothing happens when he executes the command. I can confirm that he is in the first trade window. This command works for my other scripts but for some reason in this script it wont work. I am checking the log and "Accepting Trade" keeps looping so I know that it keeps trying to execute the command. Thanks for the help. edit: I put this.script.trade.acceptTrade() in an if statement to see if it was returning true but it is returning false. Still not sure why it is returning false though. edit2: When the bot attempts to accept trade, the mouse hovers over "decline".. Edited March 13, 2017 by Tylersbored Quote Link to comment Share on other sites More sharing options...
Explv Posted March 13, 2017 Share Posted March 13, 2017 (edited) 14 minutes ago, Tylersbored said: I am trying to make my mule accept a trade but for some reason, he wont execute the command, or nothing happens when he executes the command. I can confirm that he is in the first trade window. This command works for my other scripts but for some reason in this script it wont work. I am checking the log and "Accepting Trade" keeps looping so I know that it keeps trying to execute the command. Thanks for the help. edit: I put this.script.trade.acceptTrade() in an if statement to see if it was returning true but it is returning false. Still not sure why it is returning false though. Why are you using while loops? Firstly the script is already looping, (the method is even called onLoop) and you also only want to be offering items and accepting trade once. Your code should be structured more like: If not in trade with player then trade player Else if first window and not offered coins then offer coins Else if not accepted trade window accept trade window Edited March 13, 2017 by Explv Quote Link to comment Share on other sites More sharing options...
Muffins Posted March 13, 2017 Share Posted March 13, 2017 4 minutes ago, Explv said: Why are you using while loops? Firstly the script is already looping, (the method is even called onLoop) and you also only want to be offering items and accepting trade once. Your code should be structured more like: If not in trade with player then trade player Else if not accepted trade window accept trade window can u write me the code plz Quote Link to comment Share on other sites More sharing options...
Tylersbored Posted March 13, 2017 Author Share Posted March 13, 2017 15 minutes ago, Explv said: Why are you using while loops? Firstly the script is already looping, (the method is even called onLoop) and you also only want to be offering items and accepting trade once. Your code should be structured more like: If not in trade with player then trade player Else if first window and not offered coins then offer coins Else if not accepted trade window accept trade window Ah I see. I just started writing scripts about a week ago so sorry for the spaghetti code haha. Anyways, I restructured my code to your advice and it seems to be working now, thanks! Quote Link to comment Share on other sites More sharing options...
Container Posted March 13, 2017 Share Posted March 13, 2017 5 minutes ago, Tylersbored said: Ah I see. I just started writing scripts about a week ago so sorry for the spaghetti code haha. Anyways, I restructured my code to your advice and it seems to be working now, thanks! Also, those static sleeps on every second line are pretty obsolete. You could throw in more cond sleeps, though. Quote Link to comment Share on other sites More sharing options...
Tylersbored Posted March 13, 2017 Author Share Posted March 13, 2017 10 minutes ago, Container said: Also, those static sleeps on every second line are pretty obsolete. You could throw in more cond sleeps, though. So should I be using a bunch of conditional sleeps instead of static sleeps? Quote Link to comment Share on other sites More sharing options...
Explv Posted March 13, 2017 Share Posted March 13, 2017 (edited) 50 minutes ago, Tylersbored said: Ah I see. I just started writing scripts about a week ago so sorry for the spaghetti code haha. Anyways, I restructured my code to your advice and it seems to be working now, thanks! In my opinion, it should be more like: if not is currently trading: if interact "Trade with" on worker is successful: Conditional sleep until is currently trading else if not my offer contains coins: if enter amount dialog is visible: type 35k else if interact "Offer-x" on "Coins" is successful: Conditional sleep until enter amount dialog is visible else if not accepted trade: accept trade Interactions can fail, so you shouldn't continue with other interactions unless you know the first one succeeded. For example, in your code you type 35k after interacting with the Coins, but the Coin interaction might fail (it probably won't), and your bot will just type 35k into the chatbox. Edited March 13, 2017 by Explv Quote Link to comment Share on other sites More sharing options...
Tylersbored Posted March 13, 2017 Author Share Posted March 13, 2017 1 hour ago, Explv said: In my opinion, it should be more like: if not is currently trading: if interact "Trade with" on worker is successful: Conditional sleep until is currently trading else if not my offer contains coins: if enter amount dialog is visible: type 35k else if interact "Offer-x" on "Coins" is successful: Conditional sleep until enter amount dialog is visible else if not accepted trade: accept trade Interactions can fail, so you shouldn't continue with other interactions unless you know the first one succeeded. For example, in your code you type 35k after interacting with the Coins, but the Coin interaction might fail (it probably won't), and your bot will just type 35k into the chatbox. Oh wow. That structure looks alot better.. Thank you so much man, I'll try to follow this principle from now on. Time to go change all my code rip. Quote Link to comment Share on other sites More sharing options...
Container Posted March 13, 2017 Share Posted March 13, 2017 1 hour ago, Tylersbored said: Oh wow. That structure looks alot better.. Thank you so much man, I'll try to follow this principle from now on. Time to go change all my code rip. This won't be the last time you have to change major parts of any code Quote Link to comment Share on other sites More sharing options...
DrDu Posted March 13, 2017 Share Posted March 13, 2017 1 minute ago, Container said: This won't be the last time you have to change major parts of any code xD Quote Link to comment Share on other sites More sharing options...
Container Posted March 13, 2017 Share Posted March 13, 2017 2 minutes ago, DrDu said: xD postCount += 1; Quote Link to comment Share on other sites More sharing options...
DrDu Posted March 13, 2017 Share Posted March 13, 2017 10 minutes ago, Container said: postCount += 1; Quote Link to comment Share on other sites More sharing options...
Tylersbored Posted March 13, 2017 Author Share Posted March 13, 2017 15 minutes ago, Container said: This won't be the last time you have to change major parts of any code Definitely not haha. I learn as I go Quote Link to comment Share on other sites More sharing options...
whipz Posted March 13, 2017 Share Posted March 13, 2017 6 minutes ago, Tylersbored said: Definitely not haha. I learn as I go its a never ending experience rofl Quote Link to comment Share on other sites More sharing options...
d0zza Posted March 15, 2017 Share Posted March 15, 2017 I'm not sure if this is still the case but a month or two ago when I was testing acceptTrade() I realised the widgets are wrong. So I had to find what widgets to interact with myself using the widget debugger. Quote Link to comment Share on other sites More sharing options...