Jump to content
massih

Problem with my script..

Recommended Posts

I'm trying to make my own script I have got some kind of a problem i don't really know how to solve...



if (!LEVERAREA.contains(myPlayer())){
localWalker.walkPath(TOLEVER);
if (LEVERAREA.contains(myPlayer())){
lever.interact("Pull");
if (dialogues.isPendingContinuation()){
dialogues.clickContinue();
if (dialogues.isPendingOption()){
dialogues.selectOption("Yes I'm brave.");
if (players.myPlayer().isAnimating()){
sleep(random(1000,1500));
}
}
}

}

So it does walk to the LEVERAREA and when i manually leave it, it walks back.


But when it is AT the LEVERAREA it does not pull the lever...


Link to comment
Share on other sites

 

I'm trying to make my own script I have got some kind of a problem i don't really know how to solve...

            if (!LEVERAREA.contains(myPlayer())){
                localWalker.walkPath(TOLEVER);
                if (LEVERAREA.contains(myPlayer())){
                    lever.interact("Pull");
                    if (dialogues.isPendingContinuation()){
                        dialogues.clickContinue();
                        if (dialogues.isPendingOption()){
                            dialogues.selectOption("Yes I'm brave.");
                            if (players.myPlayer().isAnimating()){
                                sleep(random(1000,1500));
                            }
                        }
                    }
                    
                }
            } 

So it does walk to the LEVERAREA and when i manually leave it, it walks back.

But when it is AT the LEVERAREA it does not pull the lever...

 

 

if (!LEVERAREA.contains(myPlayer()))

     localWalker.walkPath(TOLEVER);

if (LEVERAREA.contains(myPlayer()))

     lever.interact("Pull");

if (dialogues.isPendingContinuation())

     dialogues.clickContinue();

if (dialogues.isPendingOption())

     dialogues.selectOption("Yes I'm brave.");

if (players.myPlayer().isAnimating())

     sleep(random(1000,1500));

 

I could be wrong, but these are all nested if statements. Try spreading them out how I have it and see if that works.

Link to comment
Share on other sites

I'm trying to make my own script I have got some kind of a problem i don't really know how to solve...

if (!LEVERAREA.contains(myPlayer())){                localWalker.walkPath(TOLEVER);                if (LEVERAREA.contains(myPlayer())){                    lever.interact("Pull");                    if (dialogues.isPendingContinuation()){                        dialogues.clickContinue();                        if (dialogues.isPendingOption()){                            dialogues.selectOption("Yes I'm brave.");                            if (players.myPlayer().isAnimating()){                                sleep(random(1000,1500));                            }                        }                    }                                    }            }

So it does walk to the LEVERAREA and when i manually leave it, it walks back.

But when it is AT the LEVERAREA it does not pull the lever...

I would not use nested IF statements like this as this causing you logical problems.

Currently you're saying:

If not in lever area, walk to lever area. But this will not execute the second if statement because you are now in fact in the lever area so the the first boolean returns false meaning no code is executed.

Try:

if (!LEVERAREA.contains(myPlayer())){

localWalker.walkPath(TOLEVER);

} else if (LEVERAREA.contains(myPlayer())){

lever.interact("Pull");

}

You might want to famaliarise yourself with if statements and if then else statements :)

(Only changed part of the code because I am on my phone and so you can learn too)

Precise

Link to comment
Share on other sites

I would not use nested IF statements like this as this causing you logical problems.

Currently you're saying:

If not in lever area, walk to lever area. But this will not execute the second if statement because you are now in fact in the lever area so the the first boolean returns false meaning no code is executed.

Try:

if (!LEVERAREA.contains(myPlayer())){

localWalker.walkPath(TOLEVER);

} else if (LEVERAREA.contains(myPlayer())){

lever.interact("Pull");

}

You might want to famaliarise yourself with if statements and if then else statements :)

(Only changed part of the code because I am on my phone and so you can learn too)

Precise

To dsd into this I'd reccomend reading http://osbot.org/forum/topic/58775-a-beginners-guide-to-writing-osbot-scripts-where-to-get-started-by-apaec/. Definatly will give you a big helping hand. I'd get used to the format that script uses using states. Will make things a lot easier/cleaner to read.

  • Like 1
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.

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...