SRL Archive - OSR Help

help with loot function.


dzpliu

2013-06-15 10:40:57

this is part of script

'Custom':
begin
if CustomLoot then
Bones := FindBones; //findbones function returns all Tpoints found
if (Length(Bones) > 0) then
begin
WriteLn('Checking bones.');
for i:=Low(Bones) to High(Bones) do
begin
//i:=2;
RandomMMouse(Bones[i].x,Bones[i].y,0,0);
ClickMouse2(mouse_right);
if WaitOptionMulti(Loots,600) then
Exit;
end;
end;
end;


question is how do i limit 'i'(the integer) to 2 instead of all the Tpoints found?
so that the function only loot 2 of the drops found.

Olly

2013-06-15 10:48:22

for i := 0 to 1 do.. (will loop though 2 TPoints)

dzpliu

2013-06-15 11:46:31

From: Ollybest
for i := 0 to 1 do.. (will loop though 2 TPoints)


thanks so much, but it didnt work.

update:
'Custom':
begin
if CustomLoot then //Bones: Array of Tpoint;
Bones := FindBones; //findbones function returns all Tpoints found
if (Length(Bones) > 0) then
begin
WriteLn('Checking bones.');
for i:=0 to 1 do
begin

RandomMMouse(Bones[i].x,Bones[i].y,0,0);
ClickMouse2(mouse_right);
if WaitOptionMulti(Loots,600) then
Exit;
end;
end;
end;
this gives an error.. at
RandomMMouse(Bones[i].x,Bones[i].y,0,0);
saying out of range… btw
any other way? :(

dzpliu

2013-06-16 07:33:17

anyone else? help :(

Olly

2013-06-16 09:13:01

var
h, l: integer;

'Custom':
begin
if (CustomLoot) then //Bones: Array of Tpoint;
Bones := FindBones; //findbones function returns all Tpoints found

if (Length(Bones) > 0) then
begin
h := min(2, high(bones));

WriteLn('Checking bones.');
for i := 0 to h do
begin
RandomMMouse(Bones[i].x,Bones[i].y,0,0);
ClickMouse2(mouse_right);
if WaitOptionMulti(Loots,600) then
Exit;
end;
end;
end;

something like that.. it was giving you a out of range error because the tpa length wasn't 1 or more.

dzpliu

2013-06-16 09:18:59

From: Ollybest
var
h, l: integer;

'Custom':
begin
if (CustomLoot) then //Bones: Array of Tpoint;
Bones := FindBones; //findbones function returns all Tpoints found

if (Length(Bones) > 0) then
begin
h := min(2, high(bones));

WriteLn('Checking bones.');
for i := 0 to h do
begin
RandomMMouse(Bones[i].x,Bones[i].y,0,0);
ClickMouse2(mouse_right);
if WaitOptionMulti(Loots,600) then
Exit;
end;
end;
end;

something like that.. it was giving you a out of range error because the tpa length wasn't 1 or more.


i went to search the whole tutorial section and found
SetLength(Bones, 2);
is this suitable?

btw
h := min(2, high(bones));
why is it not
max(2, high(bones));
?
thanks for replying

Olly

2013-06-16 09:23:44

setLength should work, and its min because you only want to loop though two TPoints max, if it was max() it would return higher than 2.

dzpliu

2013-06-16 09:29:49

From: Ollybest
setLength should work, and its min because you only want to loop though two TPoints max, if it was max() it would return higher than 2.


ah i see. thanks so much.