SRL Archive - OSR Help

Annoying error when world switching


Peanuts

2013-05-28 12:24:24

Logs out, opens world screen, chooses world, ERROR…. on login.srl

Error: Out Of Range at line 880


This is the code im using.

ChangeWorld(RandomWorld(True, False));

Shatterhand

2013-05-28 12:28:21

Is this 07? If so:
http://villavu.com/forum/project.php?issueid=98

Peanuts

2013-05-28 12:30:41

From: Shatterhand
Is this 07? If so:
http://villavu.com/forum/project.php?issueid=98


No..

Sjoe

2013-05-28 12:32:28

From: Peanuts
No..


Did u set your player inactive after that by any chance? :s

EDIT: post script in simba tags here?

Peanuts

2013-05-28 12:39:21

From: Sjoe
Did u set your player inactive after that by any chance? :s

EDIT: post script in simba tags here?


Im not sure.. i could have.. ?

program Gems;

{$DEFINE SMART}

{$i srl\srl.simba}
{$i srl\srl\misc\SmartGraphics.simba}

{$i su_surfaces.simba}

var
Surface_Rock: TSurfacePart;
Obj_Gem_Rock, Obj_Gem_Rock2: TSurfaceObject;
dtm, r, drops, gemrock, startingxp, attempts, dtms, gembag, pp, GemCount, sapphire, emerald, diamond, ruby, Opal, topaz, Jade, CutOpal, CutTopaz, CutJade, DropCrushed, CrushedGems, Button, x, y, z, q : integer;
Peanut : TPoint;
aFound: Extended;

procedure DeclarePlayers;
begin

HowManyPlayers:= 1;
CurrentPlayer:= 0;
NumberOfPlayers(HowManyPlayers);


Players[0].Name := 'asdfsdasdfasd';
Players[0].Pass := 'asdfasdfasd';
Players[0].Nick := '';
Players[0].Active := True;
end;


function AutoColor1: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
R, G, B: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.02, 0.36);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 8280838, MSX1, MSY1, MSX2, MSY2, 11);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToRGB(arC[i], R, G, B);

if (R >= 3) and (R <= 10) and (G >= 51) and (G <= 131) and (B >= 71) and (B <= 179) then
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 2.44) and (X <= 16.15) and (Y >= 2.94) and (Y <= 19.26) and (Z >= 6.55) and (Z <= 44.99) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;


Procedure LoadVariables;
begin
Opal := DTMFromString('mggAAAHicY2NgYNBggWAVKNYEYl0gZmNiYGCGYk4g5mKCiDU05DPU1eWCMYhdVJTMEB3tx4ALMOLAEAAAp+UJPw==');
Topaz := DTMFromString('mggAAAHicY2NgYOABYi4GCGAHYlEgFgFibqgYC1QMhNmAuFs4AEgyYWAjBuyAEQeGAACOMQG8');
Jade := DTMFromString('mbQAAAHicY2VgYOAGYlEgZmOAAHYg5gViISifB4hFgLiqtRhIMqFgEQZMwIgFgwEAiOoCBQ==');
Button := DTMFromString('mggAAAHicY2NgYIhlYmCIA+JMKB0IxAFA3MbIwNAIxO1A3AXEnUDcDMQc2ZMZ2LxSGTgK5zBw1axm4KxYysASVskgBzSLkQQMAQC41wuD');
CutTopaz := DTMFromString('mbQAAAHicY2VgYAhnZmBIAuIoIPYD4iAgDmaE4BggDgdiPyCeKxoFVM2EgkUYMAEjFgwGAHcbBKE=');
CutJade := DTMFromString('mbQAAAHicY2VgYGhiZmDoAeJGIK4E4g4gDmZkYAgEYk8gjoTiafO7gKqZUDA/AyZgxILBAADzVAYk');
CutOpal := DTMFromString('mbQAAAHicY2VgYFjDzMCwBYi3AfEqIF4KxPqMDAxqQGwMxJZArAPECxbMBKpmQsEiDJiAEQsGAwAWSgZm');
GemBag := DTMFromString('mWAAAAHicY2FgYGADYmYGCOABYlYomwXKPvLoNkN2TQVDVlUZQ9vsaQz/GVABIxoGAQBsYggc');
Sapphire := DTMFromString('mbQAAAHicY2VgYAhmZmCIAuJQIHYFYn8gLmGE4AYgLgLiLCAWlZgFVM2EguUYMAEjFgwGAItNBOY=');
Emerald := DTMFromString('mbQAAAHicY2VgYJjKxMAwBYhnAPE8IF4IxOKMDAy8UCwAxBJAzJ8uCFTNhIL5GTABSIYRDYMBAGt5BBI=');
Ruby := DTMFromString('mggAAAHicY2NgYMhmYmDIAeICIC4B4nIgLgVicUYGBh4g5gNiASCWAGIRIA4X4gHqYsLA/AzYAUiWEQuGAACO2wPC');
Diamond := DTMFromString('m1gAAAHic42JgYOhnZmDoYYbQE6HsqUA8BSrWBcSdQHyREYKvAfFNKL4CxBeA+BQQn4Xye9vbGWZMmsTQUF3F0NXSAsblRUUMLfX1DLUVFQybVq9m2LhqFQOxgJFIjAAAPKYeTw==');
DropCrushed := DTMFromString('mggAAAHicY2NgYDjJyMBwAojPAfERIN4NxNeBeCcQbwTiY0B8CMoG4eP79zGICAszcLCxMvByczKICPCCsREDdsCIA0MAAKc3DGg=');
GemRock := DTMFromString('mWAAAAHicY2FgYJBiYmAQB2JZIJYGYilGCJYGYnEgzjZMZYjWCWYotqlhaHOdwAAUwotBAAAAzQVJ');




end;



procedure CutIt;
begin
if not findcolorspiraltolerance(z, q, 8280838, MSX1, MSY1, MSX2, MSY2, 10) then
begin
Writeln('failed to cut gems');
Exit;
end;

if findcolorspiraltolerance(z, q, 8280838, MSX1, MSY1, MSX2, MSY2, 10) then
begin
writeln('Cutting gems');
Mmouse(z, q, 7, 7);
mouse(z, q, 0, 0, true);
Wait(5000);
end;
end;

Procedure ProgressReport;
Var
CurrentXP, XPGained, LogsCut: Integer;

Begin
CurrentXP := GetXPBarTotal;
XPGained := CurrentXP - StartingXP;
LogsCut := XPGained / 65;

WriteLn('We have mined ' + IntToStr(LogsCut) + 'gems');

End;

procedure AddGemsToBag;
var
abc, def: integer;
begin
if FindDtm(Sapphire, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Writeln('Attempting to bag sapphires...');
Mmouse(x, y, 7, 7);
mouse(x, y, 0, 0, false);
WaitOption('se', 1500);
MMouseItem(28);
Wait(500 + random(500));
GetMousePos(abc, def);
HoldMouse(abc, def, mouse_Left);
MoveMouse(abc + 1, def);
GetMousePos(abc, def);
ReleaseMouse(abc, def, mouse_Left);
end;
if FindDtm(Emerald, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Writeln('Attempting to bag emeralds...');
Mmouse(x, y, 7, 7);
mouse(x, y, 0, 0, false);
WaitOption('se', 1500);
MMouseItem(28);
Wait(500 + random(500));
GetMousePos(abc, def);
HoldMouse(abc, def, mouse_Left);
MoveMouse(abc + 1, def);
GetMousePos(abc, def);
ReleaseMouse(abc, def, mouse_Left);
end;
if FindDtm(Ruby, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Writeln('Attempting to bag rubys...');
Mmouse(x, y, 7, 7);
mouse(x, y, 0, 0, false);
WaitOption('se', 1500);
MMouseItem(28);
Wait(500 + random(500));
GetMousePos(abc, def);
HoldMouse(abc, def, mouse_Left);
MoveMouse(abc + 1, def);
GetMousePos(abc, def);
ReleaseMouse(abc, def, mouse_Left);
end;
if FindDtm(Diamond, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Writeln('Attempting to bag diamonds...');
Mmouse(x, y, 7, 7);
mouse(x, y, 0, 0, false);
WaitOption('se', 1500);
MMouseItem(28);
Wait(500 + random(500));
GetMousePos(abc, def);
HoldMouse(abc, def, mouse_Left);
MoveMouse(abc + 1, def);
GetMousePos(abc, def);
ReleaseMouse(abc, def, mouse_Left);
FreeDTM(Dtms);
end;
end;

Function FindGems:boolean;
var
GemTPA, WoodTPA:TPointArray;
GemATPA:T2DPointArray;
GemBox:TBox;
i, r, counter:integer;
begin
if not(loggedin) then
exit;


SetColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.23, 0.83);
if findcolorstolerance(GemTPA, 6697071, MSX1, MSY1, MSX2, MSY2, 11) then
begin

SortATPAFromMidPoint(GemATPA, Point(MSCX, MSCY));
for i := 0 to high(GemATPA) do
begin
GemBox := GetTPABounds(GemATPA[i]);
SetColorSpeed2Modifiers(0.04, 0.28);
if findcolorstolerance(GemTPA, 4609378, GemBox.x1, Gembox.Y1, Gembox.X2, Gembox.Y2, 15) then
Break;
if i = high(GemATPA) then
begin
writeln('We went through all TPA''s and found no brown! Check your CTS2 Work!');
Terminatescript;
end;
end;
SetColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.02, 0.02);
marktime(counter);
while (not isuptextmulticustom(['em','asd'])) do
begin
r := random(length(GemTPA));
mmouse(GemTPA[r].x, GemTPA[r].y, 3, 3);
wait(randomrange(200, 500));
if timefrommark(counter) > 5000 then
begin
writeln('No Uptext Found');
Logout;
Terminatescript;
end;
end;
clickmouse2(mouse_right);
if ChooseOption('em') then
begin
Writeln('Mining...');
end;
end else
ChangeWorld(RandomWorld(True, False));
Wait(500);
end;

procedure MineGems;

begin
GemCount := InvCount + 1;


FindGems;

Wait(50);
writeln('found');



end;







begin
SetupSRL();
//LogInPlayer; //make declare players
SMART_ClearMS();
Smart_FreeDebug;
LoadVariables;
//ClickNorth(SRL_ANGLE_High);
StartingXP := GetXPBarTotal;
GemCount := InvCount + 1;
ToggleActionBar(False);
repeat
minegems;
repeat
Wait(50);
until(InvCount = GemCount)
until(InvFull)

progressreport;

AddGemsToBag;
DropAllExcept([28]);



end.


Sjoe

2013-05-28 12:50:26

Try Selectworld(RandomWorld(True, False)); ?

Also DeclarePlayers; after SetupSRL;

Peanuts

2013-05-28 12:59:35

From: Sjoe
Try Selectworld(RandomWorld(True, False)); ?

Also DeclarePlayers; after SetupSRL;


AH!.. forgot something so obvious..

thx!.