SRL Archive - OSR Help

Compiling Error- Type Mismatch


Hazzah

2012-03-29 22:24:33

Okay, so I'm fairly new to trying to script and am not sure why this is not working!
procedure XPGainCheck;
var
P,x,y:integer;
begin
P:= DTMFromString('mQwAAAHicY2ZgYGBmZGDIB+KlQLY0EAsA8Sog/vP3D8OdO3cYEqNDGJABIxIGAgBMSwiO');

// if(Not(FindDTM(P,x,y,MSX1,MSY1,MSX2,MSY2))) >60000 then
begin
WriteLn('No Xp Gained for some minutes, Terminating Script')
FreeDTM(P);
TerminateScript;
end;
end;

the error is

[Hint] C:\Simba\Includes\SRL/SRL/core/mapwalk.simba(1353:3): Variable 'BOX' never used at line 1352
[Error] (460:65): Type mismatch at line 459
Compiling failed.

ReadySteadyGo

2012-03-29 22:29:06

Hi there Hazzah,

WriteLn('No Xp Gained for some minutes, Terminating Script');

You missed a semicolon.

Hazzah

2012-03-29 22:31:41

Ohh my! Such a dumb mistake, does Simba always point to the wrong line like this?

Edit: That did not fix the error, I don't think it was compiling that far to tell me I was missing a semi-colon. :/

ReadySteadyGo

2012-03-29 22:37:20

Sorry, I'm not entirely sure what you are asking.

It will always fail to compile if there is a type mismatch.

[Error] (460:65): Type mismatch at line 459

This line tells you that, and where it is.

It's up to you to learn and be able to recognise the characteristics of the language.


E: Just saw your edit. Please post the whole script and the debug.

Also, this:

[Hint] C:\Simba\Includes\SRL/SRL/core/mapwalk.simba(1353:3): Variable 'BOX' never used at line 1352

leads me to believe that you haven't updated SRL and/or SPS.


Ok, forgive me, I didn't see this before. You've got the IF statement commented out. Uncomment it.
if(Not(FindDTM(P,x,y,MSX1,MSY1,MSX2,MSY2))) >60000 then

That also makes no sense to have the '>60000'. The 'not' is returning a boolean (0 or 1), and therefore will never be greater than 60000. What are you trying to achieve?

Hazzah

2012-03-29 22:41:29

Okay, what I was trying to to do, very simply of course, because I am not very good at scripting, was to run a check to see if the onscreen exp check was there (the little bubble that pops up that your xp floats up to). If it was not there for 1 minutes then the script would terminate.

ReadySteadyGo

2012-03-29 22:51:59

From: Hazzah
Never mind I figured it out. I cant put >60000 inside a if - then statement.


Of course you can, it will return true or false. Is there something specific you're trying to check?

E:

From: Hazzah
Okay, what I was trying to to do, very simply of course, because I am not very good at scripting, was to run a check to see if the onscreen exp check was there (the little bubble that pops up that your xp floats up to). If it was not there for 1 minutes then the script would terminate.


OK, you need a loop.


procedure XPGainCheck;
var
P, x, y, t:integer;
begin
P:= DTMFromString('mQwAAAHicY2ZgYGBmZGDIB+KlQLY0EAsA8Sog/vP3D8OdO3cYEqNDGJABIxIGAgBMSwiO');

t := GetSystemTime;

repeat
if FindDTM(P,x,y,MSX1,MSY1,MSX2,MSY2) then
Break;
if (GetSystemTime > (t + 60000)) then
begin
WriteLn('No Xp Gained for some minutes, Terminating Script')
FreeDTM(P);
TerminateScript;
end;
Wait(100);
until False;

end;

Hazzah

2012-03-29 23:00:51

Okay, what I was trying to to do, very simply of course, because I am not very good at scripting, was to run a check to see if the onscreen exp check was there (the little bubble that pops up that your xp floats up to). If it was not there for 1 minutes then the script would terminate.

ReadySteadyGo

2012-03-29 23:08:21

You don't have to edit everything btw, you can make new replies, makes it easier to keep track of the conversation. ;)

Hazzah

2012-03-29 23:16:53

Haha, I edited it before your post had showed up to me (my connection is laggy which is why I want to add this check) and I didn't want to double post.

ReadySteadyGo

2012-03-29 23:18:38

Ok, no worries, was that what you are after?

Hazzah

2012-03-29 23:36:31

This is not quite working, I was trying to add a fail safe to a construction script so that it would not sit for hours right clicking in the wrong spot, I wanted to make it so that, if it did not detect the onscreen xp bubble for one minute, then it would terminate the script and log out. However this does not seem to be working as I had planned :/

ReadySteadyGo

2012-03-29 23:49:23

From: Hazzah
This is not quite working, I was trying to add a fail safe to a construction script so that it would not sit for hours right clicking in the wrong spot, I wanted to make it so that, if it did not detect the onscreen xp bubble for one minute, then it would terminate the script and log out. However this does not seem to be working as I had planned :/


Try debugging your DTM, use WriteLn() to print something if it finds the DTM.

Hazzah

2012-03-29 23:56:32

The DTM editor continues to find it using the "Show Matching DTM's" however the script does not seem to find it.

procedure XPGainCheck;
var
ConSkillDTM, x, y, t:integer;
begin
ConSkillDTM:= DTMFromString('mQwAAAHicY2ZgYGBmZGDIB+KlQLY0EAsA8Sog/vP3D8OdO3cYEqNDGJABIxIGAgBMSwiO');

t := GetSystemTime;

repeat
if FindDTM(ConSkillDTM,x,y,MSX1,MSY1,MSX2,MSY2) then
writeln('We found it!');
Break;
if (GetSystemTime > (t + 10000)) then
begin
WriteLn('No Xp Gained for some minutes, Terminating Script')
FreeDTM(ConSkillDTM);
TerminateScript;
end;
Wait(100);
until False;
end;

m34tcode

2012-03-30 00:02:01

this may be due to the slight rotation of the runescape scren. In fact, it probably is. Just a tnth of a degree will throw off your dtm

You must use FindDtmRotated();

This will take into account the rotation. also, try adding a slight area tolerance to you sub points in the dtm. I tend to use area size of 2 for sub points

Hazzah

2012-03-30 00:10:15

I tried that m34tcode and still do not get a return, the weird thing is, now I have edited it to

procedure XPGainCheck;
var
ConSkillDTM, x, y, t:integer;
begin
ConSkillDTM:= DTMFromString('mQwAAAHicY2ZgYIhjgIBTQMwNxLOg/D9//zAkRocw3LlzB8w3gmJGIGaCYiAAAExkCNM=');

t := GetSystemTime;

repeat
if FindDTMRotated(ConSkillDTM,x,y,MSX1,MSY1,MSX2,MSY2,-Pi,Pi,Pi/30,aFound) then
writeln('We found that mother fucker!');
if not(FindDTMRotated(ConSkillDTM,x,y,MSX1,MSY1,MSX2,MSY2,-Pi,Pi,Pi/30,aFound)) then
begin
WriteLn('No Xp Gained for some minutes, Terminating Script')
FreeDTM(ConSkillDTM);
TerminateScript;
end;
Wait(100);
until False;
end;

and I still do not get the script terminated like it should when it does not find the DTM on screen for the 10000 (I believe this is in miliseconds, so 10 seconds).

m34tcode

2012-03-30 00:13:45

did you add area to your subpoints and update the dtm?

an area of just 2 on each point, and you can move the angle increment up to 2 degrees

also try using Radains()

I Use Radians(-5),Radians(5),Radians(1) as parameters

Hazzah

2012-03-30 00:23:46

I did set the area to 2, and converted to the Radians(-5)… although Pi, -Pi, and P/30, are Radian measures.

procedure XPGainCheck;
var
ConSkillDTM, x, y, t:integer;
begin
ConSkillDTM:= DTMFromString('mQwAAAHicY2ZgYIhjgIBTQMwNxLOg/D9//zAkRocw3LlzB8w3gmJGIGaCYiAAAExkCNM=');

t := GetSystemTime;

repeat
if FindDTMRotated(ConSkillDTM,x,y,MSX1,MSY1,MSX2,MSY2,Radians(-5),Radians(5),Radians(1),aFound) then
WriteLn('We found it!');
if not(FindDTMRotated(ConSkillDTM,x,y,MSX1,MSY1,MSX2,MSY2,Radians(-5),Radians(5),Radians(1),aFound)) then
begin
WriteLn('No Xp Gained for some minutes, Terminating Script')
FreeDTM(ConSkillDTM);
TerminateScript;
end;
Wait(100);
until False;
end;

Procedure MainLoop;
Begin
If WaitFunc(@FindEmpty,100,3000) Then
Begin
If WaitFunc(@FindBuild,100,7000) Then
WaitFunc(@FindDoor,100,5000) Else
XPGainCheck;
FindDoor;
End Else
If FindBuild Then
WaitFunc(@FindDoor,100,5000) Else
FindDoor;
End;


No Xp Gained for some minutes, Terminating Script
Successfully executed.

I did get one successful hit on that section, although it still is not writing that it has found the DTM, and if it gets moved off its position it for some reason will not terminate the script. (I am trying to add another failsafe to ashamans Oak doorer since I have the funds to test it and the time).

Edit: I have to get some sleep, have a Math test and Chem test tomorrow! Thanks for you help and here is what I have done to the script, perhaps someone here can figure it out for me :P.

Program AshamanDoorer;
{$define SMART}
{$Define Crashsmart}
{$include srl/srl/misc/smart.simba}
{$i srl/srl.simba}
{$i SRL\SRL\misc\paintsmart.simba}
{$I SRL/SRL/Misc/Debug.simba}

{

AshamanDoorer v1.4
-Make sure you have a full load of Oak Planks on you
-Make sure you are ONLY USING DEMON BUTLER
-Make sure you have already told the demon butler to go get 26 planks
-Make sure you are standing in the right place. The Door recess in the furthest room you have in the cardinal direction you chose.
}

//Fill these in.
Const
SRLStats_Username = ''; // Leave blank if you don't have a stats account
SRLStats_Password = '';
Direction = 'N' ; // Set this to whatever direction your door is (like the picture)
OnScreen = True; // Set this to false if you don't want onscreen proggy (may increase speed)

Procedure DeclarePlayers;
Begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ''; //Username
Players[0].Pass := ''; //Password
Players[0].Active := True;
End;

//////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// //
// Don't touch below this line unless you know what you're doing!! //
// //
//////////////////////////////////////////////////////////////////////////////////////////////////////

Const
A=237;
B=172; // No touchy
C=269;
D=202;

ScriptVersion = '1.4';

Var
DoorCount,XP,StartTime,StartingExperience,DoorsPH,XPH,Sec: Integer;
DButlerDTM,SpotDTM,MessCount,Count: Integer;
aFound: Extended;

Procedure SetDTM;
Begin
DButlerDTM := DTMFromString('mQwAAAHicY2ZgYNBkhGAtIJ4O5C8E4pVAbCLGz7B6yWKG8qIiBn4gH4YZkTAQAADyswY6');
SpotDTM := DTMFromString('mggAAAHicY2NgYChmYmBIAeIWKK4A4kIgDgHKJQFxAhCnAXE+FP///5/hGwMbBv4PlOPHghlxYAgAAI+fDm4=');
End;

Procedure Fr33DTM;
Begin
FreeDTM(DButlerDTM);
FreeDTM(SpotDTM);
End;


Function FindButler:Boolean;
Var
X,Y,T: Integer;
Begin
Result := False;

If MessCount > 20 Then
Begin
Writeln('Messed up somewhere, logging off');
Logout;
Fr33DTM;
Terminatescript;
End;

If(Not(LoggedIn)) Then
Exit;

If ((Not FindDTMRotated(DButlerDTM,X,Y,MSX1,MSY1,MSX2,MSY2,-Pi,Pi,Pi/30,aFound)) And (OptionsExist(['Exam','mine','Examine','Canc','ncel','Cancel'],False))) Then
Begin
MMouse(200,200,100,100);
End;

If FindDTMRotated(DButlerDTM,X,Y,235,170,275,223,-Pi,Pi,Pi/30,aFound) Or FindDTMRotated(DButlerDTM,X,Y,278,135,310,186,-Pi,Pi,Pi/30,aFound) Or FindDTMRotated(DButlerDTM,X,Y,189,125,239,174,-Pi,Pi,Pi/30,aFound) Then
Begin
Mouse(X,Y,4,4,False);

If WaitOptionMulti(['etch','from','bank'],RandomRange(700,900)) Then
Begin
MarkTime(T);
Repeat
Wait(Random(200));
Until ((FindNPCChatText('coins',Nothing)) Or (FindNPCChatText('nother', Nothing)) Or (TimeFromMark(T) > 8000));

If (FindNPCChatText('coins',Nothing)) Then
Begin
ClickContinue(True, True);
TypeSendEx('1',False);
Wait(RandomRange(800,1000));

Mouse(X,Y,4,4,False);
WaitOption('etch',RandomRange(700,900));
Wait(randomRange(900, 1100));
End;

If (FindNPCChatText('nother', Nothing)) Then
Begin
TypeSendEx('1',False);
Wait(RandomRange(500,700));
Count := 0;
Result := True;
End;
End;
End;
End;

Function FindEmpty:Boolean;
Var
X,Y,H,H2,I,CTS,T: Integer;
pArray: TPointArray;
aPArray: T2DPointArray;
Begin
Result := False;

If(Not(LoggedIn)) Then
Exit;

If Count >= 2 Then
Begin
MarkTime(T);
Repeat
Wait(100);
Until ((FindButler) Or (TimeFromMark(T) > 10000));
End;

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);

SetColorSpeed2Modifiers(0.51, 0.02);
FindColorsSpiralTolerance(MSCX, MSCY, pArray, 7435639, A, B, C, D, 15);
aPArray := TPAtoATPAEx(pArray, 20, 20);

If (Length(aPArray) = 0) Then
Begin
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
MessCount := MessCount + 1;
End;

H := High(aPArray);
If H < 1 Then
H2 := H Else
H2 := 1;

For I := 0 To H2 Do
Begin
MiddleTPAEx(aPArray[I], X, Y);
MMouse(X, Y, 4, 4);

If (WaitUpTextMulti(['Wal','alk'],300)) Then
Begin
GetMousePos(X,Y);
Mouse(X,Y,0,0,False);

If Count >= 1 Then
Begin
MarkTime(T);
Repeat
Wait(100);
Until (InvCount >10) Or (TimeFromMark(T)>5000);

If InvCount < 10 Then
Begin
MMouse(50,50,100,100);
FindButler;

Marktime(T);
Repeat
Wait(100);
Until ((InvCount > 10) or (TimeFromMark(T) > 30000))
End;

If InvCount < 10 Then
Begin
Writeln('Out of supplies. Goodbye!');
Logout;
Fr33DTM;
Terminatescript;
End;
End;

If WaitOptionMulti(['uild','Buil','oor'],RandomRange(700,900)) Then
Begin
Wait(RandomRange(300,400));
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Result := True;
Exit;
End;
End;
End;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
End;

{*******************************************************************************
Function PrintonSmart;
By: Shuttleu
Edited By: Ashaman88
Description: Will put progress report on screen.
*******************************************************************************
Procedure PrintOnSmart(TP: TStringArray; Placement: TPoint; Colour: integer);
var
mx, my, Pic, I, E, H, TPH, Numb: Integer;
TTP: TPointArray;
Canvas: TCanvas;
begin
SmartSetDebug(True);
GetClientDimensions(mx, my);
Pic := BitmapFromString(mx, my, '');
TPH := High(TP);
for I := 0 to TPH do
begin
TTP := LoadTextTPA(TP[i], UpChars, H);
for E := 0 to High(TTP) do
begin
Numb := ((I + 1) * 13);
FastSetPixel(Pic, TTP[E].x + 1, TTP[E].y + Numb + 1,131072);
FastSetPixel(Pic, TTP[E].x, TTP[E].y + Numb, Colour);
end;
end;
Canvas := TCANVAS.Create;
Canvas.Handle := SmartGetDebugDC;
DrawBitmap(Pic, Canvas, Placement.x, Placement.y);
FreeBitmap(Pic);
end;

*******************************************************************************
Function ProgressReport;
By: Sin and parts by Shuttleu
Edited By: Ashaman88
Description: Will Make a progress report.
*******************************************************************************
Procedure ProgressReport;
Var
SmartLines: TStringArray;
Begin
Sec:= (1+((Getsystemtime-StartTime)/1000));
XP := (GetXPBarTotal - StartingExperience);
XPH := (3600 / SeC * (XP));
DoorsPH := (3600*DoorCount) / Sec;

If OnScreen Then
Begin
SetArrayLength(SmartLines, 9);

SmartLines[0]:= '==========================';
SmartLines[1]:= '=====AshamanDoorerV'+ScriptVersion+'=======';
SmartLines[2]:= 'Time Running: ' + TimeRunning;
SmartLines[3]:= 'Doors Made: ' + IntToStr(DoorCount);
SmartLines[4]:= 'Experience Earned: ' + IntToStr(XP);
SmartLines[5]:= 'Experience/Hour: ' + IntToStr(XPH);
SmartLines[6]:= 'Doors/H: ' + IntToStr(DoorsPH);
SmartLines[7]:= '===========================';
SmartLines[8]:= '===========================';

PrintOnSmart(SmartLines,Point(15,200),clRed);
End;

Writeln('===========================');
Writeln('=====AshamanDoorerV'+ScriptVersion+'=========');
Writeln('Time Running: ' + TimeRunning);
Writeln('Doors Made: ' + IntToStr(DoorCount));
Writeln('Experience Earned: ' + IntToStr(XP));
Writeln('Experience/Hour: ' + IntToStr(XPH));
Writeln('Doors/H: ' + IntToStr(DoorsPH));
Writeln('===========================');
Writeln('===========================');

Stats_IncVariable('Oak Doors (Constructed)', 1);
Stats_Commit;
End; }

Function FindBuild:Boolean;
Var
X,Y: Integer;
Begin
Result := False;

If(Not(LoggedIn)) then
Exit;

MouseBox(103,62,115,84,Mouse_Move);
GetMousePos(X,Y);

If WaitUpTextMulti(['uild','Oak','door','oor'],RandomRange(2000,2200)) Then
Begin
Mouse(X,Y,0,0,True);
If DidYellowClick Then
Begin
Mouse(629,61,4,4,True);

Wait(RandomRange(400,500));

Repeat
Wait(100);
Until (Not(Ismoving));
End Else
Begin
Count := Count + 1;
DoorCount := DoorCount + 1;
MessCount := 0;
Result:=True;
//ProgressReport;
MouseBox(A,B,C,D,Mouse_Move);
End;
End;
End;

Function FindDoor: Boolean;
Var
X,Y,H,H2,I,CTS1,T: Integer;
pArray2: TPointArray;
aPArray2: T2DPointArray;
Begin
Result := False;

If(Not(LoggedIn)) Then
Exit;

CTS1 := GetColorToleranceSpeed;
ColorToleranceSpeed(2);

SetColorSpeed2Modifiers(0.07, 0.39);
FindColorsSpiralTolerance(MSCX, MSCY, pArray2, 4480367, A, B, C, D, 15);
aPArray2 := TPAtoATPAEx(pArray2, 20, 20);

If (Length(aPArray2) = 0) Then
Begin
ColorToleranceSpeed(CTS1);
SetColorSpeed2Modifiers(0.2, 0.2);
End;

H := High(aPArray2);
If H < 1 Then
H2 := H Else
H2 := 2;

For I := 0 To H Do
Begin
MiddleTPAEx(aPArray2[I], X, Y);
MMouse(X, Y, 4, 4);

If (WaitUpTextMulti(['Open','pen','Door','oor'],400)) Then
Begin
GetMousePos(X,Y);
Mouse(X,Y,0,0,False);

If WaitOption('emove',RandomRange(700,900)) Then
Begin
MarkTime(T);
Repeat
Wait(Random(200));
If (TimeFromMark(T) > 4000) Then
Begin
FindDoor;
Exit;
End;
Until (FindNPCChatText('Yes',Nothing));

TypeSendEx('1',False);

If Count < 2 Then
MouseBox(A,B,C,D,Mouse_Move);


ColorToleranceSpeed(CTS1);
SetColorSpeed2Modifiers(0.2, 0.2);
Result := True;
Exit;
End;
End;
End;
ColorToleranceSpeed(CTS1);
SetColorSpeed2Modifiers(0.2, 0.2);
End;

procedure XPGainCheck;
var
ConSkillDTM, x, y, t:integer;
begin
ConSkillDTM:= DTMFromString('mQwAAAHicY2ZgYIhjgIBTQMwNxLOg/D9//zAkRocw3LlzB8w3gmJGIGaCYiAAAExkCNM=');

t := GetSystemTime;

repeat
if FindDTMRotated(ConSkillDTM,x,y,MSX1,MSY1,MSX2,MSY2,Radians(-5),Radians(5),Radians(1),aFound) then
writeln('We found that mother fucker!');
if not(FindDTMRotated(ConSkillDTM,x,y,MSX1,MSY1,MSX2,MSY2,Radians(-5),Radians(5),Radians(1),aFound)) then
begin
WriteLn('No Xp Gained for some minutes, Terminating Script')
FreeDTM(ConSkillDTM);
TerminateScript;
end;
Wait(100);
until False;
end;

Procedure MainLoop;
Begin
If WaitFunc(@FindEmpty,100,3000) Then
Begin
If WaitFunc(@FindBuild,100,7000) Then
WaitFunc(@FindDoor,100,5000) Else
XPGainCheck;
FindDoor;
End Else
If FindBuild Then
WaitFunc(@FindDoor,100,5000) Else
FindDoor;
End;

Procedure Setup;
Begin
Smart_Server := 10;
Smart_Members := True;
Smart_Signed := True;


SetupSRL;
If (SRLStats_Username = '') Then
SetupSRLStats(948, 'Anonymous', 'anon1337')
Else
SetupSRLStats(948, SRLStats_Username, SRLStats_Password);
SmartSetRefresh(75);

ClearDebug;
SMART_ClearMS;
SMART_ClearCanvas;

DeclarePlayers;

AddOnTerminate('Fr33DTM');
SetDTM;

If (Not LoggedIn) Then
Writeln('Please log in and setup the position as needed');

Repeat
Wait(randomRange(500,1500));
Until (LoggedIn);

If InvCount < 28 Then
Repeat
Writeln('Please get a full inventory of planks');
Wait(RandomRange(3000,4000));
Until (InvCount = 28);

MakeCompass(Direction);
SetAngle(SRL_ANGLE_HIGH);

ToggleXPBar(True);
StartingExperience := GetXPBarTotal;
StartTime:=GetSystemTime;
End;


Begin
Setup;
FindButler;
//XPGainCheck;
Repeat
Mainloop;
Until (AllPlayersInactive);
Fr33DTM;
End.