Results 1 to 7 of 7

Thread: Drinking potions and making the script work more than once.

  1. #1
    Join Date
    Feb 2012
    Posts
    89
    Mentioned
    2 Post(s)
    Quoted
    13 Post(s)

    Default Drinking potions and making the script work more than once.

    Hello, i started making a corrupted serren stone cleanser.
    But i need some help.



    My question is, would this work?
    What i am trying to do is to make it so when your perfect juju prayer potion runs out it wil drink another dose.
    (i am testing this with prayer potion because juju's last an hour)

    the actual potion drinking part works but i can't figure out how to make it repeat.

    would this work?

    Code:
    if chatBox.findTextOnLines(['ou have run out of prayer points'], [1..5]); then
    
       begin
       repeat
        drinkPot
       until (not isLoggedIn);
       end



    Code:
    procedure drinkPot();
    begin
      tabBackPack.mouseSlot(1, MOUSE_MOVE); // Move mouse to slot 1
    
      //if isMouseOverText(['erfect juju prayer potion']) then // If text matches then start the next 'begin..end block'
      if isMouseOverText(['rayer potion']) then // If text matches then start the next 'begin..end block'
      begin
        fastClick(MOUSE_RIGHT);    // Left click
        writeLn('We drank a potion!');
        chooseOption.select(['rink']); // Choose the option
      end else
        writeLn('There wasn''t potion'); // If the mouseOverText didn't match, this will print instead
    
    end

  2. #2
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Use this for checking prayer:
    http://docs.villavu.com/srl-6/action...tprayerpercent

    I think as it is you'd just be drinking potions over and over. Once you drink you don't want to check again right away because the text will still be in the chatbox.
    Code:
    if we're out of the thing then
      drink the thing
      don't check again until ~1hr later
    else
      don't drink the thing
    Last edited by Citrus; 03-05-2015 at 10:44 PM.

  3. #3
    Join Date
    Feb 2015
    Posts
    422
    Mentioned
    41 Post(s)
    Quoted
    226 Post(s)

    Default

    Quote Originally Posted by Majnoon View Post
    Hello, i started making a corrupted serren stone cleanser.
    But i need some help.



    My question is, would this work?
    What i am trying to do is to make it so when your perfect juju prayer potion runs out it wil drink another dose.
    (i am testing this with prayer potion because juju's last an hour)

    the actual potion drinking part works but i can't figure out how to make it repeat.

    would this work?

    Code:
    if chatBox.findTextOnLines(['ou have run out of prayer points'], [1..5]); then
    
       begin
       repeat
        drinkPot
       until (not isLoggedIn);
       end



    Code:
    procedure drinkPot();
    begin
      tabBackPack.mouseSlot(1, MOUSE_MOVE); // Move mouse to slot 1
    
      //if isMouseOverText(['erfect juju prayer potion']) then // If text matches then start the next 'begin..end block'
      if isMouseOverText(['rayer potion']) then // If text matches then start the next 'begin..end block'
      begin
        fastClick(MOUSE_RIGHT);    // Left click
        writeLn('We drank a potion!');
        chooseOption.select(['rink']); // Choose the option
      end else
        writeLn('There wasn''t potion'); // If the mouseOverText didn't match, this will print instead
    
    end
    Code:
    if chatBox.findTextOnLines(['ou have run out of prayer points'], [1..5]); then
    
       begin
       repeat
        drinkPot
       until (not isLoggedIn);
       end
    would loop infinitely once the first potion runs out, it will notice the chat text, start the drinkpot procedure, and keep trying to drink more potions infinitely, because it repeats until the player is logged out. However, the drinkpot procedure looks good to me. just either remove the repeat completely or find a way to stop the loop.

    also try wrapping your scripts in SIMBA and /SIMBA, not CODE and /Code, when posting to the forums. It will make it much easier to read.

  4. #4
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    That way you have that repeat loop set up, once the script recognizes that it's out of prayer points and starts drinking potions, it'll never stop.

    Condsider something like this:
    Simba Code:
    procedure drinkPot();
    begin
      if (not (chatBox.findTextOnLines(['ou have run out of prayer points'], [1..5]))) then
       exit(); //Exit the routine if we don't need to drink.

      tabBackPack.mouseSlot(1, MOUSE_MOVE); // Move mouse to slot 1

      //if isMouseOverText(['erfect juju prayer potion']) then // If text matches then start the next 'begin..end block'
      if isMouseOverText(['rayer potion']) then // If text matches then start the next 'begin..end block'
      begin
        fastClick(MOUSE_RIGHT);    // Left click
        writeLn('We drank a potion!');
        chooseOption.select(['rink']); // Choose the option
      end else
        writeLn('There wasn''t potion'); // If the mouseOverText didn't match, this will print instead
    end;

    Then, you may simply call drinkPot() somewhere in your mainloop where it will be called as the script repeats naturally. So, your mainloop might look like this:

    Simba Code:
    begin
      {login/setup stuff blah blah}
      repeat
       drinkPot(); //it's okay to call this here without any conditionals
                  //because if it's not needed, it will just exit
       getStone();
       cleanseStone();
       {main game interaction stuff here, etc etc}
      until (players.getActive() <= 0);
    end.

    E: what evilcitrus said is also good advice, I don't believe the chatbox is the best way to determine prayer points

    E2: Mother of god, this is post ID 1333337.
    Last edited by KeepBotting; 03-05-2015 at 10:45 PM.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  5. #5
    Join Date
    Mar 2013
    Location
    Argentina
    Posts
    758
    Mentioned
    27 Post(s)
    Quoted
    365 Post(s)

    Default

    Quote Originally Posted by Majnoon View Post
    ...
    why do you put "repeat until (not is loggedin)" ?? you are getting into an infinite loop there, the bot will just drink pots until it logs out!
    Formerly known as Undorak7

  6. #6
    Join Date
    Feb 2012
    Posts
    89
    Mentioned
    2 Post(s)
    Quoted
    13 Post(s)

    Default

    Quote Originally Posted by KeepBotting View Post
    That way you have that repeat loop set up, once the script recognizes that it's out of prayer points and starts drinking potions, it'll never stop.

    Condsider something like this:
    Simba Code:
    procedure drinkPot();
    begin
      if (not (chatBox.findTextOnLines(['ou have run out of prayer points'], [1..5]))) then
       exit(); //Exit the routine if we don't need to drink.

      tabBackPack.mouseSlot(1, MOUSE_MOVE); // Move mouse to slot 1

      //if isMouseOverText(['erfect juju prayer potion']) then // If text matches then start the next 'begin..end block'
      if isMouseOverText(['rayer potion']) then // If text matches then start the next 'begin..end block'
      begin
        fastClick(MOUSE_RIGHT);    // Left click
        writeLn('We drank a potion!');
        chooseOption.select(['rink']); // Choose the option
      end else
        writeLn('There wasn''t potion'); // If the mouseOverText didn't match, this will print instead
    end;

    Then, you may simply call drinkPot() somewhere in your mainloop where it will be called as the script repeats naturally. So, your mainloop might look like this:

    Simba Code:
    begin
      {login/setup stuff blah blah}
      repeat
       drinkPot(); //it's okay to call this here without any conditionals
                  //because if it's not needed, it will just exit
       getStone();
       cleanseStone();
       {main game interaction stuff here, etc etc}
      until (players.getActive() <= 0);
    end.

    E: what evilcitrus said is also good advice, I don't believe the chatbox is the best way to determine prayer points

    E2: Mother of god, this is post ID 1333337.
    thank you but its just testing for the juju prayer potion doing it with prayer potions and later on editing it for perfect juju prayer potions sounds easier.

    how would i go about making the script continue on clicking after 1 stone is cleanser? because now it stops after 1 cleanse


    Simba Code:
    program new;
    {$DEFINE SMART}
    {$I SRL-6/SRL.simba}

    begin
      setupSRL();
     repeat
      clearDebug();
      drinkPot();
      clickCorruptedStone();
        until (players.getActive() <= 0);
    end.

    procedure clickCorruptedStone();
    var
      x, y: integer; //we need to declare these variables since findObject outputs/requires these
    begin
      if mainscreen.findObject(x, y, 10369635, 50, ['orrupted Seren Stone']) then
      begin
        writeLn('We used a crystal!'); // If findObject returns true, this will print
      end;
    end;

    procedure drinkPot();
    begin
      if (not (chatBox.findTextOnLines(['ou have run out of prayer points'], [1..5]))) then
       exit(); //Exit the routine if we don't need to drink.

      tabBackPack.mouseSlot(1, MOUSE_MOVE); // Move mouse to slot 1

      //if isMouseOverText(['erfect juju prayer potion']) then // If text matches then start the next 'begin..end block'
      if isMouseOverText(['rayer potion']) then // If text matches then start the next 'begin..end block'
      begin
        fastClick(MOUSE_RIGHT);    // Left click
        writeLn('We drank a potion!');
        chooseOption.select(['rink']); // Choose the option
      end else
        writeLn('There wasn''t potion'); // If the mouseOverText didn't match, this will print instead
    end;

  7. #7
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by Majnoon View Post
    thank you but its just testing for the juju prayer potion doing it with prayer potions and later on editing it for perfect juju prayer potions sounds easier.

    how would i go about making the script continue on clicking after 1 stone is cleanser? because now it stops after 1 cleanse


    Simba Code:
    program new;
    {$DEFINE SMART}
    {$I SRL-6/SRL.simba}

    procedure drinkPot();
    begin
      if (not (chatBox.findTextOnLines(['ou have run out of prayer points'], [1..5]))) then
       exit(); //Exit the routine if we don't need to drink.

      tabBackPack.mouseSlot(1, MOUSE_MOVE); // Move mouse to slot 1

      //if isMouseOverText(['erfect juju prayer potion']) then // If text matches then start the next 'begin..end block'
      if isMouseOverText(['rayer potion']) then // If text matches then start the next 'begin..end block'
      begin
        fastClick(MOUSE_RIGHT);    // Left click
        writeLn('We drank a potion!');
        chooseOption.select(['rink']); // Choose the option
      end else
        writeLn('There wasn''t potion'); // If the mouseOverText didn't match, this will print instead
    end;

    procedure clickCorruptedStone();
    var
      x, y: integer; //we need to declare these variables since findObject outputs/requires these
    begin
      if mainscreen.findObject(x, y, 10369635, 50, ['orrupted Seren Stone']) then
      begin
        writeLn('We used a crystal!'); // If findObject returns true, this will print
      end;
    end;

    begin
      setupSRL();
     repeat
      clearDebug();
      drinkPot();
      clickCorruptedStone();
     until (players.getActive() <= 0);
    end.
    Well first of all, I'm pretty sure your routines need to be above your mainloop, so let's do that really quickly (I just changed it in your quote)

    Secondly you're defining SMART but not declaring any players or setting them up with Rafiki (I assume you're just logging in manually?) but if that's the case, and what you posted isn't the entire script, please post the remainder.

    Since you are not setting up a player, no players are ever set as active (pic), therefore the mainloop will only loop once. You can change
    Simba Code:
    until (players.getActive() <= 0);
    to
    Simba Code:
    until (not (isLoggedIn()));
    or similiar, but I'd highly suggest you source declarePlayers() from one of The Mayor's tutorials, or look through the documentation for the player manager and use that.
    Last edited by KeepBotting; 03-05-2015 at 11:29 PM.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •