SRL Archive - OSR Help

Help with TBox's Please :)


ForMyFutures

2013-02-04 19:42:01

Okay so I'm trying to use cases so when a number between 1 and 4 is generated the script will click on a designated box, however, I think either my parameters are wrong, or I perhaps don't understand it?

Anyways, here's the code:


procedure CleanHerbs;
var
ItemBox, CleanBox1, CleanBox2, CleanBox3, CleanBox4: TBox;
begin
CleanBox1.X2:= 264;
CleanBox1.Y2:= 322;
CleanBox1.X1:= 298;
CleanBox1.Y1:= 305;

CleanBox2.X2:= 321;
CleanBox2.Y2:= 323;
CleanBox2.X1:= 350;
CleanBox2.Y1:= 310;

CleanBox3.X2:= 368;
CleanBox3.Y2:= 320;
CleanBox3.X1:= 400;
CleanBox3.Y1:= 310;

CleanBox4.X2:= 440;
CleanBox4.Y2:= 320;
CleanBox4.X1:= 460;
CleanBox4.Y1:= 304;


if not (GameTab(Tab_Inv)) then
FTab(Tab_Inv) else
begin
Wait(RandomRange(300, 600));
case Random(4) of
1: GetInvItemBounds(7, ItemBox);
2: GetInvItemBounds(5, ItemBox);
3: GetInvItemBounds(3, ItemBox);
4: GetInvItemBounds(4, ItemBox);
end;
MouseTbox(ItemBox, Mouse_left);
Wait(RandomRange(750, 800));
case Random(4) of
1: MouseTBox(CleanBox1, Mouse_left);
2: MouseTBox(CleanBox2, Mouse_left);
3: MouseTBox(CleanBox3, Mouse_left);
4: MouseTBox(CleanBox4, Mouse_left);
end;
end;


end;

Also, it's basically to click the clean button once the interface has popped up to clean a herb. Help is much appreciated! Cheers.

Le Jingle

2013-02-04 19:54:58

No idea what's going on, but I tried to help you out by showing you a more formal format + explaining what the code does (briefly)


program new;
{$i srl/srl.simba}

procedure CleanHerbs;
var
rIntArr : TIntegerArray;
CleanBox : TBoxArray;
ItemBox : TBox;
begin
{ re - enter the box coordinates here,
you want to make sure you use the correct
x1 , y1 and then x2 , y2 parameters. You
appeared to have this X2 Y2 X1 Y1...
(which doesn't follow SRL standards, and
can be confusing. so stick with x1,y1,x2,y2 format
}
CleanBox[0] := IntToBox(x1, y1, x2, y2);
CleanBox[1] := IntToBox(x1, y1, x2, y2);
CleanBox[2] := IntToBox(x1, y1, x2, y2);
CleanBox[3] := IntToBox(x1, y1, x2, y2);

{
here, you try gameTab'ing to the inventory,
but if not successful, then you'll try FTabs.
You could always make a personal wait function for this too.}
if not GameTab(Tab_Inv) then
FTab(Tab_Inv);

// no idea what this static wait is for?
Wait(RandomRange(300, 600));

// a small array to use for randomizing our itemBox returned.
rIntArr := [3, 4, 5, 7];

// uses the int array above to pick a random number in the array.
GetInvItemBounds(rIntArr[Random(4)], ItemBox);

MouseTbox(ItemBox, Mouse_left);

// again no idea what this static wait is for
Wait(RandomRange(750, 800));

// clicks a random Box, created from the 0..3 (aka 4 index length array)
// box array declared earlier, again randomizing the box to click.
MouseTBox(CleanBox[Random(4)], Mouse_Left);
end;

Cheers,
-Lj

ForMyFutures

2013-02-04 20:36:55

I always get this error :


** Warning in GaussBox: Point invalid (384, 315) **

Le Jingle

2013-02-04 20:57:58

From: ForMyFutures
I always get this error :


** Warning in GaussBox: Point invalid (384, 315) **


I believe you should sort the .X1's, etc as I said in the code example.
I'll try to explain better/be more clear;

Declaring a TBox (a single box) is as follows:


  • someBox := IntToBox(x1, y1, x2, y2);
    //example
    // someBox := IntToBox(10, 15, 20, 25);
    Here, you list the x1 coordinate of the TBox, or the first lowest value x, the first lower value y, the second higher value x, the second higher value y. ^ When I say lower/higher, I mean that the x1 < x2 in terms on the number/integer value used. (same with y1 < y2) ^^ X1 is less than the X2 number/integer. <- this should keep you from getting a gauss box error.
  • Also represented / equilavent to ;

    someBox.x1 := {lower x} 10;
    someBox.y1 := {lower y} 10;
    someBox.x2 := {higher x} 20;
    someBox.y2 := {higher y} 20;

* Do note , the 0, 0 starting point is in the upper left corner of the RS window. So going 50 across (or +50 to the x coordinate, starts from the upper left RS corner of the screen and goes +50x without and y (up or down) to the new 50, 0 point)

Does that make sense?

Cheers,
-Lj