Results 1 to 14 of 14

Thread: A note on ScriptTerminate;

  1. #1
    Join Date
    Mar 2007
    Posts
    4,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    A note on ScriptTerminate;

    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:
    SCAR Code:
    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.
    SCAR Code:
    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
    SCAR Code:
    {.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' .


  2. #2
    Join Date
    Feb 2007
    Posts
    3,622
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice tut. I used to wonder how to do this...

    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.
    Is it possible you mean set to NUL, not nil?

  3. #3
    Join Date
    Mar 2007
    Posts
    4,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  4. #4
    Join Date
    Feb 2007
    Posts
    3,622
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    Nil is the actual 'command' if you like that SCAR uses . Though Null is just the same.
    Hmm... Idk why; nil just sounds funny lol.

  5. #5
    Join Date
    Dec 2007
    Posts
    2,714
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    You can, I presume, use something else than Writeln when useing ScriptTerminate like LogOut or Bank or Drop Ores, stuff like that ?

  6. #6
    Join Date
    Mar 2007
    Posts
    4,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  7. #7
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    731
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    this is realy good, ima use it so that a proggy is thrown in upon termination so the proggy will always be exact x]
    Lance. Da. Pants.

  8. #8
    Join Date
    Dec 2008
    Posts
    2,829
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    their is also ScriptPause

    no like ScriptStart or ScriptResume (those don't work).. is their one that does ScriptResume?

  9. #9
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Case of Use Three:

    Freeing dtms.

    SCAR Code:
    {.Include SRL/SRL.Scar}

    var
      Lolwut : Integer;
     
    Procedure ScriptTerminate;
    Begin
      FreeDTM(Lolwut)
    End;
     
    Begin
      Lolwut := DTMFromString('78DA63E460626090616440060E1A720CFC401' +
           'A24FA1F0818B9816A2451D540646124906603AA9123A0860B538D' +
           '9F810AA63952F8CD010019D30604');
      Repeat
        WriteLn('Press CTRL+ALT+S');
        Wait(800);
      Until(False);
    End.


    ~Sandstorm

  10. #10
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,887
    Mentioned
    6 Post(s)
    Quoted
    121 Post(s)

    Default

    Making sure DTMs have been freed, as well as calling one last progress report are what I use it for. Also, in your example script, you misspelled TerminateScript :P

  11. #11
    Join Date
    Jun 2006
    Posts
    3,864
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    Nil is the actual 'command' if you like that SCAR uses . Though Null is just the same.
    They're not the same. Null is an empty variant, and nil is, I think, a null pointer. So, not really anything at all.

  12. #12
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,790
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    var
      DTMsLoaded : boolean;

    procedure LoadDTMs;
    begin
      if not DTMsLoaded then
      begin
        Lolwut := DTMFromString('78DA63E460626090616440060E1A720CFC401' +
           'A24FA1F0818B9816A2451D540646124906603AA9123A0860B538D' +
           '9F810AA63952F8CD010019D30604');
        DTMsLoaded := true;
      end;
    end;

    procedure ScriptTerminate;
    begin
      if DTMsLoaded then
      FreeDTM(Lolwut);
    end;

    In my scripts DTMs are declared as an array like DTMs[0], DTMs[1], etc. so that it will be easier to free so in my script terminate procedure I use a for i := 0 to High(DTMs) do FreeDTM(DTMs[i];

    Also is it possible to make a script not able to terminate?

    I know you can do this

    SCAR Code:
    procedure ScriptTerminate;
    var
      haha : boolean;
    begin
      while not haha do
    end;

    And, in theory, that would not allow it to end unless of course, haha is set to true...
    But is their a way that is uses less resources? Because that locked up my SCAR .

  13. #13
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    While Not haha Do
    Wait(1)


    So it doesn't check haha repeatedly?

    ~Sandstorm

  14. #14
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,790
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yea I just did that...
    That does work but it just locks up my SCAR. And you don't need to do wait(1) .

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Auto note seller.
    By jakeyboy29 in forum Outdated / Broken
    Replies: 7
    Last Post: 01-17-2009, 04:41 PM
  2. On a completely unrelated note...
    By Wrycu in forum Gaming
    Replies: 0
    Last Post: 10-10-2008, 07:17 PM
  3. Scriptterminate; closes smart and scar
    By Waddo in forum Scripting Help
    Replies: 8
    Last Post: 06-09-2008, 07:22 PM
  4. MahG's Note Seller
    By MahG in forum Outdated / Broken
    Replies: 14
    Last Post: 11-20-2007, 10:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •