Results 1 to 12 of 12

Thread: TBox

  1. #1
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default TBox

    I've checked through the tutorials section and haven't found a great deal written on how to define a TBox or really use it..

    Would anyone please be able to explain how or whether it can be defined with a DTM or even just a set of colors?

    Essentially, I'd like to use it for when my script either finds and item or a spell to create a box around it and save that position for later use (so my script remembers where to withdraw from or cast the spell from).

    Also, is it possible to make it click in the centre of the TBox or anywhere within it's bounds?

    If this is written somewhere in the tutorials, my apologies I wasn't able to find it myself.

  2. #2
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    To click in the center of the TBox, you can do:

    Simba Code:
    Mouse((TBox.X1 + TBox.X2) / 2, (TBox.Y1, TBox.Y2) / 2, 0, 0, mouse_Left);

    You can also set TBox's with the IntToBox method.
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  3. #3
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    Simba Code:
    procedure LetMeExplain
    var
      TpaOne: TPointArray;
      OneBox: TBox;
    begin
      OneBox := IntToBox(238, 251, 312, 321); // the four co-ordinates of your box
      TpaOne := TPAFromBox(OneBox); // turns box into TPA (kind of)
        for i := 0 to High(TpaOne) do
        begin
          MiddleTPAEx(TpaOne, x, y); // gets the middle point
          Mouse(x, y, 0, 0, True); // clicks the middle point
          Break;
        end;
    end;

    Awesome procedure no?

  4. #4
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    A TBox is basically a rectangle, with the X1, Y1, X2, Y2 coordinates:
    X1,Y1+++++++
    +----------------+
    +----------------+
    +----------------+
    +----------------+
    ++++++++++X2,Y2

    When you find a DTM you tell the function where to search for, using the two points (x1,y1 and x2,y2).
    Finding the middle of the box is calculated like this:
    xmiddle: (x1+x2)/2
    ymiddle: (y1+y2)/2


  5. #5
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    Great! Thanks for the help, but with regards to using the DTM to set the TPoints of the TBox how would this work, given that functions like -
    Simba Code:
    begin
      if (FindDTM(HighAlch,x,y,MIX1,MIY1,MIX2,MIY2)) then
    end;
    Only return two values x and y..

    should i perhaps use
    Simba Code:
    IntToBox(x - 5, y - 5, x + 5, y + 5);

    Simba Code:
    procedure LetMeAttempt;
    var
      MyTPA: TPointArray;
      B: TBox;
      M: TPoint;
    begin
      if (FindDTM(HighAlch,x,y,MIX1,MIY1,MIX2,MIY2)) then
      begin
        B := IntToBox(x-5, y-5, x+5, y+5);
        MyTPA := TPAFromBox(B);
        for i := 0 to High(MyTPA) do
        begin
          M:= MiddleTPA(MyTPA)
          MMouse(M.x,M.y,0,0);
          ClickMouse2(True);
          Break;      
        end;
    end;

  6. #6
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    just
    Simba Code:
    if (FindDTM(HighAlch,x,y,MIX1,MIY1,MIX2,MIY2)) then
    begin
      MMouse(x,y,0,0);
      ClickMouse2(true);
    endl
    Basically you find DTM ,and coords of this DTM are assigned to x,y. You don't need to create TPoint to click on it. But if you really want you can convert it to TPOint this way:
    Simba Code:
    var
    P : TPoint;

     if (FindDTM(HighAlch,x,y,MIX1,MIY1,MIX2,MIY2)) then
    begin
      P := Point(x,y);
      MMouse(P.x,P.y,0,0);
      ClickMouse2(true);
    endl
    Last edited by bg5; 05-08-2012 at 05:06 AM.

  7. #7
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    Yeh all you really need to do is what beginner said

    Just ignore everything I wrote!



    EDIT: As a side-note, FindDTMs will return TPA's
    Last edited by Abu; 05-08-2012 at 05:11 AM.

  8. #8
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    Was kind of just trying to find a way to click in the centre of the DTM rather than over to the side where it seems to be clicking quite regularly..

    Along with trying to grasp a better understanding of both TBoxes and TPAs

    Already had a similar method to beginner prior to this thread. But, never the less thank-you to everyone for all of your help.

  9. #9
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Was kind of just trying to find a way to click in the centre of the DTM
    x,y are coords of Main(First) point of DTM. So if you want to click in the center ,then make DTM with first point on the center. For randomization you can make this one inbuilt in MMouse(x,y,Random_x,Random_y);

  10. #10
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    So when I make the DTM use a point close to the centre of it as the first point and the others outlying on the black line and it will click roughly in the centre?

  11. #11
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    It will click wherever your first point is - because that is the is the x and y it will return.

  12. #12
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    Fantastic! Thanks heaps, I wasn't aware that where I chose the centre point when making a DTM was really relevant at all after it's creation.

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
  •