BenLand100
2007-08-20 21:35:02
Firstly copy the dll (in the Release folder) into you're plugin folder. You will also need Java 1.6+ in order to use SMART. Every script that wishes to use a SMART function must call SmartSetup before using any, unless you want to meet Crashzilla. Note that the server string is the server prefix, not world number. Call SmartSetup as follows:
SMART also provides other mouse methods for the advanced user.:
procedure SmartSetup(server: String; hidetail, signed: Boolean);This will load the server only if its not already loaded, as it takes some time (a few seconds) to init a server. You can call SmartReady (which takes no arguments and returns a boolean) at any time to check if SMART is able to receive commands. The next step is to set Scar's target to SMART. This can be done in 3.06+ by calling SetTargetDC(SmartGetDC); or in 1.13+ by calling the following procedure.procedure SmartSetTarget;
var
Smart_Bitmap: Integer;
begin
Smart_Bitmap:= BitmapFromString(765,503,'');
GetBitmapCanvas(Smart_Bitmap).Handle:= SmartGetDC;
SetTargetBitmap(Smart_Bitmap);
FreeBitmap(Smart_Bitmap);
end;The next logical step is to redirect mouse and key events. I've made this VERY SIMPLE for all of you poptards out there ;) Simply put the following code in an include and make it the *FIRST* include in you're program (or the program you are converting).procedure MoveMouse(x, y: Integer);
begin
SmartMoveMouse(x, y);
end;
procedure HoldMouse(x, y: Integer; left: Boolean);
begin
SmartHoldMouse(x, y, left);
end;
procedure ReleaseMouse(x, y: Integer; left: Boolean);
begin
SmartReleaseMouse(x, y, left);
end;
procedure KeyUp(key: Byte);
begin
SmartReleaseKey(key);
end;
procedure KeyDown(key: Byte);
begin
SmartHoldKey(key);
end;
procedure SendKeys(S: String);
begin
SmartSendKeys(S);
end;
procedure GetMousePos(var x, y: Integer);
begin
SmartGetMousePos(x, y);
end;
That will override the specified commands that I've found are most common in SRL and the scripts that I've looked at. Now, since its embedded, you can just override the low level movemouse procedure and use windmouse or anything else from SRL. Note that this does not override any other 'built in' procedures, such as SendKeysSilent or KeyUpSilent, etc. You'll have to do those on a need-to-be-done basis.SMART also provides other mouse methods for the advanced user.:
procedure SmartWindMouse(x, y: Integer); //Built in WindMouse algorithm
procedure SmartDragMouse(x, y: Integer); //Drags from the current pos to the end pos
procedure SmartClickMouse(x, y: Integer; left: Boolean); //Moves via WindMouse to the pos and clicksIf you are really savvy and want to use some blisteringly fast color searches, you might try SMART's color searching methods. Please note that they do not (as of yet ;)) support scar bitmaps, you must pass the dc of the bitmap which is retrieved via GetBitmapCanvas(bmp).Handle;function SmartGetColor(x, y: integer): integer;
function SmartFindColor(var x, y: integer; color, sx, sy, ex, ey: integer): boolean;
function SmartFindColorTolerance(var x, y: integer; color, sx, sy, ex, ey, tol: integer): boolean;
function SmartFindColorSpiral(var x, y: integer; color, sx, sy, ex, ey: integer): boolean;
function SmartFindColorSpiralTolerance(var x, y: integer; color, sx, sy, ex, ey, tol: integer): boolean;
function SmartFindBitmap(hdc: integer; var x, y: integer): boolean;
function SmartFindBitmapIn(hdc: integer; var x, y: integer; sx, sy, ex, ey: integer): boolean;
function SmartFindBitmapToleranceIn(hdc: integer; var x, y: integer; sx, sy, ex, ey, tol: integer): boolean;There is coded support for setting SMART's target (ie. to another image), the different color tolerance modifiers, fast RGB<>HSL conversion, a faster similar colors, and a few other interesting things, but I haven't made them available to Scar yet.