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