SRL Archive - OSR Help

InvBox


Sin

2012-11-09 07:23:19

procedure CheckInventory;
var
i,p,tmpCTS:Integer;
Box:TBox;
foodCount,x,y:Integer;
begin
ToIni('Checking for food in inventory');
tmpCTS := GetColorToleranceSpeed;
for i := 1 to 28 do
begin
for p := 0 to 2 do
begin
SetColorspeed2Modifiers(Foods[p].HMod,Foods[p].SMod);
Box := InvBox(i);
if FindColor(x,y,Foods[p].Color,Box.X1,Box.Y1,Box.X2,Box.Y2) then
begin
foodCount := foodCount + 1;
ToIni('Food found in slot ' + IntToStr(i));
end;
end;
end;


How exactly does "InvBox" work? Does it convert the slot in the parameters into a box? Not too clear on it. If it doesn't… I'll just have to write a new one.

Not the complete procedure btw.

riwu

2012-11-09 07:27:30

Yeah it returns the TBox of the inv slot. Do you have anything else other than

ToIni('Checking for food in inventory');
tmpCTS := GetColorToleranceSpeed;
before your for loop?

Sin

2012-11-09 07:28:58

From: riwu
Yeah it returns the TBox of the inv slot.

Do you have anything else other than

ToIni('Checking for food in inventory');
tmpCTS := GetColorToleranceSpeed;
before your for loop?


Alright thanks!
And no, I don't.

riwu

2012-11-09 07:30:18

I think the problem is that you didn't set it to CTS 2 then.

Sin

2012-11-09 07:31:25

From: riwu
I think the problem is that you didn't set it to CTS 2 then.


Ah I derped on that one xD
I haven't actually tested it yet, I wrote it when I didn't have access to the internet.
Thanks again!

Flight

2012-11-09 07:33:04

From: riwu
I think the problem is that you didn't set it to CTS 2 then.


Indeed. Also, remember to set your CTS back to 1 upon exiting the procedure.

Sin

2012-11-09 07:33:45

From: Flight
Indeed. Also, remember to set your CTS back to 1 upon exiting the procedure.


Yup, did that ;)
SetColorToleranceSpeed(tmpCTS);

Just kinda forgot it that once haha.

Sin

2012-11-09 07:43:00

Edit button not working?
Well i'll post this and ask a mod to merge it.

Anyways, anyone know what happened to PosInArray? I can't seem to find it :(

riwu

2012-11-09 07:47:14

From: Shay
Edit button not working?
Well i'll post this and ask a mod to merge it.

Anyways, anyone know what happened to PosInArray? I can't seem to find it :(

What is that meant to do? Or are you looking for StrInArr?

Nebula

2012-11-09 10:13:44

From: riwu
What is that meant to do? Or are you looking for StrInArr?

Once upon a time PosInArray returned the position of a variable in an array. One day it magically disappered along with one of the most useful functions ever, BoolToInt.

Sin

2012-11-09 12:55:29

http://paste.villavu.com/show/3577/

http://paste.villavu.com/show/3576/

Which one do you think is more efficient?