Page 1 of 2 12 LastLast
Results 1 to 25 of 27

Thread: Debugging onto the Runescape Canvas

  1. #1
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default Debugging onto the Runescape Canvas

    If you're lazy you can use these procedures to debug directly on the runescape canvas.

    They will show the Points Found by FindColors(or other functions that return dots) or boxes(SplitTpaex or such...) until you either press f2 oder f3.

    I guess it enhances the workflow.

    Heres an example for my mining site detection showing the points it found(right), and the box it generated(left).

    Left: procedure DrawBoxes(boxes:T2Dpointarray; Right: procedure DrawDots(pixels : TpointArray);



    SCAR Code:
    procedure DrawBoxes(boxes : T2DPointarray);
    var
      i,x,y,w,h : integer;
      drawing : TBitmap;
      B : Tbox;
    begin
      drawing := TBitmap.Create;
      drawing.canvas.handle := GetTargetDC;
      drawing.canvas.Pen.Color := CLRED;
     
      repeat
        for i:= 0 to high(boxes) do
        begin
          B := GetTPABounds(boxes[i]);
          drawing.canvas.moveto(B.x1,B.y1);
          drawing.canvas.LineTo(B.x2,B.y1);
          drawing.canvas.LineTo(B.x2,B.y2);
         
          drawing.canvas.LineTo(B.x1,B.y2);
          drawing.canvas.LineTo(B.x1,B.y1);

        end;
        wait(30);
      until(IsFkeyDown(3));
       
    end;

    procedure DrawDots(pixels : TpointArray);
    var
      i,x,y : integer;
      drawing : TBitmap;
    begin
      drawing := TBitmap.Create;
      drawing.canvas.handle := GetTargetDC;
      drawing.canvas.Pen.Color := CLRED;

      repeat
        for i:= 0 to high(pixels) do
        begin
          drawing.canvas.moveto(pixels[i].x-1,pixels[i].y);
          drawing.canvas.LineTo(pixels[i].x,pixels[i].y);
        end;
        wait(30);//Lag Reduction
      until(IsFKeyDown(2));
    end;

    ~caused

  2. #2
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by caused View Post
    If you're lazy you can use these procedures to debug directly on the runescape canvas.

    They will show the Points Found by FindColors(or other functions that return dots) or boxes(SplitTpaex or such...) until you either press f2 oder f3.

    I guess it enhances the workflow.

    Heres an example for my mining site detection showing the points it found(right), and the box it generated(left).

    Left: procedure DrawBoxes(boxes:T2Dpointarray; Right: procedure DrawDots(pixels : TpointArray);



    SCAR Code:
    procedure DrawBoxes(boxes : T2DPointarray);
    var
      i,x,y,w,h : integer;
      drawing : TBitmap;
      B : Tbox;
    begin
      drawing := TBitmap.Create;
      drawing.canvas.handle := GetTargetDC;
      drawing.canvas.Pen.Color := CLRED;
     
      repeat
        for i:= 0 to high(boxes) do
        begin
          B := GetTPABounds(boxes[i]);
          drawing.canvas.moveto(B.x1,B.y1);
          drawing.canvas.LineTo(B.x2,B.y1);
          drawing.canvas.LineTo(B.x2,B.y2);
         
          drawing.canvas.LineTo(B.x1,B.y2);
          drawing.canvas.LineTo(B.x1,B.y1);

        end;
        wait(30);
      until(IsFkeyDown(3));
       
    end;

    procedure DrawDots(pixels : TpointArray);
    var
      i,x,y : integer;
      drawing : TBitmap;
    begin
      drawing := TBitmap.Create;
      drawing.canvas.handle := GetTargetDC;
      drawing.canvas.Pen.Color := CLRED;

      repeat
        for i:= 0 to high(pixels) do
        begin
          drawing.canvas.moveto(pixels[i].x-1,pixels[i].y);
          drawing.canvas.LineTo(pixels[i].x,pixels[i].y);
        end;
        wait(30);//Lag Reduction
      until(IsFKeyDown(2));
    end;

    ~caused
    So this basicly draws over the runescape screen?

  3. #3
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Right. Or any other window specified.
    Last edited by caused; 10-02-2009 at 12:59 AM.

  4. #4
    Join Date
    Jul 2008
    Location
    England
    Posts
    763
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I'm pretty sure this could only debug onto SMART's debug canvas as the RuneScape client refreshes itself.
    lol

  5. #5
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Quote Originally Posted by Quickmarch View Post
    I'm pretty sure this could only debug onto SMART's debug canvas as the RuneScape client refreshes itself.
    No worries, it works, cause it's drawing every 30ms .

    ~caused

    Edit: Heres an example with trees.





    SCAR Code:
    program New;
    var
    blub: Tpointarray;
    blub2: T2DPointarray;

    procedure DrawBoxes(boxes : T2DPointarray);
    var
      i,x,y,w,h : integer;
      drawing : TBitmap;
      B : Tbox;
    begin
      drawing := TBitmap.Create;
      drawing.canvas.handle := GetTargetDC;
      drawing.canvas.Pen.Color := CLRED;

      repeat
        for i:= 0 to high(boxes) do
        begin
          B := GetTPABounds(boxes[i]);
          drawing.canvas.moveto(B.x1,B.y1);
          drawing.canvas.LineTo(B.x2,B.y1);
          drawing.canvas.LineTo(B.x2,B.y2);

          drawing.canvas.LineTo(B.x1,B.y2);
          drawing.canvas.LineTo(B.x1,B.y1);

        end;
        wait(30);
      until(IsFkeyDown(3));

    end;

    procedure DrawDots(pixels : TpointArray);
    var
      i,x,y : integer;
      drawing : TBitmap;
    begin
      drawing := TBitmap.Create;
      drawing.canvas.handle := GetTargetDC;
      drawing.canvas.Pen.Color := CLRED;

      repeat
        for i:= 0 to high(pixels) do
        begin
          drawing.canvas.moveto(pixels[i].x-1,pixels[i].y);
          drawing.canvas.LineTo(pixels[i].x,pixels[i].y);
        end;
        wait(30);//Lag Reduction
      until(IsFKeyDown(2));
    end;

    begin
    If FindColorsTolerance(blub,2182468,0,0,685,610,15) then
    DrawDots(blub);

    blub2 := SplitTpaEX(blub,3,3);
    DrawBoxes(blub2);

    end.
    Last edited by caused; 10-02-2009 at 01:48 AM.

  6. #6
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    wow... and how much lag does this create? I don't really see how it would make scripts more effective but it would definitely make them look more professional
    Lance. Da. Pants.

  7. #7
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I think it's more for making scripting easier. At least I would use it for debugging. Seems better then the functions in Debug.scar.

    Nice work, I really like this!

  8. #8
    Join Date
    Mar 2008
    Location
    New Jersey
    Posts
    1,673
    Mentioned
    1 Post(s)
    Quoted
    9 Post(s)

    Default

    this is awesome, this can help a lot for when you are mousing over the wrong object and want a bettor color. Such an awesome idea/script. Thanks so much, will definitely use this. REP+++

  9. #9
    Join Date
    Oct 2006
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

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

    Default

    I already played around with this. No need to use MoveTo() and LineTo(), it's simple as Rectangle(X1, Y1, X2, Y2) And drawing every 30 milliseconds might hassle your RAM after a while. Just use DebugTPA() to debug such thing or make it to use the SCAR's debug screen.


  11. #11
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Thanks everyone.

    Quote Originally Posted by Cazax View Post
    I already played around with this. No need to use MoveTo() and LineTo(), it's simple as Rectangle(X1, Y1, X2, Y2) And drawing every 30 milliseconds might hassle your RAM after a while. Just use DebugTPA() to debug such thing or make it to use the SCAR's debug screen.
    I tried rectangle first, but was too lazy to find out how to get the space it generates transparent ;D. So i just made lines.

    It's only for debugging, and doesnt require any external canvas, thats the advantage.

    Also I had problems with debugging boxes with the functions from debug.scar. It seems to sometimes fail.

    ~caused

  12. #12
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    I love it great idea <3. I love seeing pics with debug its so nice and awesome looking, makes me <3 SCAR and all of its power!

  13. #13
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    I love it great idea <3. I love seeing pics with debug its so nice and awesome looking, makes me <3 SCAR and all of its power!
    Haha : D. I guess i love staring at debug images as well .

    ~caused

  14. #14
    Join Date
    May 2007
    Location
    NSW, Australia
    Posts
    2,823
    Mentioned
    3 Post(s)
    Quoted
    25 Post(s)

    Default

    Very nice, looks and sounds.... Very nice!

    Ill get around to trying this , rep + 1.

  15. #15
    Join Date
    Jul 2008
    Location
    England
    Posts
    763
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    This good but the problem is you will always need some kind of loop to keep it displaying as the client would just refresh itself. But if Freddy added multi-threading (I tried making it in a plugin but it failed. ) then this could be run on a separate thread.
    lol

  16. #16
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    BobboHobbo: Thanks Alot , Feel free to try it out. It's perfect for debugging color-based scripts.

    Quote Originally Posted by Quickmarch View Post
    This good but the problem is you will always need some kind of loop to keep it displaying as the client would just refresh itself. But if Freddy added multi-threading (I tried making it in a plugin but it failed. ) then this could be run on a separate thread.
    Absolutely. Maybe we could construct something with timer though

  17. #17
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    This helps me alot! Thanks very much!
    rep++

  18. #18
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Quote Originally Posted by marpis View Post
    This helps me alot! Thanks very much!
    rep++
    Thanks, marpis. I'm glad you find it helpful, also feel free to check out my tutorial about Multithreading with timers, that would enable you to dynamicly debug, while your script is running.

    ~caused

  19. #19
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    To be honest this definitely isn't worth the trouble... Just debug on something that doesn't update every 30ms...



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  20. #20
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    To be honest this definitely isn't worth the trouble... Just debug on something that doesn't update every 30ms...
    What what what?
    I can't think of a better way to debug wheter TPAs and colours are what we are looking for. DebugTPA is good, but this is more userfriendly.

  21. #21
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    To be honest this definitely isn't worth the trouble... Just debug on something that doesn't update every 30ms...
    Yes, you could debug somewhere else.

    But that would always block parts of your screen. This is the ultimate solution for ultimate laziness .

    ~caused

  22. #22
    Join Date
    Mar 2010
    Location
    New Hampshire, U.S.A
    Posts
    586
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    so how would i draw text in runescape every 5 seconds?
    Sell botted goods at mid to high prices!!! Else we lose our profit AND ruin the game!!!!

  23. #23
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by g0tp0t View Post
    so how would i draw text in runescape every 5 seconds?
    You just grave digged... try to look at the last post date before you post.

    However, this is still a usefull thread.

    This is how I draw my proggy on the SMART canvas:
    SCAR Code:
    procedure DebugProggy(TP: TStringArray; DC, Colour, Shadow: integer);
    var
     MX, MY, Pic, OldDC, I, B, H, TPH, Numb: Integer;
     TTP: TPointArray;
    begin
      SmartSetDebug(True);
      GetClientDimensions(mx,my);
      Pic:= BitmapFromString(mx,my,'');
      OldDC := GetTargetDC;
      SetTargetDC(DC);
      TPH := High(TP);
      for I := 0 to TPH do
      begin
        TTP := LoadTextTPA(TP[i], FriendChars, H);
        for B := 0 to High(TTP) do
        begin
          Numb := ((I + 1) * 13);
          FastSetPixel(Pic, TTP[b].x + 10 + 1, TTP[b].y + 10 + Numb + 1, Shadow);
          FastSetPixel(Pic, TTP[b].x + 10, TTP[b].y + 10 + Numb, Colour);
        end;
      end;
      CopyCanvas(GetBitmapCanvas(Pic), GetClientCanvas, 0, 0, mx, my, 0, 0, mx, my);
      FreeBitmap(Pic);
      SetTargetDC(OldDC);
    end;

  24. #24
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    Quote Originally Posted by caused View Post
    BobboHobbo: Thanks Alot , Feel free to try it out. It's perfect for debugging color-based scripts.



    Absolutely. Maybe we could construct something with timer though
    Sorry for gravedig

    I prefer more SetTimeOut Function


    ~Home

  25. #25
    Join Date
    Feb 2010
    Location
    On the edge of space
    Posts
    160
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It doesn't draw anything.

Page 1 of 2 12 LastLast

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
  •