SRL Archive - OSR Help

Problem when applying invcount and/or invfull


PerryP

2011-11-18 02:49:33

So, I've been crudescripting a wine of zamorak bot and when testing it yesterday i found that it jumped parts of the code for no obvious reason(that i can find atleast).
the problem was that it ignored the InvFull and InvCount that i had included in the repeat and went on like the lines of code didnt exist. I've rewritten it atleast 20 times by now and still can't find the reason for it not working and thus i turn to you since your knowledge far exceeds when it comes to this

the procedure as it is right now:

Procedure WineGrabbing;
var
x, y, I, p: Integer;
MyPos: TPoint;
begin
if (rs_GetCompassAngleDegrees <> 0) then
begin
ClickNorth(true);
SetAngle(true);
end else;
begin
SetAngle(true);
end;

MyPos := SPS_GetMyPos();
if (MyPos.x <> 3545) and (MyPos.y <> 2575) then
repeat
SPS_WalkToPos(point(3545, 2575));
wait(2000);
MyPos := SPS_GetMyPos();
until (MyPos.x = 3545) and (MyPos.y = 2575);
o := 0
repeat
inc(o)
if (o>25) then
begin
GameTab(tab_inv);
for I := 1 to 28 do
if (ExistsItem(I)) then
Inc(p);
o := ((o + p - 2) / 2)
end;
Gametab(tab_Magic);
if (rs_GetCompassAngleDegrees <> 0) then
begin
ClickNorth(true);
SetAngle(true);
end;
repeat
x := RandomRange(614, 627)
y := RandomRange(295, 310)
MMouse(x, y, 3, 3);
Mouse(x, y, 0, 0, True);
wait(100 + RandomRange (100,450))
x := RandomRange(213, 219)
y := RandomRange(156, 161)
MMouse(x, y, 3, 3);
wait(50 + RandomRange (100,250))
until IsUpText('elekinetic') = true;
FindObject(x, y);
wait(randomrange(194, 673));
writeln('inventcount: ' + IntToStr(p));
writeln('tries: ' + IntToStr(o));

until (p = 27)

end;

earlier arrangements called invfull and broke loop when it turned true, also tried with using InvCount := p for example in the end of the script, which is preferable but didn't work either. don't get any errors while compiling but it wont even go as far as open the tab, only returns 0 as value, the rest of the script works without problems. Sorry for messy script… :crying:

Flight

2011-11-18 03:18:13

I for one am thoroughly confused…


inc(o)
if (o>25) then
begin
GameTab(tab_inv);
for I := 1 to 28 do
if (ExistsItem(I)) then
Inc(p);
o := ((o + p - 2) / 2)
end;
I don't understand this, what are you trying to figure here? Keep repeating the code in this loop until 'p' reaches 27? "until (p = 27)". What I usually do is, when creating 'repeat/until' loops is have "until" set forever, like so: "until(false)". That initiates an infinite loop. Now inside that loop, I put something like "if InvFull then break;", that will break out of the loop and continue with whatever code you have after that loop. Now if you use "Exit;" instead of 'Break;', it'll exit out of the loop and your whole procedure (WineGrabbing).

Again, I'm really confused as to what you're saying, it's quite unclear. If you could give just a simple explanation of what you want it to do and what it's doing currently that'd be helpful.

i luffs yeww

2011-11-18 03:21:09

Well for one, P is never reset. So you'll pass over 27 and continue to go through, because what P is right now is like 1! + 2! + 3! + 4! etc. (except for addition and not multiplication), so what you need to do is reset P to 0 after every loop.

But, InvCount should work. But really InvFull should work. Unless there was an update in the past few hours or something..

WT-Fakawi

2011-11-18 03:56:43

  1. You use fixed x and y ranges
  2. Then you hover random over the area until
  3. you find the uptext (In an endless loop)
  4. Then you do FindObject(x,y)

I would do

repeat

break when timeout

until findobject;
or


repeat
findobject;
until timeout

Also there is a very nice function FindObjTPA, that allows you to find colored areas in the runescape screen.

PerryP

2011-11-19 09:44:06

From: i luffs yeww
Well for one, P is never reset. So you'll pass over 27 and continue to go through, because what P is right now is like 1! + 2! + 3! + 4! etc. (except for addition and not multiplication), so what you need to do is reset P to 0 after every loop.

But, InvCount should work. But really InvFull should work. Unless there was an update in the past few hours or something..


thought p was reset everytime the procedure was done, since it's not a global variable?


From: WT-Fakawi
  1. You use fixed x and y ranges
  2. Then you hover random over the area until
  3. you find the uptext (In an endless loop)
  4. Then you do FindObject(x,y)

I would do

repeat

break when timeout

until findobject;
or


repeat
findobject;
until timeout

Also there is a very nice function FindObjTPA, that allows you to find colored areas in the runescape screen.


  1. the clicking of the telegrab spell?
  2. A human would never stay as the spellbutton until spawn so i ´move mouse to the are of the spawn
  3. the uptext for the spell since there's always a risk that the click on the spell didn't work and this avoids thatyou click the wine without it…
  4. the findobject function is written to search in the area the wine respawns only to reduce timebefore identify

since i need the search and click to repeat until inventory is full i have built it so that it repeats until inventory fills, i will add a timeout aswell as a failsafe as soon as i get it to work with checking the inventory.

will lock at the FindObjTPA when i get my own pc back on sunday. the best would probably have been to meassure colourchange in an area since that would speed up the process of checking when the item spawn…


From: Flight
I for one am thoroughly confused…


inc(o)
if (o>25) then
begin
GameTab(tab_inv);
for I := 1 to 28 do
if (ExistsItem(I)) then
Inc(p);
o := ((o + p - 2) / 2)
end;
I don't understand this, what are you trying to figure here? Keep repeating the code in this loop until 'p' reaches 27? "until (p = 27)". What I usually do is, when creating 'repeat/until' loops is have "until" set forever, like so: "until(false)". That initiates an infinite loop. Now inside that loop, I put something like "if InvFull then break;", that will break out of the loop and continue with whatever code you have after that loop. Now if you use "Exit;" instead of 'Break;', it'll exit out of the loop and your whole procedure (WineGrabbing).

Again, I'm really confused as to what you're saying, it's quite unclear. If you could give just a simple explanation of what you want it to do and what it's doing currently that'd be helpful.



When i get my pc back on sunday i will explain more thoroughly every step of the procedure, sorry.

o increases every time it atempt to get 1 wine.
when o reaches 25(tried 25 times) it checks the inventory (since no human would check inventory every time they cast the telegrab-spell)
number of full inventoryspaces := p
o is reduced so that it will check inventory again first when there has been a possibility to fill the remaining spots in the inventory)

hmm,should probably have p>26 or preferably put the check after the find object to be able to break when p=28(since inv cant have more places then 28…)

On sunday evening (CET) i will get my pc with the script back and then i can explain it better.

Thank you for your help so far all of you:)