SRL Archive - MSI Suggestions

Smart Debugging


Sir R. M8gic1an

2010-08-15 05:43:20

Many people have seen the sort of debugging I have on my Guild Miner.

For those who haven't: My script debugs the rocks that it finds on SMART, meaning it colors them 'on the screen'.

I find this is extremely useful for debugging purposes and to realize where things go right and wrong. And the correct timings and so on.

What do you guys think? I could probably have this in SRL rather than specifically MSI, but I thought we might just use it here :)

~RM

Coh3n

2010-08-15 11:05:12

Absolutely! :)

Just pluck a "SmartDebug" into the object functions and we're good to go. I also agree that this should be added to SRL, I'm sure it would get used a lot.

marpis

2010-08-15 15:15:22

The best way to debug any finding functions is to paint.
I would have done this already if I knew how :p

NCDS

2010-08-15 18:24:16

Yes sir!

I'm plugging this into WaitWhileMining for personal testing reasons to try and get it working better as we speak :p

nickrules

2010-08-16 17:03:56

I once made a script that did this (but never finished it). It was extremely helpful, as well, as the fact, that it looks awesome (imo)

Sir R. M8gic1an

2010-08-31 00:05:13


{ RM --------------------------------------------------------------------------]

[ Clears Canvas ]

[------------------------------------------------------------------------------}

Procedure ClearSmartPaint(canvas: TCanvas);

{$ifdef SmartDebug}

var

CleanBMP: integer;

{$endif}

begin

{$ifdef SmartDebug}

CleanBMP := BitmapFromString(MIX2, MIY2, '');

{$ifdef Simba}

DrawBitmap(CleanBMP,Canvas,0,0);

{$else}

SafeDrawBitmap(CleanBMP, canvas, 0, 0);

{$endif}



try

FreeBitmap(CleanBMP);

except end;

{$endif}

end;



{ caused edited by RM ---------------------------------------------------------]

[ Paint a TPA onto the Smart Debug Canvas ]

[------------------------------------------------------------------------------}

procedure DrawDots(pixels : TpointArray);

{$ifdef SmartDebug}

var

i : integer;

drawing : TBitmap;

begin

drawing := TBitmap.Create;

drawing.canvas.handle := SmartGetDebugDC;

drawing.canvas.Pen.Color := clRed;



ClearSmartPaint(drawing.canvas);



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;



try

FreeBitmap(drawing);

except end;

{$else}

begin

{$endif}

end;



{ RM based on DrawBoxes by caused ---------------------------------------------]

[ Draws a box, Rock size. ]

[------------------------------------------------------------------------------}

procedure DrawBox(Box: TPointArray; color: TColor);

{$ifdef SmartDebug}

var

drawing : TBitmap;

TP : TPoint;

B: TBox;

begin

drawing := TBitmap.Create;

drawing.canvas.handle := SmartGetDebugDC;

drawing.canvas.Pen.Color := color;



ClearSmartPaint(drawing.canvas);



TP := MiddleTPA(Box);

B := MakeMSBox(TP, 20);



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



try

FreeBitmap(drawing);

except end;

{$else}

begin

{$endif}

end;

From my guild miner. I'll get onto it later.

~RM

Coh3n

2010-08-31 00:08:20

Sounds good. The double spacing really annoyed me when I used Ubu. :p

Sir R. M8gic1an

2010-08-31 07:51:02

Some further work. Will get it into SRL soon.

Procedure ClearSmartPaint(canvas: TCanvas);
{$IFDEF SMART}
var
CleanBMP: integer;
begin

CleanBMP := BitmapFromString(MIX2, MIY2, '');

{$ifdef Simba}
DrawBitmap(CleanBMP,Canvas,0,0);
{$else}
SafeDrawBitmap(CleanBMP, canvas, 0, 0);
{$endif}

try
FreeBitmap(CleanBMP);
except end;

{$ELSE}
begin
{$ENDIF}

end;

{ caused edited by RM ---------------------------------------------------------]
[ Paint a TPA onto the Smart Debug Canvas ]
[------------------------------------------------------------------------------}
procedure DrawDotsEx(Clear: boolean; pixels: TPointArray; color: TColor);
{$IFDEF SMART}
var
i : integer;
drawing : TBitmap;
begin

drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
drawing.canvas.Pen.Color := color;

ClearSmartPaint(drawing.canvas);

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;

try
FreeBitmap(drawing);
except end;

{$ELSE}
begin
{$ENDIF}

end;

procedure DrawDots(Dots: TPointArray);
begin
DrawDotsEx(True, Dots, clRed);
end;

{ RM based on DrawBoxes by caused ---------------------------------------------]
[ Draws a box, Rock size. ]
[------------------------------------------------------------------------------}

procedure DrawBoxEx(Clear: boolean; Box: TBox; color: TColor);
{$IFDEF SMART}
var
drawing : TBitmap;
TP : TPoint;
B: TBox;
begin

drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
drawing.canvas.Pen.Color := color;

ClearSmartPaint(drawing.canvas);

drawing.canvas.moveto(Box.x1,Box.y1);
drawing.canvas.LineTo(Box.x2,Box.y1);
drawing.canvas.LineTo(Box.x2,Box.y2);
drawing.canvas.LineTo(Box.x1,Box.y2);
drawing.canvas.LineTo(Box.x1,Box.y1);


try
FreeBitmap(drawing);
except end;

{$ELSE}
begin
{$ENDIF}

end;

procedure DrawBox(Box: TBox);
begin
DrawBoxEx(True, Box, clRed);
end;

~RM

Nava2

2010-08-31 08:13:34

RM, when copying from WINE it will do that.

Copy it from gEdit or something similar.

Sir R. M8gic1an

2010-08-31 09:58:52

I did.. :s it's fine.

From gEdit -> double spaced
From Simba(wine) -> normal spaced

~RM

Nava2

2010-08-31 13:25:15

Odd.. I didn't get issues from gEdit, but did from WINE. Weird.

Sir R. M8gic1an

2010-09-03 07:27:16

Committed PaintSmart.scar to SRL. Will apply it to core object finding functions later :)

~RM

Coh3n

2010-09-03 14:28:47

Awesome! :) I'll update the core to-do list.

JuKKa

2010-09-03 15:29:31

I remember wizzup having a function that painted all points stored in a TPA. Maybe someone could dig that up and rewrite it maybe?

Sir R. M8gic1an

2010-09-03 23:10:05

From: JuKKa
I remember wizzup having a function that painted all points stored in a TPA. Maybe someone could dig that up and rewrite it maybe?


DrawDots does this.. Although Wizzup's was probably faster.

~RM

Bonfield

2010-09-04 04:08:37

Could this be made to work on the runescape client not just smart?

JuKKa

2010-09-04 04:26:02

Yes, but u wont be able to see it, the runescape canvas refreshes too fast

Coh3n

2010-09-07 22:55:18

If you already don't know, this has been committed in both MSI and SRL. :)