Description
Execute scripted FSM and return the FSM handle or 0 when failed. The FSM file is first searched in the mission folder, then in the campaign scripts folder and finally in the global scripts folder. Argument (if any) are available in _this variable inside FSM. Variables set inside FSMs can be read/modified externally, using setFSMVariable and getFSMVariable commands.
The return value is the FSM handle; it can be used to determine (via completedFSM) when the FSM has finished.
Note
Arma 3: In Arma 3, the FSM handle is also available within the FSM through the
_thisFSMvariable.
Scripted FSMs are added into the scheduler just like exec scripts, execVM scripts and spawn scripts.
To see what FSMs are currently in the scheduler, use diag_activeMissionFSMs command.
Important
While the code placed into any of the sections of FSM cannot be suspended (canSuspend is false), the FSM itself is suspended every simulation between the state's
initandprecondition(exception is the init state). This is the only place where scripted FSM is suspended/resumed. The usual difference between the state'sinitandpreconditionis 1 frame but if the scheduler is busy it can take longer. See FSM for more information about FSM's structure.
Syntax
Syntax 1
arguments execFSM fsmFilePath
Parameters:
arguments: Anything - arguments accessible as_thisin the FSMfsmFilePath: String - file with FSM code
Returns: Number - FSM handle (also available as _thisFSM in the FSM)
Syntax 2
execFSM fsmFilePath
Parameters:
fsmFilePath: String - file with FSM code
Returns: Number - FSM handle (also available as _thisFSM in the FSM)
Syntax 3
since arma3 2.18
arguments execFSM [fsmFilePath, allowTermination]
Parameters:
arguments: Anything - arguments accessible as_thisin the FSMfsmFilePath: String - file with FSM codeallowTermination: Boolean - true to allow FSM termination with terminate command. Optional, default false
Returns: Number - FSM handle (also available as _thisFSM in the FSM)
Syntax 4
since arma3 2.18
execFSM [fsmFilePath, allowTermination]
Parameters:
fsmFilePath: String - file with FSM codeallowTermination: Boolean - true to allow FSM termination with terminate command. Optional, default false
Returns: Number - FSM handle (also available as _thisFSM in the FSM)
Examples
Example 1
_id = player execFSM "test.fsm";
Example 2
_handle = [_a, _b, _c] execFSM "test.fsm";
Example 3
_handle = execFSM "test.fsm";
See also
FSM · FSM Editor Manual · execVM · call · spawn · exec · commandFSM · completedFSM · doFSM · getFSMVariable · setFSMVariable