SRL Archive - RS3 Help

Drinking potions and making the script work more than once.


Majnoon

2015-03-05 17:22:31

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?


if chatBox.findTextOnLines(['ou have run out of prayer points'], [1..5]); then

begin
repeat
drinkPot
until (not isLoggedIn);
end





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

Citrus

2015-03-05 17:33:53

Use this for checking prayer:
http://docs.villavu.com/srl-6/actionbar.html#trsactionbar-getprayerpercent

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.

if we're out of the thing then
drink the thing
don't check again until ~1hr later
else
don't drink the thing

fady

2015-03-05 17:35:21

From: Majnoon
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?


if chatBox.findTextOnLines(['ou have run out of prayer points'], [1..5]); then

begin
repeat
drinkPot
until (not isLoggedIn);
end





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



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.

KeepBotting

2015-03-05 17:36:32

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:

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:


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.

Lipcot

2015-03-05 17:36:59

From: Majnoon
…


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!

Majnoon

2015-03-05 18:10:21

From: KeepBotting
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:

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:


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



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;

KeepBotting

2015-03-05 18:22:34

From: Majnoon
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



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
until (players.getActive() <= 0);
to
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.