SRL Archive - OSR Help

A looping issue


m3gaman3g3nd

2012-01-13 16:34:52

i have this probably too easy to fix but its taking too long to fix chunk that i want straightened out




procedure MineOre;
var
c, j, x, y: integer;
begin
if InvFull then
exit else
begin
c:= InvCount+1;
for j:= Invcount to 27 do
repeat
if FindObjEx_F(55511, 156151, 12, 20, MSCX, MSCY, ['Mine', 'Rocks'], X, Y, False) then
Mouse(x, y, 6, 6, false);
until(invcount=c)
end;
end;


as you can see

it clicks and mines but then it just doesnt do what i want it to do…

i would like it to click mine the rock and when my invcount increases by 1 then continue the loop all the way till what it says….

im kinda stuck

Mark

2012-01-13 16:42:31

procedure MineOre;
var
a, c, j, x, y: integer;
begin
if InvFull then exit;
repeat
// if FindObjEx_F(55511, 156151, 12, 20, MSCX, MSCY, ['Mine', 'Rocks'], X, Y, False) then
Mouse(x, y, 6, 6, Mouse_Right); ///chaneg this from false
a:=InvCount;
while InvCount = a do
begin
wait(0);
end;
until(invFull)
end;

FindObjEx_F i dont have your edited version to check if this compiles

ill try answer you question now tho will edit this post

m3gaman3g3nd

2012-01-13 16:47:57

i dont know mang im just going to have to look at more script examples…

Mark

2012-01-13 16:50:03

does this work

Chris

2012-01-13 17:00:27

From: CRU1Z1N
procedure MineOre;
var
a, c, j, x, y: integer;
begin
if InvFull then exit;
c:= InvCount+1;
for j:= Invcount to 27 do
repeat
if FindObjEx_F(55511, 156151, 12, 20, MSCX, MSCY, ['Mine', 'Rocks'], X, Y, False) then
Mouse(x, y, 6, 6, Mouse_Right); ///chaneg this from false
a:=InvCount;
while a = a do
begin
wait(0);
end;
until(invFull)
end;

does this work


Arent a for-loop and a repeat 2 different loops?
like:
for j := invcount to 27 do
begin

end;
or
repeat

until this := thus

when im looking through the code, it seems like it rpeats something until the inventory is full: invcount 28 and it repeats something else until its 27 but because the second repeat will go all the way till 28 before it checks if it is 27 again, it will be an infinite loop

Mark

2012-01-13 17:01:54

good spot didnt notice that

As you can see he do not even use j anywhere in that procedure

updated the code above still needs alot of work but i hope it shows you some ideas

Chris

2012-01-13 17:22:16

Thanks
btw, m3gaman, if you dont know how the while loop works:
the while loop checks If the given statement (a=a) is correct, if it is then it will wait 500 ms and check again until the statement is false, so because a is a just like b is b and chris is chris, this will be an infinite loop :p
So it should be:
 a:=invcount;
b:=invcount;
while a = b do
begin
b:=invcount;
end;

m3gaman3g3nd

2012-01-14 00:57:38

While i=invcount(lets say it counts 6) to 27 (for 22 to 27) do (5 Times)

A mining Procedure?
how can i make this work smoothly…