Results 1 to 24 of 24

Thread: Help making a box

  1. #1
    Join Date
    May 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default Help making a box

    Hi

    How can I make a box around x, y anywhere on the main screen?
    So I would move the mouse to x, y and check for a colour in that box.

    Thanks

  2. #2
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    you can do
    Simba Code:
    MMouse(x, y, 3, 3);
    findcolor(a, b, color, x - 10, y - 10, x + 10, y + 10)
    and alter the amount added and subtracted from x and y to increase/decrease the size of your box. Hope I helped
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

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

    Default

    You can set the xs,ys,xe,ye with relation to the mouses x and y co-ords. Something like below:

    Simba Code:
    MMouse(x,y,0,0);
      if FindColorTolerance(x,y,color,x-50,y-50,x+50,y+50,tol) then
        Mouse(x,y,0,0,mouse_Left);

    'd

  4. #4
    Join Date
    May 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    I'll give them a go. Thanks

  5. #5
    Join Date
    May 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Ok so I gave that box a go and it didn't seem to work for me. What I'm trying to do is make a function to search for health bars. Maybe I could find an NPC then check for a DTM mask of the health bar? Would that work? I've read a lot about TPA's but I really don't understand then or how I would use it to find the health bar.

    What would be better and what should I work towards?

    Thanks

  6. #6
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,322
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by bambe View Post
    Ok so I gave that box a go and it didn't seem to work for me. What I'm trying to do is make a function to search for health bars. Maybe I could find an NPC then check for a DTM mask of the health bar? Would that work? I've read a lot about TPA's but I really don't understand then or how I would use it to find the health bar.

    What would be better and what should I work towards?

    Thanks
    I think there is already a function in the SRL include that finds HP bars... 1 sec

    Edit:
    Try running this:
    Simba Code:
    program new;
      {$DEFINE SMART}
      {.include SRL/SRL.simba}
      {.include SPS/SPS.simba}
      {.include SRL/SRL/skill/magic.simba}
      {$IFDEF SIMBAMAJOR980}
        {.include SRL\SRL\MISC\Paintsmart.simba}
      {$ELSE}
        {.include SRL\SRL\Misc\SmartGraphics.simba}
      {$ENDIF}
    Var
      Points : array of TPoint;
    begin

      {$IFDEF SMART}
        {$IFDEF SIMBAMAJOR980}
          Smart_Server := 72;
          Smart_Members := True;
          Smart_Signed := True;
          Smart_SuperDetail := False;
        {$ELSE}
          SRL_SixHourFix := True;
          Smart_FixSpeed := True;
        {$ENDIF}
      {$ENDIF}

      Points := GetFightBarTPA(MSBox);
      SMART_DrawDotsEx(True, Points, clAqua);

    end.
    Last edited by putonajonny; 07-28-2012 at 11:52 AM.

  7. #7
    Join Date
    May 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Thanks for the quick reply but my issue is because it's for a rsps that won't work. This is why I'm trying to write a function

  8. #8
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,322
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Ok, do you want to post a screenshot of what the bar looks like, then I can help better

  9. #9
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Yeah what type of bar is it... the new style bar or the old style?

  10. #10
    Join Date
    May 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Ive attached a screenshot for you.

  11. #11
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    My knowledge on this is a 'tad rusty, but I think I can help you.
    Simba Code:
    procedure Example();
    var
      x, y: Integer;
      b: TBox;
    begin
      b := (IntToBox(x + 25, y + 25, x - 25, y - 25));
      if ... then
      begin
      end;
    end;

    Let me explain what we're doing here. We first define x and y as integers and we also define b as a TBox (that's just 4 values to make a box).
    Once we define those variables, we make b's values (x1, y1, x2, y2) to be dependant on x and y's values. So we take x and increase it by 25, y by 25 and then decrease the next x and y values.

    This makes a box of 25 pixels above and lower than the x and y values. This will allow us to search within the box. That's where the if ... then comes in and you replace it with what you want.

    E: Just for a little 'bit more insight: If you know TPAs & 2D TPAs well enough, you can get the boundaries of a 2D TPA and make a box around it with the size you desire. This will allow you to accurately enough tell where the HP bar is and judge what you want to do based on that.

    I'm very rusty at this so I can't explain it very well, but I hoped that help a little.
    Last edited by RISK; 07-28-2012 at 05:37 PM.
    Simba Code:
    (* Main *)

    repeat
      WriteLn('I am an idiot!');
    until(False);

  12. #12
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,322
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by bambe View Post
    Ive attached a screenshot for you.
    That looks like the same one from normal RS, so what I posted above will probably still work...

  13. #13
    Join Date
    May 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Thanks everyone for the help. I'll see how it goes and post if I get stuck again

  14. #14
    Join Date
    May 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Hi again,
    After having a play around i keep getting errors

    Warning! You passed a wrong xs to a finder function: -25. That is below 0, thus out of bounds. Setting the value to 0 for now.
    Warning! You passed a wrong ys to a finder function: -25. That is below 0, thus out of bounds. Setting the value to 0 for now.

    i get this when i do

    Simba Code:
    x - 25, y - 25, x + 25, y + 25

    any ideas how to stop this?

    i can make and search a box at any point on the screen just not around the the mouse x, y

  15. #15
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Hi bambe,

    That warning means that you are searching outside the bounds of the client. Remember, a client is essentially a box, starting at (0, 0) and ending at (whateverX, whateverY). Now, what you are essentially doing is searching before that region (before (0, 0)) - you are searching from (-25, -25) to (whereverX, whereverY). Obviously, that is impossible, since nothing of the client exists before that initial (0, 0) starting point What Simba is telling you by warning you, is that it has corrected this and put the top-left corner of your box to (0, 0).

    Regards,
    ~ Daniel.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  16. #16
    Join Date
    May 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    hmm in that case how do i make a box which is following x,y?

    I need to be able to search a box at x,y and just cant seem to do it

  17. #17
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by bambe View Post
    hmm in that case how do i make a box which is following x,y?

    I need to be able to search a box at x,y and just cant seem to do it
    Daniel just explained it. Just ignore the warning, simba auto fix it to start from 0 as area outside that don't exist anyway so it wont affect the search result.

  18. #18
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    If you want your box in the far top left corner, then this is correct. Otherwise you will need to use mmouse, then getmousepos(x, y).
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

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

    Default

    You will need to use MMouse, but GetMousePos is not necessary as your mouse's co-ordinates will already be stored in the variables x and y, thus no need for GetMousePos..

    In addition to that, GetMousePos is actually not working so, best if you don't use it.

  20. #20
    Join Date
    May 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Im looking to make a box at x,y anywhere on the mainscreen where ever the colour im searching for is found.

    FindColor
    MMouse
    Then search for a color in a box at x,y


    I keep trying to use IntToBox but cant seem to get it to work.

    If there is a tutorial on making boxes and how to use them ill be more then happy to take a look if someone can point me in the right direction.
    Last edited by bambe; 08-02-2012 at 10:59 PM.

  21. #21
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I read a tut on this last week, give me a minute.
    I learned Tboxes in this tutorial, its on pixelshift, but at the beggining, it gives a brief overlook on how to use a TBox. If you need help on tboxes, dont ask me, I only know what i learned in this tutorial. :P
    Last edited by Footy; 08-03-2012 at 01:50 AM.
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

  22. #22
    Join Date
    Mar 2007
    Location
    USA
    Posts
    1,433
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by bambe View Post
    Im looking to make a box at x,y anywhere on the mainscreen where ever the colour im searching for is found.

    FindColor
    MMouse
    Then search for a color in a box at x,y


    I keep trying to use IntToBox but cant seem to get it to work.

    If there is a tutorial on making boxes and how to use them ill be more then happy to take a look if someone can point me in the right direction.
    Am I missing something? Why aren't you just using something like
    Simba Code:
    if FindColoredArea(x, y, YourColor, LeftX, TopY, RightX, BottomY, SmallestSize) then
    begin
       MMouse(x, y, RandomRange(5, 10), RandomRange(5, 10));
       Writeln('Color found at: x: ' + IntToStr(x) + ' y: ' IntToStr(y));
    end;
    I'm Silent SPY
    Secret project: 0%
    Need help? Send me a PM

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

    Default

    if find the colour on the mainscreen, then make a box relative to the x and y co-ordinates that you found the colour. I don't know what else you want to do so I didn't expand the procedure any further, but in it's most basic form that is what I believe you are asking for?
    Simba Code:
    procedure MakeBox;
    var
      x, y: Integer;
      Box: TBox;
    begin
      if FindColor(x, y, WhateverColor, MSx1, MSy1, MSx2, MSy2) then
        Box := IntToBox(x - 20, y - 20, x + 20, y + 20);
    end;

  24. #24
    Join Date
    May 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    ah i understand now! So im finding the colour then making a box at them coords to check for my next colour.

    i thought then box would be made then follow x,y checking for a colour.

    thanks

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
  •