Welcome to the Iron Front Fan Forums!
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
Terry

Private
Registered:
Posts: 14
Reply with quote  #1 
Was wondering on how to stop a running script when entering a trigger for instance?

Example:

When using the AI artillery script,the shelling is non-stop.
But what commands the script to stop shelling and resume a normal stance??

I have heard of both "terminate" and "exit",but does not seem to get it right...
0
Rydygier

Avatar / Picture

IFR Team
Registered:
Posts: 179
Reply with quote  #2 
Depends, how yours script is designed. In general reasonably placed exitWith can give you exit current loop/scope under condition, you set, when code reach that line. Waituntil can give you conditional pause/wait for condition fulfillment. Terminate however IMHO is best for reliable, permanent terminating the script on demand at any moment, as long you have script handle(s), just like in example from linked BIKI page.

Anyway - code must be properly prepared/designed for such action, unless will not spawn/execVM additional scripts from within, and you have access to its main handle (_mainHandle = [] execVM "TheScript.sqf"; ) - then you can use _mainHandle with terminate command. Details depends on the script and its task.
0
kju

RM Team
Registered:
Posts: 388
Reply with quote  #3 
Terminate leaves the script in an uncertain state. ExitWith/exit condition is the proper design.
0
Rydygier

Avatar / Picture

IFR Team
Registered:
Posts: 179
Reply with quote  #4 
Quote:
Terminate leaves the script in an uncertain state.


Could you elaborate this a bit? What exactly that means (what consequences) and why to avoid that? In fact I used it only in one small project, and all looked fine. Perhaps something bad happened behind the scenes then, no visible problems spotted though.
0
kju

RM Team
Registered:
Posts: 388
Reply with quote  #5 
_handle = 
{
 while {true} do
 {
  //do stuff A
  //do stuff B
  //do stuff C
 };
};

sleep (random 1);

terminate _handle;


With terminate you could leave after either operation, while you may want to have it finish all three before existing.
0
Rydygier

Avatar / Picture

IFR Team
Registered:
Posts: 179
Reply with quote  #6 
Ah yes, now it is clear, thanks. In my case this wasn't a problem. So, we could say, that terminate can be used with caution & consideration, taking into account logical consequences of breaking code in the middle of any of its calculations, so eg not recommended for scripts of unknown design due to unpredictable side effects.
0
Terry

Private
Registered:
Posts: 14
Reply with quote  #7 
The terminate command does not work in my case,does it matter that the script is an sqs type,not an sqf? and the execution command I use is exec,not execVm.

Cant seem to be able to name the script either....this one i am struggeling With!

This is in the trigger activation line: [art1,"Target1",5000,300,2] exec "D30fire.sqs";
0
Rydygier

Avatar / Picture

IFR Team
Registered:
Posts: 179
Reply with quote  #8 
Exec apparently doesn't returning the script handle needed in terminate command syntax. Perhaps just write in sqf, not sqs?
0
Terry

Private
Registered:
Posts: 14
Reply with quote  #9 

Can I just rename the script to an sqf file type??

0
Rydygier

Avatar / Picture

IFR Team
Registered:
Posts: 179
Reply with quote  #10 
Most probably no. Syntax is different, although teoretically is possible very simple code, that will work as sqs and sqf, usually isn't. Maybe show this code, perhaps is easy to transform it into sqf...
0
kju

RM Team
Registered:
Posts: 388
Reply with quote  #11 
http://community.bistudio.com/wiki/ArmA:_Introduction_to_Scripting
http://community.bistudio.com/wiki/SQS_to_SQF_conversion
http://community.bistudio.com/wiki/SQS_syntax
http://community.bistudio.com/wiki/SQF_syntax
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.