SRL Archive - Help and Support

Script Maker


Special Ed

2007-03-20 18:46:18

Ok… I'm trying to make this script that you run and then all you do is play RS, it records your actions and uses "Writeln" to display the coding in the debug box. It's going smoothly so far but i need someone to give me a hand fixing this function. This is not meant to create a script for you but merely to help you make framework for it.

*BTW if anyone wants to help or give some ideas it would be greatly appreciated*

This part of the coding works on rightclick in the mainscreen, it finds what you clicked on and what option you chose but it has a lot of trouble finding what object you clicked on "The Name" at least but it works well otherwise.

The problem I'm having is that I want it to find the objects name using the option box rather than having it use the uptext, it only works every once and a while but if no one can fix it to make it work this way i have another idea.

Still having trouble with the RightClick but I added some new stuff…

[New] 3.21.07

Make_RadialWalk March 21st
StartRadialDegrees March 21st
EndRadialDegrees March 21st
MouseIn_Quadrant March 21st
SpecialArcTan March 21st

T'm kinda confused on the RadialWalk thing because it says to use numbers between 0 - 1440 but in the examples it is using degrees ..

StartRadial/EndRadial := Any number between 0-1440. 0=N,90=E,180=S,270=W. DO NOT USE NUMBERS UNDER 0 or ABOVE 1440

procedure RightClick_MainScreen;
var
MX,MY,Color,OptX,OptY,MouseRand:integer;
Opt1,Opt2,Opt3,Opt4,RightObjName:string;
begin
if(IsMouseButtonDown(false))then
begin
if(not(MouseIn_MainScreen))then
begin
Exit;
end;
if(MouseIn_MainScreen)then
begin
Wait(500);
GetMousePos(MX,MY);
Color:= GetColor(MX,MY - 10);
Opt1:= Trim(GetTextAtEx(MX - 52, MY + 19, 20, upchars, True, True, 0, 3, 16777215, 30, False, tr_AllChars));
Opt2:= Trim(GetTextAtEx(MX - 52, MY + 34, 20, upchars, True, True, 0, 3, 16777215, 30, False, tr_AllChars));
Opt3:= Trim(GetTextAtEx(MX - 52, MY + 49, 20, upchars, True, True, 0, 3, 16777215, 30, False, tr_AllChars));
Opt4:= Trim(GetTextAtEx(MX - 52, MY + 64, 20, upchars, True, True, 0, 3, 16777215, 30, False, tr_AllChars));
Writeln(Opt1);
Writeln(Opt2);
Writeln(Opt3);
Writeln(Opt4);
begin
repeat
Wait(100);
until(IsMouseButtonDown(true));
GetMousePos(OptX,OptY);
end;
if(IsMouseButtonDown(true) and ((MX - 52) < OptX) and (OptX < (MX + 52)) and ((MY + 19) < OptY) and (OptY < (MY + 34)))then
begin
MouseRand:= (Random(3) + 1);
RightObjName:= Trim(GetTextAtEx(MX - 52, MY + 19, 100, upchars, False, False, 0, 3, 16776960, 50, False, tr_AllChars));
Writeln('FindObj(x,y,' + RightObjName + ',' + inttostr(Color) + ',' + inttostr(MouseRand) + ');');
Writeln('Mouse(x,y,' + inttostr(MouseRand) + ',' + inttostr(MouseRand) + ',false);');
Writeln('PopUp(' + Opt1 + ');');
end;
if(IsMouseButtonDown(true) and ((MX - 52) < OptX) and (OptX < (MX + 52)) and ((MY + 34) < OptY) and (OptY < (MY + 49)))then
begin
MouseRand:= (Random(3) + 1);
RightObjName:= Trim(GetTextAtEx(MX - 52, MY + 34, 100, upchars, False, False, 0, 3, 16776960, 50, False, tr_AllChars));
Writeln('FindObj(x,y,' + RightObjName + ',' + inttostr(Color) + ',' + inttostr(MouseRand) + ');');
Writeln('Mouse(x,y,' + inttostr(MouseRand) + ',' + inttostr(MouseRand) + ',false);');
Writeln('PopUp(' + Opt2 + ');');
end;
if(IsMouseButtonDown(true) and ((MX - 52) < OptX) and (OptX < (MX + 52)) and ((MY + 49) < OptY) and (OptY < (MY + 64)))then
begin
MouseRand:= (Random(3) + 1);
RightObjName:= Trim(GetTextAtEx(MX - 52, MY + 49, 100, upchars, False, False, 0, 3, 16776960, 50, False, tr_AllChars));
Writeln('FindObj(x,y,' + RightObjName + ',' + inttostr(Color) + ',' + inttostr(MouseRand) + ');');
Writeln('Mouse(x,y,' + inttostr(MouseRand) + ',' + inttostr(MouseRand) + ',false);');
Writeln('PopUp(' + Opt3 + ');');
end;
if(IsMouseButtonDown(true) and ((MX - 52) < OptX) and (OptX < (MX + 52)) and ((MY + 64) < OptY) and (OptY < (MY + 80)))then
begin
MouseRand:= (Random(3) + 1);
RightObjName:= Trim(GetTextAtEx(MX - 52, MY + 64, 100, upchars, False, False, 0, 3, 16776960, 50, False, tr_AllChars));
Writeln('FindObj(x,y,' + RightObjName + ',' + inttostr(Color) + ',' + inttostr(MouseRand) + ');');
Writeln('Mouse(x,y,' + inttostr(MouseRand) + ',' + inttostr(MouseRand) + ',false);');
Writeln('PopUp(' + Opt4 + ');');
end;
end;
end;
end;

P.S. If you want to check out my progress so far you can download it but PLEASE give me feedback, also this will be members when it comes out I think.

mage of begu

2007-03-21 12:48:39

This could be great…you should really add somekind of RadialRoadWalk thing to there that if you walk it makes it a RRW…

Bobarkinator

2007-03-21 13:32:38

I'm not exactly sure how to do it but you can use pos and delete I think. Pos gets part of a string so you can get the text in the option box then delete the first part and only take the name.

Special Ed

2007-03-21 16:25:01

Yes I know that but thanks for the feedback, I'm just having troubles figuring out the co-ordinates and what not. If you want to give me a hand it would be more than helpful.

I'm working on radialwalking at the moment * what a coincidence * so an updated version should be out in a bit.

Here is my Make_RadialWalk procedures…

//Modded from SRL/SRL/core/math.scar "ArcTan2"
function SpecialArcTan(y,x:Extended):Extended;
begin
if(y = MMCY) and (x < MMCX) then Result := Radians(180.0);
if(y = MMCY) and (x > MMCX) then Result := Radians(0.0);
if(x = MMCX) and (y < MMCY) then Result := Radians(270.0);
if(x = MMCX) and (y > MMCY) then Result := Radians(90.0);
if(Result = 0.0) and (x <> MMCX) then
if(x = 0) then
begin
x:= 1;
end;
if(Abs(y) / Abs(x) = 1.0) then
begin
if(y > MMCY) and (x > MMCX) then Result := Radians(45.0);
if(y > MMCY) and (x < MMCX) then Result := Radians(135.0);
if(y < MMCY) and (x < MMCX) then Result := Radians(225.0);
if(y < MMCY) and (x > MMCX) then Result := Radians(315.0);
end;
if Result = 0 then
begin
Result := ArcTan(Abs(-y) div Abs(x));
if(y > MMCY) and (x < MMCX) then Result := Result + Radians(90.0);
if(y < MMCY) and (x < MMCX) then Result := Result + Radians(180.0);
if(y < MMCY) and (x > MMCX) then Result := Result + Radians(270.0);
end;
end;

function FlagIn_Quadrant:integer;
var MPX,MPY:integer;
begin
FindColor(MPX,MPY,255,MMX1,MMY1,MMX2,MMY2);
begin
if(((648 < MPX)and(MPX < 735))and((5 < MPY)and(MPY < 86)))then begin Writeln('Quad 1'); Result:= 1; end;
if(((570 < MPX)and(MPX < 648))and((5 < MPY)and(MPY < 86)))then begin Writeln('Quad 2'); Result:= 2; end;
if(((570 < MPX)and(MPX < 648))and((86 < MPY)and(MPY < 166)))then begin Writeln('Quad 3'); Result:= 3; end;
if(((648 < MPX)and(MPX < 735))and((86 < MPY)and(MPY < 166)))then begin Writeln('Quad 4'); Result:= 4; end;
if((648 = MPX)and(5 < MPY)and(MPY < 86))then begin Writeln('0 / 360'); Result:= 5; end; //0
if((MPY = 86)and(570 < MPX)and(MPX < 648))then begin Writeln('270'); Result:= 6; end; //270
if((MPY = 86)and(648 < MPX)and(MPX < 735))then begin Writeln('90'); Result:= 7; end; //90
if((648 = MPX)and(86 < MPY)and(MPY < 166))then begin Writeln('180'); Result:= 8; end; //180
end;
end;

function StartRadialDegrees:extended;
var RadX,RadY,ZeroX,ZeroY,AngleInRadians,AngleInDegrees:Extended;
MPX,MPY:integer;
begin
if(not(FlagPresent))then Exit;
GetMousePos(MPX,MPY);
RadX:= (MMCX - MPX);
RadY:= (MMCY - MPY);
ZeroX:= (MMCX)
ZeroY:= (MMCY + 72)
AngleInRadians:= (Abs((SpecialArcTan(ZeroY,ZeroX) - SpecialArcTan(RadY,RadX))));
AngleInDegrees:= ((AngleInRadians * 180) / Pi);
if(FlagIn_Quadrant = 1)then result:= (180 - AngleInDegrees);
if(FlagIn_Quadrant = 2)then result:= (180 + AngleInDegrees);
if(FlagIn_Quadrant = 3)then result:= ((180 - AngleInDegrees) + 180);
if(FlagIn_Quadrant = 4)then result:= (AngleInDegrees);
if(FlagIn_Quadrant = 5)then result:= 0;
if(FlagIn_Quadrant = 6)then result:= 270;
if(FlagIn_Quadrant = 7)then result:= 90;
if(FlagIn_Quadrant = 8)then result:= 180;
end;

function EndRadialDegrees:extended;
var RadX,RadY,ZeroX,ZeroY,AngleInRadians,AngleInDegrees:Extended;
MPX,MPY,FIQ:integer;
begin
if(not(FlagPresent))then Exit;
begin
repeat
if(FlagIn_Quadrant = 1)then FIQ:= 1
if(FlagIn_Quadrant = 2)then FIQ:= 2
if(FlagIn_Quadrant = 3)then FIQ:= 3
if(FlagIn_Quadrant = 4)then FIQ:= 4
if(FlagIn_Quadrant = 5)then FIQ:= 5
if(FlagIn_Quadrant = 6)then FIQ:= 6
if(FlagIn_Quadrant = 7)then FIQ:= 7
if(FlagIn_Quadrant = 8)then FIQ:= 8
Wait(100);
until(not(FlagPresent));
end;
RadX:= (MMCX - MPX);
RadY:= (MMCY - MPY);
ZeroX:= (MMCX)
ZeroY:= (MMCY + 72)
AngleInRadians:= (Abs((SpecialArcTan(ZeroY,ZeroX) - SpecialArcTan(RadY,RadX))));
AngleInDegrees:= ((AngleInRadians * 180) / Pi);
if(FIQ = 1)then result:= (180 - AngleInDegrees);
if(FIQ = 2)then result:= (180 + AngleInDegrees);
if(FIQ = 3)then result:= ((180 - AngleInDegrees) + 180);
if(FIQ = 4)then result:= (AngleInDegrees);
if(FIQ = 5)then result:= 0;
if(FIQ = 6)then result:= 270;
if(FIQ = 7)then result:= 90;
if(FIQ = 8)then result:= 180;
end;

procedure Make_RadialWalk;
var CX,CY,Color,MouseRand,Dist,SR2,ER2:integer;
SR,ER:extended;
begin
if(not(IsMouseButtonDown(true)) and (not(FlagPresent)))then Exit;
if(IsMouseButtonDown(true) and FlagPresent)then
begin
FindColor(CX,CY,255,MMX1,MMY1,MMX2,MMY2);
Color:= GetColor(CX + 2,CY)
SR:= StartRadialDegrees;
ER:= EndRadialDegrees;
SR2:= Trunc(SR);
ER2:= Trunc(ER);
Dist:= Distance(MMCX,MMCX,CX,CY);
MouseRand:= (Random(3) + 1);
Writeln('RadialWalk(' + inttostr(Color) + ',' + inttostr(SR2) + ',' + inttostr(ER2) + ',' + inttostr(Dist) + ',' + inttostr(MouseRand) + ',' + inttostr(MouseRand) + ');');
end;
end;