SRL Archive - General Botting Help

2 simple questions (6-hr limit and pixelchange function)


boscolamhk

2014-11-30 05:10:43

Hi all, I am new to scripting and I am trying to write my first script on humidifying. I have two general questions.

1. How to add the pixelchange function to the script below? I want to write "Until time timer >3000 or there is a pixel change in my backpack e.g. from clay to soft clay". I am not sure how to use this function and where I should put this function in my script.
TRSTabBackpack.waitSlotPixelChange(slot, waitTime: integer): boolean

2. What is the procedure or function to get past the 6-hr logout limit? (After 6-hr, it can automatically close the SMART and start again)
3. Instead of copying the script directly or attaching my script to here, is there a better way to quote my script so that it is easier for people to read?

Procedure humidify();
begin
if bankscreen.close() then
begin
humid_timer.start()
Repeat
actionbar.clickSlot(1);
Until (humid_timer.getTime() > 3000)
end else;
Inc(LoadsDone);
end;

KeepBotting

2014-11-30 10:13:05

1. tabBackpack.waitForShift(5000) will wait 5 seconds and return true if the backpack has shifted, false if not.

2. Well, it used to be sixHourFix() but calling that isn't actually needed anymore. Now what you can do is call

if (not isLoggedIn()) then
players[currentPlayer].login();
at the start of every procedure (or mainloop or wherever, somewhere it'll get called often), this will automatically invoke a client restart (EVENT_RS_UPDATE) depending on the login response recieved.

3. Use Simba tags
, put your code in between the tags.

Incurable

2014-11-30 10:57:57

For anyone who wants to read the code and help before OP has the chance to come on again:


program scriptTemplate;

{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}

var
LoadsDone, item_humid : integer;
humid_timer : TTimeMarker;

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'Username'; //Please enter your username here.
password := 'password'; //Please enter your password here
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;

Procedure dobankingstuff();
begin
if bankScreen.open(BANK_NPC_BLUE) then //Open the bank
begin
bankScreen.clickButton(BANK_BUTTON_PRESET_2) //Preset 2 is chosen.
end else
end;

Procedure humidify();
begin
if bankscreen.close() then
begin
humid_timer.start()
Repeat
actionbar.clickSlot(1);
Until (humid_timer.getTime() > 3000)
end else;
Inc(LoadsDone);
end;

Procedure progressreport();
begin
item_humid := LoadsDone * 27;
writeLn('============================================');
writeLn('Time Run: ' + TimeRunning());
writeLn('Item Made: ' + intToStr(item_humid));
writeLn('============================================');
end;

{Main Loop}
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();

if not isLoggedIn() then
begin
players[currentPlayer].login();
end;

exitSquealOfFortune();
minimap.setAngle(MM_DIRECTION_WEST);
mainScreen.setAngle(MS_ANGLE_HIGH);
Repeat
dobankingstuff();
humidify();
progressreport();
Until ( not isloggedin())
End




A few things…

1. You can do what you want by changing your humidify procedure to the following:


Procedure humidify();
begin
if bankscreen.close() then
begin
humid_timer.start()
Repeat
actionbar.clickSlot(1);
Until ((humid_timer.getTime() > 3000) or (tabBackpack.waitSlotPixelChange(28, 3000))) // Changed this line
// Documentation for it: http://docs.villavu.com/srl-6/backpack.html#trstabbackpack-waitslotpixelchange
end else;
Inc(LoadsDone);
end;

This will repeat actionbar.clickSlot(1) until humid_timer has reached 3 seconds OR the 28th slot pixels have changed.

2. As KeepBotting said, you can call login every procedure, but I personally think that it's an unsafe way to do it because you may have logged out due to an error (like being outside of the map range in a walking function, for example) and logging in could cause you to get stuck and flagged for macroing.

3. Unrelated to your question 3, but just fyi, exitSquealOfFortune has been deprecated ever since the replacement of the Squeal of Fortune with Treasure Hunter. The new procedure is named exitTreasure. The previous procedure will still work (it just calls the new one) and hasn't been removed yet so as not to break a bunch of old scripts that still use it. It will be removed eventually though (afaik).

4. You're on the right track code wise, but you may want to consider revising just a few of your standards. For example, the following:


Procedure dobankingstuff();
begin
if bankScreen.open(BANK_NPC_BLUE) then //Open the bank
begin
bankScreen.clickButton(BANK_BUTTON_PRESET_2) //Preset 2 is chosen.
end else
end;

… should really look like this:



Procedure doBankingStuff(); // camelCase
begin
if bankScreen.open(BANK_NPC_BLUE) then //Open the bank
begin // surrounding begin/end on same column as if statement
bankScreen.clickButton(BANK_BUTTON_PRESET_2) //Preset 2 is chosen.
end; // Removed unnecessary else
end;

And this:


{Main Loop}
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();

if not isLoggedIn() then
begin
players[currentPlayer].login();
end;

exitSquealOfFortune();
minimap.setAngle(MM_DIRECTION_WEST);
mainScreen.setAngle(MS_ANGLE_HIGH);
Repeat
dobankingstuff();
humidify();
progressreport();
Until ( not isloggedin())
End

… should look more like this:


{Main Loop}
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();

if not isLoggedIn() then // Removed unnecessary begin/end in this case, optional though
players[currentPlayer].login();

// Realigned indentation to start on the same column since these aren't enclosed statements
exitSquealOfFortune();
minimap.setAngle(MM_DIRECTION_WEST);
mainScreen.setAngle(MS_ANGLE_HIGH);

// Indenting as above
Repeat
doBankingStuff(); // camelCase again for function/procedure names (* see note below)
humidify();
progressReport();
Until (not isLoggedIn()) // camelCasee for isLoggedIn()

End. // Added period to final end, I didn't even know that this would compile without it

* NOTE: Your case preference is mostly up to you. PascalScript does have official standards, but there's a mismatch of standards that we generally consider to be the SRL/Simba standards.

For example, I personally use PascalCase to name procedures and global variables, UPPERCASE_NAMES with underscores for global constants, and camelCase to name functions and local variables. What you choose to do is up to you, just make sure that it makes sense, it is easily understood and read by fellow scripters, and that you're always consistent with your standards.

Either way, I'm glad to see another new scripter learning the ropes, I look forward to seeing your first script released. :D

boscolamhk

2014-12-01 05:58:20

From: KeepBotting
1. tabBackpack.waitForShift(5000) will wait 5 seconds and return true if the backpack has shifted, false if not.

2. Well, it used to be sixHourFix() but calling that isn't actually needed anymore. Now what you can do is call

if (not isLoggedIn()) then
players[currentPlayer].login();
at the start of every procedure (or mainloop or wherever, somewhere it'll get called often), this will automatically invoke a client restart (EVENT_RS_UPDATE) depending on the login response recieved.

3. Use Simba tags
, put your code in between the tags.


Thanks for your answer. I think I know the tabBackPack.waitForShift function. But I don't know when that 5 seconds start to count.

boscolamhk

2014-12-01 06:06:00

Thanks for posting the script for me. :)
Same question as in my post above: when does that pixelchange time start to count?


if bankscreen.close() then
begin
humid_timer.start()
Repeat
actionbar.clickSlot(1);
Until ((humid_timer.getTime() > 3000) or (tabBackpack.waitSlotPixelChange(28, 3000))) // Changed this line
// Documentation for it: http://docs.villavu.com/srl-6/backpack.html#trstabbackpack-waitslotpixelchange
end else;

In the above code, does the pixelchange function starts to time when the repeat loop starts or what?
Yeah…There is still a lot for me to learn about scripting and I will try to pay more attention to the wordings used in scripts.
One more question to ask, how to think of those failsafe method? Obviously I want to lower my chance of being banned using my script.
Or is there any general antiban function or procedure to use?

Incurable

2014-12-01 07:06:19

From: boscolamhk
Thanks for posting the script for me. :)
Same question as in my post above: when does that pixelchange time start to count?


if bankscreen.close() then
begin
humid_timer.start()
Repeat
actionbar.clickSlot(1);
Until ((humid_timer.getTime() > 3000) or (tabBackpack.waitSlotPixelChange(28, 3000))) // Changed this line
// Documentation for it: http://docs.villavu.com/srl-6/backpack.html#trstabbackpack-waitslotpixelchange
end else;

In the above code, does the pixelchange function starts to time when the repeat loop starts or what?
Yeah…There is still a lot for me to learn about scripting and I will try to pay more attention to the wordings used in scripts.
One more question to ask, how to think of those failsafe method? Obviously I want to lower my chance of being banned using my script.
Or is there any general antiban function or procedure to use?


Yes, that is correct, the waitSlotPixelChange time will start as soon as the script enters the repeat..until loop. Because of the speed at which scripts are run, humid_timer will also start at almost the same time. :)

The easiest way to come up with failsafes is to read scripts written by more experienced scripters and see what kind of failsafes that they've come up with. Generally, a failsafe is something that will save your script in the event of a failure. For example, placing this:


if (not isLoggedIn) then
exit();

… at the start of each procedure is a very simple but excellent way to ensure that the procedure will only be run through if the player is actually logged in. If you're not logged in, then you don't want the script to try and run your procedure. Similarly, your timer is a great failsafe because it stops the script from entering an infinite loop and repeating actionbar.clickSlot(1) forever in the event of a failure. Instead, just in case tabBackpack.waitSlotPixelChange(28, 3000) never returns true, it will exit because your timer failsafe has run out of time!

You are doing well so far, don't give up hope! Make sure that you've read the tutorials in my signature link (the big daddy tutorial thingo link), and don't forget that the official SRL-6 documentation is an invaluable resource. Remember, there's no questions that should ever go unasked, so don't be afraid to post more questions as they arise! ;)

EDIT: Just realised that the thread ID is 111111, lol.

boscolamhk

2014-12-01 08:52:24

From: Incurable
Yes, that is correct, the waitSlotPixelChange time will start as soon as the script enters the repeat..until loop. Because of the speed at which scripts are run, humid_timer will also start at almost the same time. :)

The easiest way to come up with failsafes is to read scripts written by more experienced scripters and see what kind of failsafes that they've come up with. Generally, a failsafe is something that will save your script in the event of a failure. For example, placing this:


if (not isLoggedIn) then
exit();

… at the start of each procedure is a very simple but excellent way to ensure that the procedure will only be run through if the player is actually logged in. If you're not logged in, then you don't want the script to try and run your procedure. Similarly, your timer is a great failsafe because it stops the script from entering an infinite loop and repeating actionbar.clickSlot(1) forever in the event of a failure. Instead, just in case tabBackpack.waitSlotPixelChange(28, 3000) never returns true, it will exit because your timer failsafe has run out of time!

You are doing well so far, don't give up hope! Make sure that you've read the tutorials in my signature link (the big daddy tutorial thingo link), and don't forget that the official SRL-6 documentation is an invaluable resource. Remember, there's no questions that should ever go unasked, so don't be afraid to post more questions as they arise! ;)

EDIT: Just realised that the thread ID is 111111, lol.


Thanks for your encourage and thanks for the SRL documentation link. I didn't use it when I wrote my first script and it took me lots of time finding the correct function to use.

I am now learning how to write script for walking and ACA haha :)