Results 1 to 4 of 4

Thread: Help with TBox's Please :)

  1. #1
    Join Date
    Jan 2013
    Posts
    21
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default Help with TBox's Please :)

    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:

    Simba 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.
    "It takes a man with nothing to appreciate the value of everything."

    - Taking script requests, message me. -

  2. #2
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    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)

    Simba Code:
    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

  3. #3
    Join Date
    Jan 2013
    Posts
    21
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    I always get this error :

    Simba Code:
    ** Warning in GaussBox: Point invalid (384, 315) **
    "It takes a man with nothing to appreciate the value of everything."

    - Taking script requests, message me. -

  4. #4
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Quote Originally Posted by ForMyFutures View Post
    I always get this error :

    Simba Code:
    ** 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:


    • Simba Code:
      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 ;
      Simba Code:
      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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •