SRL Archive - Research & Development Lounge

Debugging onto the Runescape Canvas


caused

2009-10-01 19:18:37

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);



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

Frement

2009-10-01 20:35:27

From: caused
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);



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?

caused

2009-10-01 20:57:37

Right. Or any other window specified.

Quickmarch

2009-10-01 21:29:53

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

caused

2009-10-01 21:31:22

From: Quickmarch
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.



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.

Lance

2009-10-01 23:13:23

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

Sabzi

2009-10-01 23:20:07

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!

Baked0420

2009-10-01 23:23:08

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+++

Rick

2009-10-01 23:44:21

Amazing. This will be really useful. Rep +

Cazax

2009-10-02 01:04:19

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.

caused

2009-10-02 01:14:31

Thanks everyone.

From: Cazax
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

YoHoJo

2009-10-02 01:41:47

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!

caused

2009-10-02 14:32:20

From: YoHoJo
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

BobboHobbo

2009-10-02 14:58:45

Very nice, looks and sounds…. Very nice!

Ill get around to trying this :), rep + 1.

Quickmarch

2009-10-02 15:04:40

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.

caused

2009-10-02 19:59:55

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

From: Quickmarch
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 ;)

marpis

2009-10-06 19:09:47

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

caused

2009-10-06 19:38:21

From: marpis
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

Wizzup?

2009-10-07 22:01:37

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

marpis

2009-10-07 23:23:26

From: Wizzup?
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.

caused

2009-10-08 02:05:37

From: Wizzup?
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

g0tp0t

2010-04-06 18:27:07

so how would i draw text in runescape every 5 seconds?

TRiLeZ

2010-04-06 20:06:53

From: g0tp0t
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:

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;

Home

2010-04-09 03:07:18

From: caused
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

Diddy Kong

2010-04-19 00:19:16

It doesn't draw anything. :duh:

i luffs yeww

2010-04-19 00:28:28

Which?

hackncrack1

2010-05-22 02:34:15

i love this!!!!!! thank you so much