KeepBotting
2014-06-07 15:11:58
Made this for a script I'm writing, was really pleased. Decided to release.
It's better than SRL's inbuilt worldswitcher imo.
It even compensates for the weird error where SRL will scroll the whole world list 2-3 times, mouse up to (0, 0) and then just click play without selecting a world.
lastWorld is declared globally. Can't remember why.
isMembers is declared as a global boolean that users should set true/false, depending on if they're a member.
All login2 does is press the play button at the lobby. I had a reason for isolating it from SRL but can't remember what it was. Use login2, make your own, or let SRL do it.
writeDebug and writeError are procedures specific to my script, use them or replace with writeLn.
Usage:
Cheers. If you've any bugs or suggestions, please post them.
It's better than SRL's inbuilt worldswitcher imo.
It even compensates for the weird error where SRL will scroll the whole world list 2-3 times, mouse up to (0, 0) and then just click play without selecting a world.
function worldSwitcher(worldNum:integer):boolean;
var
theWorld:integer;
p:TPoint;
begin
writedebug('worldSwitcher: preparing to switch worlds!');
players[currentPlayer].exitToLobby();
lobby.openTab(LOBBY_WORLDS);
lastWorld := lobbyWorlds.getCurrentWorld();
writeDebug('worldSwitcher: lastWorld is ' + toStr(lastWorld) + '.');
if worldNum > 0 then
begin
writeDebug('worldSwitcher: switching to world ' + toStr(worldNum) + '.');
lobbyWorlds.selectWorld(worldNum);
login2;
exit(true);
end;
if (not lobbyWorlds._isWorldValid(worldNum) or worldNum = 0) then //srl thinks 0 is invalid
begin
writeError('*** FATAL ERROR: worldSwitcher: worldNum is not a valid world!');
exit(false);
terminateScript();
end else
begin
if worldNum <= 0 then
begin
writeDebug('worldSwitcher: switching to random world.');
lobbyWorlds.selectRandomWorld(isMembers);
theWorld := lobbyWorlds.getCurrentWorld();
writeDebug('worldSwitcher: theWorld is ' + toStr(theWorld) + '.');
if (theWorld = lastWorld) then
begin
writeWarn('worldSwitcher: Oh no! theWorld = lastWorld! Choosing again...');
lobbyWorlds.selectRandomWorld(isMembers); //select another
end;
writeDebug('worldSwitcher: selected random world ' + toStr(theWorld) + '.');
login2;
exit(true);
end;
end;
end;lastWorld is declared globally. Can't remember why.
isMembers is declared as a global boolean that users should set true/false, depending on if they're a member.
procedure login2();
var
p:TPoint;
begin
lobby.findPlayButton(p);
writeDebug('worldSwitcher: clicking play.');
mouse(p.rand(randomRange(-50, 50), randomRange(-10, 10)), MOUSE_LEFT);
repeat
wait(500);
until isLoggedIn();
end;All login2 does is press the play button at the lobby. I had a reason for isolating it from SRL but can't remember what it was. Use login2, make your own, or let SRL do it.
procedure writeDebug(text:string);
begin
{$IFDEF debug_on} writeLn('[DEBUG] : ' + text); {$ENDIF}
end;procedure writeError(text:string);
begin
{$IFDEF debug_on}
writeln('');
writeLn('[ERROR] : ' + text);
writeln('');
{$ENDIF}
end; writeDebug and writeError are procedures specific to my script, use them or replace with writeLn.
Usage:
worldSwitcher(0); //switches to random worldworldSwitcher(69); //switches to world 69Cheers. If you've any bugs or suggestions, please post them.
forgive my crudely drawn chart.