Jump to content

Script functioning really random


k0ni

Recommended Posts

So im writing a script that trains couple skills randomly, but its not functioning properly at all.
Here are some things that arent working properly:

-When mining, my sleepUntil never escapes on condition (checking both mined rocks ids on that position or player animation)

-Detects that it doesnt have pickaxe, runs to bank (printing on logger), logger says that it arrived to the destination (osbots print), and 70% of the time it does a 360 and starts running to the mining area, while still printing "Going to bank"

-Not sure about this, gonna have to recheck it later, but the getWalking().webwalk(bank1, bank2) might made me walk to the 2nd closest bank 

-Config 43 returns 4, while on config debugger its 100 (either air strike or a magic spell selected on attack tab)
-Config 108 returns 3, while on debugger its 11 (same as above)

if dangerArea contains player
    // run to tile x
else if... 

else if trainingArea contains player
    // attack npc
else 
    // walk to trainingArea

it does its thing, then attacks the npc, ignores the sleepUntil, and runs to tile x. On the same loop above the npc.interact(), the distance between player and danger returns around 90, and if he was infact in the dangerArea it shouldnt even skip the first if. 

I need help, ive been working for like 3 days on that, and im just trashing my code and filling it with random comments. Ive got no idea whats wrong or what to do


 

Link to comment
Share on other sites

It sounds like you're having trouble with your onLoop() cycling before you've finished your task. Some events such as web walking have built-in break handlers and other methods require you to implement your own sleeps.

I would recommend logging more output to see exactly what's going on. If you see code triggering before you're done processing a method that's a good indicator that you need to add a sleep there.

Your logic is also extremely important. If a method returns a boolean, but you're not using that value anywhere that is something you should consider. Ask yourself exactly what a method is doing and what the output is. I think you may be using some methods with good intentions, but they might not work exactly how you think they do.

For example: getWalking().webwalk(bank1, bank2) according to the api "Walks to closest reachable destination area".

Edited by ExtraBotz
  • Heart 1
Link to comment
Share on other sites

9 hours ago, k0rd said:

So im writing a script that trains couple skills randomly, but its not functioning properly at all.
Here are some things that arent working properly:

-When mining, my sleepUntil never escapes on condition (checking both mined rocks ids on that position or player animation)

-Detects that it doesnt have pickaxe, runs to bank (printing on logger), logger says that it arrived to the destination (osbots print), and 70% of the time it does a 360 and starts running to the mining area, while still printing "Going to bank"

-Not sure about this, gonna have to recheck it later, but the getWalking().webwalk(bank1, bank2) might made me walk to the 2nd closest bank 

-Config 43 returns 4, while on config debugger its 100 (either air strike or a magic spell selected on attack tab)
-Config 108 returns 3, while on debugger its 11 (same as above)

if dangerArea contains player
    // run to tile x
else if... 

else if trainingArea contains player
    // attack npc
else 
    // walk to trainingArea

it does its thing, then attacks the npc, ignores the sleepUntil, and runs to tile x. On the same loop above the npc.interact(), the distance between player and danger returns around 90, and if he was infact in the dangerArea it shouldnt even skip the first if. 

I need help, ive been working for like 3 days on that, and im just trashing my code and filling it with random comments. Ive got no idea whats wrong or what to do


 

Pretty sure most of these issues are just flawed script logic, if you provide some of you code I can take a look at it. :)

The webwalker doesn't always generate the shortest path, so if one bank is a little bit further it might be the closest at some points 😉

Edited by Khaleesi
  • Heart 1
Link to comment
Share on other sites

Forgot to mention that im scripting for couple of years now, just not on osbot. So i knew for a fact that it wanst a logical error, and thats why i was so confused.

After cleaning my code from all the mess i had created, i noticed that my dumbass had forgot to put a break on a couple of swiches. From what i recall, my ide was giving errors in such a case, but it didnt (guess i could remember wrong).

Script is finally working, thanks for the quick replyies <3

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...