Naum
02-10-2009, 04:38 PM
ScriptTerminate; <-- How to make a Script Print something before terminating
Intro
Hi, and welcome to a short tutorial on how to make a script do or print something before it is terminated. This may seem impossible but it actually very simple.
Method
SCAR calls a procedure called ScriptTerminate before terminating a script. If you dont have it e.g it is set to nil then it won't be called. But this is very usefull in some cases. You must write the procedure yourself.
This could be done as so:
Program ST;
Procedure ScriptTerminate;
Begin
WriteLn('Script has been terminated');
WriteLn('Thx for using');
End;
Begin
Repeat
Wait(800);
If Random(3) = 0 Then TerimateScript;
Until(False);
end.
This script will write in the debug box: 'Script has been terminated', 'Thx for using'; if the case happens that it terminates.
Cases Of Use
Case One : Your woodcutting script is running and you want it to print one last proggie before it ends or the user terminates it.
Program WCScript;
{.Include SRL/SRL.Scar}
Var x, y, Chopped : Integer;
Procedure ScriptTerminate;
Begin
WriteLn('Chopped '+IntToStr(Chopped)+' Logs!');
End;
Begin
SetupSRL;
Repeat
If FindObj(x, y, 'ree', clGreen, 25) Then
Begin
Mouse(x, y, 1, 1, True);
Wait(800 + Random(800));
Inc(Chopped);
End;
Until(InvFull);
End.
This will write in how many logs you have chopped, if you happen to stop it randomly whilst it is working.
Case Two : You want it to Logout before the script terminates
{.Include SRL/SRL.Scar}
Procedure ScriptTerminate;
Begin
LogOut;
End;
Begin
Repeat
WriteLn('Press CTRL+ALT+S');
Wait(800);
Until(False);
End.
EndNote
Script Terminate is a very useful procedure which I wasn't aware of a few months ago. Hope you can learn something from this very 'short tutorial' :).
Intro
Hi, and welcome to a short tutorial on how to make a script do or print something before it is terminated. This may seem impossible but it actually very simple.
Method
SCAR calls a procedure called ScriptTerminate before terminating a script. If you dont have it e.g it is set to nil then it won't be called. But this is very usefull in some cases. You must write the procedure yourself.
This could be done as so:
Program ST;
Procedure ScriptTerminate;
Begin
WriteLn('Script has been terminated');
WriteLn('Thx for using');
End;
Begin
Repeat
Wait(800);
If Random(3) = 0 Then TerimateScript;
Until(False);
end.
This script will write in the debug box: 'Script has been terminated', 'Thx for using'; if the case happens that it terminates.
Cases Of Use
Case One : Your woodcutting script is running and you want it to print one last proggie before it ends or the user terminates it.
Program WCScript;
{.Include SRL/SRL.Scar}
Var x, y, Chopped : Integer;
Procedure ScriptTerminate;
Begin
WriteLn('Chopped '+IntToStr(Chopped)+' Logs!');
End;
Begin
SetupSRL;
Repeat
If FindObj(x, y, 'ree', clGreen, 25) Then
Begin
Mouse(x, y, 1, 1, True);
Wait(800 + Random(800));
Inc(Chopped);
End;
Until(InvFull);
End.
This will write in how many logs you have chopped, if you happen to stop it randomly whilst it is working.
Case Two : You want it to Logout before the script terminates
{.Include SRL/SRL.Scar}
Procedure ScriptTerminate;
Begin
LogOut;
End;
Begin
Repeat
WriteLn('Press CTRL+ALT+S');
Wait(800);
Until(False);
End.
EndNote
Script Terminate is a very useful procedure which I wasn't aware of a few months ago. Hope you can learn something from this very 'short tutorial' :).