SRL Archive - OSR Help

Wierd stuff happends, completely clueless why. 07 Script


IceTruckKiller

2013-03-30 15:27:12

Firstly I'll describe how the script should work (This is a 07 Script)
It should firstly open the magic tab, then select the enchant sapphire spell, then click on inventory slot 2 (becuase inv slot 1 has runes), next it will do this but click on inventory slot 3 and so on until slot 28, after it banks and repeats.

What happens is it fails the select the spell, then clicks on invent slot 2, then 4, then 6, (Can you see a pattern here) not sure why it's doing this.

Any help would be highly appreciated as I really want to learn to script so I can release some scripts.

for reference here is the documentation I used for the functions some of you may not be familier with:
http://docs.villavu.com/srl-5/gametab.html?highlight=ftab#id1
http://docs.villavu.com/srl-5/magic.html?highlight=magic

Here is my full source code


program EnchantingSapphire;

{$DEFINE SMART8}
{$I SRL-OSR/SRL.simba}
{$i srl/srl/skill/magic.simba}
var
i,x:integer;
const
const
tab_Combat = 21;
tab_Inv = 25;
tab_Equip = 26;
tab_Prayer = 27;
tab_Magic = 28;

procedure enchant;
begin
Ftab(tab_Magic);//selects the magic tab, using F keys
i:=2;
for i:= 2 to 27 do //loops to do each inventory item
begin
(Cast('Lvl-1 Enchant', false)); //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(1700, 2000));
end;
Writeln('Finished Enchanting');
end;

procedure doBank();
begin
Wait(RandomRange(1000, 2000));
writeln('Banking');
if OpenBankFast('vwb') then
begin
Deposit(2,28,True)
Wait(RandomRange(600, 1300));
WithdrawEx(8,1,27,['apphire race','ace','re ac']);
Wait(RandomRange(750, 1235));
CloseBank; //closes bank

end;
end;

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

The Mayor

2013-03-30 15:40:20

It would be wise to make it click on the spell, then move the mouse to the slot and check the UpText (i.e. 'cast' or what ever) before clicking the mouse. If the UpText doesn't match then it would select the spell again :)

IceTruckKiller

2013-03-30 15:47:26

From: The Mayor
It would be wise to make it click on the spell, then move the mouse to the slot and check the UpText (i.e. 'cast' or what ever) before clicking the mouse. If the UpText doesn't match then it would select the spell again :)

Yeah I agree, thanks :)