SRL Archive - OSR Help

Can I detect an item in a specific inventory slot?


l6bustank

2012-09-18 05:30:15

Decided to boost my herby. I am using a working herblore script, but i keep getting this problem:
The script has a wait timer for waiting until the potions are made from ingredients. The user also has scroll of cleansing (so the invcount varies and cant be used).
Runescape tends to get slower when there are more than, say 130k ppl online (weekends). Right now I have to constantly tweak the wait timer to make sure that 14 potions are made every inv, since they are made faster when there are less ppl and slower when there are more ppl online.
I want to detect if there IS anything in inv slot 28 or NOT. If there is, then that means, there are still potions to be made. If not, the script can bank. Finding a DTM wastes 1-2sec per load and lowers my xp rates, but I cant think of anything better atm :(
Is there a faster way for this?

Daniel

2012-09-18 05:32:01


if(ExistsItem(28)) then
...
else
...

l6bustank

2012-09-18 05:41:04

thx, will try

E: still slow detection, though when I order it to detect item in 22 instead of 28, it will make all the rest of the potions while still detecting item in this slot. An improvement, but are there any other ways?

BigFate

2012-09-18 06:15:05

What Daniel suggested works very well and is fast. You might be doing something wrong and not calling it often enough… can you post your code snippet where you added it?

l6bustank

2012-09-18 06:30:54

Made a crude replacement here atm, still thinking how to do without the repeat nest:
procedure Mix;
var
FailSafe: Integer;
begin
//Vial := DTMFromString('mlwAAAHicY2dgYNjPBMGHgfg4EB8A4h1AvAuIPzEyMDwE4rdA/A2I/wDxDyD+CMTldZsZClKNGNy8Mhlc3FMZSqrXMVQ0bGGoa93NwAo0FxdmxIOhAAB/uBW7');
//All := DTMFromString('mwQAAAHic42RgYOhgZGDYjIRB/CQgTobiViCeDcT9UHoJFC8G4plAPAEq93+GPIOpqSmDvYkCGCsqKjLw8fEDbWAEs0FyrEAeIcxIBIYDAGVGD5w=');
InvMouse(14, 3);
ClickMouse2(True);
Wait(RandomRange(37, 75));
InvMouse(15, 3);
ClickMouse2(True);
Wait(RandomRange(807, 898));
MMouse((MCX1+MCX2)/2 ,(MCY1+MCY2)/2 , 5, 5);
while not(IsUpText('All')) do
begin
Wait(RandomRange(20, 40));
Inc(FailSafe);
if (FailSafe > 50) then
begin
Writeln('Couldn''t find the make all button!');
FindNormalRandoms;
Inc(SuperFailSafe);
if (SuperFailSafe > 2) then
begin
Writeln('Oh no we come to a failure!');
Logout;
TerminateScript;
end;
Mix;
Exit;
end;
end;
Writeln(inttostr(failsafe));
ClickMouse2(True);
repeat
wait(100);
Inc(x);
until not (ExistsItem(21));
//(x > WaitTimer);
AntiBan;
x :=0;
FindNormalRandoms;
SuperFailSafe := 0;
Inc(LoadsCounter);
//FreeDTM(Vial);
end;

E: script is Jeffrey's Herblore if anyone cares.

BigFate

2012-09-18 06:49:23

From: l6bustank
Made a crude replacement here atm, still thinking how to do without the repeat nest:
procedure Mix;
var
FailSafe: Integer;
begin
//Vial := DTMFromString('mlwAAAHicY2dgYNjPBMGHgfg4EB8A4h1AvAuIPzEyMDwE4rdA/A2I/wDxDyD+CMTldZsZClKNGNy8Mhlc3FMZSqrXMVQ0bGGoa93NwAo0FxdmxIOhAAB/uBW7');
//All := DTMFromString('mwQAAAHic42RgYOhgZGDYjIRB/CQgTobiViCeDcT9UHoJFC8G4plAPAEq93+GPIOpqSmDvYkCGCsqKjLw8fEDbWAEs0FyrEAeIcxIBIYDAGVGD5w=');
InvMouse(14, 3);
ClickMouse2(True);
Wait(RandomRange(37, 75));
InvMouse(15, 3);
ClickMouse2(True);
Wait(RandomRange(807, 898));
MMouse((MCX1+MCX2)/2 ,(MCY1+MCY2)/2 , 5, 5);
while not(IsUpText('All')) do
begin
Wait(RandomRange(20, 40));
Inc(FailSafe);
if (FailSafe > 50) then
begin
Writeln('Couldn''t find the make all button!');
FindNormalRandoms;
Inc(SuperFailSafe);
if (SuperFailSafe > 2) then
begin
Writeln('Oh no we come to a failure!');
Logout;
TerminateScript;
end;
Mix;
Exit;
end;
end;
Writeln(inttostr(failsafe));
ClickMouse2(True);
repeat
wait(100);
Inc(x);
until not (ExistsItem(21));
//(x > WaitTimer);
AntiBan;
x :=0;
FindNormalRandoms;
SuperFailSafe := 0;
Inc(LoadsCounter);
//FreeDTM(Vial);
end;

E: script is Jeffrey's Herblore if anyone cares.



Ok I see what your trying to do now.

try doing

MarkTime(T);
repeat
if (ExistsItem(28)) then
wait(200);
else
break;
until TimeFromMark(T) > 15000;

l6bustank

2012-09-18 06:58:58

hm… Giving it a try.

E: gives me an identifier expected error for the else statement
E2:works now, but still slow detection.

CephaXz

2012-09-18 07:49:08

From: l6bustank
hm… Giving it a try.

E: gives me an identifier expected error for the else statement
E2:works now, but still slow detection.


How is it slow? I used it in one of my crafting script and it works VERY fast. And I don't think you would need to wait 2 seconds for detecting the DTM, mine detects instantly.

Antiban should be in the wait repeat, so you're doing antiban while making the potions instead of after finish making it. Try this and see if you can get the "Done" as soon as your slot 28 is free. If it does, that means its fast.

while ExistsItem(28) do
begin
wait(100);
if TimeFromMark(t) > 30000 then
begin
writeln('Wait too long...Breaking out of loop');
Break;
end;
end;
writeln('Done');

l6bustank

2012-09-18 08:24:55

Yeah, the detections itself is fast, I will try to modify the part in the end pf the procedure.
E: Woot, working!

CephaXz

2012-09-18 08:45:26

From: l6bustank
Yeah, the detections itself is fast, I will try to modify the part in the end pf the procedure.
E: Woot, working!


Glad it works :D