March 13, 20179 yr 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, 20179 yr by Tylersbored
March 13, 20179 yr 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, 20179 yr by Explv
March 13, 20179 yr 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
March 13, 20179 yr Author 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!
March 13, 20179 yr 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.
March 13, 20179 yr Author 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?
March 13, 20179 yr 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, 20179 yr by Explv
March 13, 20179 yr Author 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.
March 13, 20179 yr 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
March 13, 20179 yr 1 minute ago, Container said: This won't be the last time you have to change major parts of any code xD
March 13, 20179 yr Author 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
March 13, 20179 yr 6 minutes ago, Tylersbored said: Definitely not haha. I learn as I go its a never ending experience rofl
March 15, 20178 yr 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.
Create an account or sign in to comment