SRL Archive - First Scripts

First script - small problem please help.


IceTruckKiller

2013-03-30 17:13:17

Ok here is my code, at the start it should click the magic tab, then select the spell and start enchanting.

However what really happends is it selects the magic tab, then clicks the inventory icon, causing the script to break. No idea why it's doing it.

Here is my source code and the method where I think it's causing the problem

//start of source code//

program EnchantingSapphire;

{$DEFINE SMART8}
{$I SRL-OSR/SRL.simba}
{$i srl/srl/skill/magic.simba}
var
i,x:integer;
const
LVL_1_ENCHANT = 5;
procedure CastSpell(NAME: Integer);
begin
if (not inRange(name, 0, 62)) and (not GameTab(Tab_Magic)) then
Exit;
Mouse((570 + (name mod 7) * 24), (238 + (name div 7) * 24), 6, 6, Mouse_Left);
end;
procedure enchant;
begin //691,238//selects the magic tab, using F keys
i:=2;
for i:= 2 to 28 do //loops to do each inventory item
begin
FindNormalRandoms;
CastSpell(LVL_1_ENCHANT); //finds the spell name and clicks on it once
Writeln('Casting spell');
Wait(RandomRange(100, 350));
InvMouse((i), 1); //clicks the invent slot (i = invent slot and 1 is the input click)
Wait(RandomRange(2000, 2500));
end;
Writeln('Finished Enchanting');
end;
procedure doBank();
begin
Wait(RandomRange(350, 1000));
writeln('Banking');
if OpenBankGlass('wvb', True, False) then
begin
Wait(RandomRange(1000, 1700));
Deposit(2,28,True)
Wait(RandomRange(600, 1300));
WithdrawEx(8,1,27,['apphire race','ace','re ac']);
Wait(RandomRange(750, 1235));
writeln('Finished Banking');
CloseBank; //closes bank

end;
end;
begin
SetupSRL;
activateclient;
ClearDebug;
writeln('Start script with a full inv of un-enchanted braces, runes in slot 1 ');
GameTab(tab_Magic);
x:=0
while x<1000 do
begin
enchant();
doBank();
x:=x+1;
end;
end.

//end of source code//


//start of InvMouse//
function InvMouse(InvSlot, Action: Byte) : boolean;
var
TB: TBox;
CurrPT : TPoint;
begin
result := false;
if (not InRange(Action, 0, 3)) then
begin
srl_Warn('InvMouse', 'Action #' + IntToStr(Action) + ' is not a valid action', warn_AllVersions);
Exit;
end;
if (not InRange(InvSlot, 1, 28)) then
begin
srl_Warn('InvMouse', 'Inventory slot #' + IntToStr(InvSlot) + ' is not a valid slot', warn_AllVersions);
Exit;
end;
Result := true;
TB := InvBox(InvSlot);
GetMousePos(CurrPT.x,CurrPT.y);
if PointInBox(CurrPT,TB) then
MouseBox(Max(CurrPT.x-random(2),TB.x1),Max(CurrPT.y-random(2),TB.y1),
Min(CurrPT.x+random(2),TB.x2),Min(CurrPT.y+random(2),TB.y2),Action) //LOL Pro-human much!
else
MouseBox(TB.X1, TB.Y1, TB.X2, TB.Y2, Action);
end;
//end//

All help is greatly appreciated.

Total

2013-03-30 17:15:57

Try replacing FindNormalRandoms with FindNonInventoryRandoms.