execFSM: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " +" to " ")
m (fixed parameters for hemtt)
 
(27 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| arma2
|game1= arma2
|1.00
|version1= 1.00


|game2= arma2oa
|game2= arma2oa
Line 15: Line 15:
|gr1= Program Flow
|gr1= Program Flow


| 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 <tt>_this</tt> variable inside FSM. Variables set inside FSMs can be read/modified externally, using [[setFSMVariable]] and [[getFSMVariable]] commands.<br>
|descr= 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 {{hl|_this}} variable inside FSM. Variables set inside FSMs can be read/modified externally, using [[setFSMVariable]] and [[getFSMVariable]] commands.<br>
<br>
<br>
The return value is the FSM handle; it can be used to determine (via [[completedFSM]]) when the FSM has finished.
The return value is the FSM handle; it can be used to determine (via [[completedFSM]]) when the FSM has finished.
{{Feature|arma3|In Arma 3, the FSM handle is also available within the FSM through the <tt>_thisFSM</tt> variable.}}
{{Feature|arma3|In Arma 3, the FSM handle is also available within the FSM through the {{hl|_thisFSM}} variable.}}
<br>
<br>
Scripted FSMs are added into the scheduler just like [[exec]] scripts, [[execVM]] scripts and [[spawn]] scripts.<br>
Scripted FSMs are added into the scheduler just like [[exec]] scripts, [[execVM]] scripts and [[spawn]] scripts.<br>
To see what FSMs are currently in the scheduler, use [[diag_activeMissionFSMs]] command.
To see what FSMs are currently in the scheduler, use [[diag_activeMissionFSMs]] command.
{{Feature|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 <tt>init</tt> and <tt>precondition</tt> (exception is the '''init state'''). This is the only place where scripted FSM is suspended/resumed.
{{Feature|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 {{hl|init}} and {{hl|precondition}} (exception is the '''init state'''). This is the only place where scripted FSM is suspended/resumed.
The usual difference between the state's <tt>init</tt> and <tt>precondition</tt> is 1 frame but if the scheduler is busy it can take longer. See [[FSM]] for more information about FSM's structure.}}
The usual difference between the state's {{hl|init}} and {{hl|precondition}} is 1 frame but if the scheduler is busy it can take longer. See [[FSM]] for more information about FSM's structure.}}


| arguments [[execFSM]] fsmFilePath
|s1= arguments [[execFSM]] fsmFilePath


|p1= arguments: [[Anything]] - Arguments accessible as <tt>_this</tt> in the FSM
|p1= arguments: [[Anything]] - arguments accessible as {{hl|_this}} in the FSM


|p2= fsmFilePath: [[String]] - file with FSM code
|p2= fsmFilePath: [[String]] - file with FSM code


| [[Number]] - FSM handle
|r1= [[Number]] - FSM handle (also available as {{hl|_thisFSM}} in the FSM)


|s2= [[execFSM]] fsmFilePath
|s2= [[execFSM]] fsmFilePath
Line 37: Line 37:
|p21= fsmFilePath: [[String]] - file with FSM code
|p21= fsmFilePath: [[String]] - file with FSM code


| r2= [[Number]] - FSM handle
|r2= [[Number]] - FSM handle (also available as {{hl|_thisFSM}} in the FSM)


|x1= <code>_id = [[player]] [[execFSM]] "test.fsm";</code>


|x2= <code>_handle = [_a, _b, _c] [[execFSM]] "test.fsm";</code>
|s3= arguments [[execFSM]] [fsmFilePath, allowTermination]
|s3since= arma3 2.18


|x3= <code>_handle = [[execFSM]] "test.fsm";</code>
|p41= arguments: [[Anything]] - arguments accessible as {{hl|_this}} in the FSM


|seealso= [[FSM]], [[FSM Editor Manual]], [[execVM]], [[call]], [[spawn]], [[exec]], [[commandFSM]], [[completedFSM]], [[doFSM]], [[getFSMVariable]], [[setFSMVariable]]
|p42= fsmFilePath: [[String]] - file with FSM code
|p43= allowTermination: [[Boolean]] - [[true]] to allow FSM termination with [[terminate]] command. Optional, default [[false]]
 
|r3= [[Number]] - FSM handle (also available as {{hl|_thisFSM}} in the FSM)
 
|s4= [[execFSM]] [fsmFilePath, allowTermination]
|s4since= arma3 2.18
 
|p61= fsmFilePath: [[String]] - file with FSM code
|p62= allowTermination: [[Boolean]] - [[true]] to allow FSM termination with [[terminate]] command. Optional, default [[false]]
 
|r4= [[Number]] - FSM handle (also available as {{hl|_thisFSM}} in the FSM)
 
|x1= <sqf>_id = player execFSM "test.fsm";</sqf>
 
|x2= <sqf>_handle = [_a, _b, _c] execFSM "test.fsm";</sqf>
 
|x3= <sqf>_handle = execFSM "test.fsm";</sqf>
 
|seealso= [[FSM]] [[FSM Editor Manual]] [[execVM]] [[call]] [[spawn]] [[exec]] [[commandFSM]] [[completedFSM]] [[doFSM]] [[getFSMVariable]] [[setFSMVariable]]
}}
}}
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}

Latest revision as of 16:49, 7 April 2024

Hover & click on the images for description

Description

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.
Arma 3
In Arma 3, the FSM handle is also available within the FSM through the _thisFSM variable.


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.

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 init and precondition (exception is the init state). This is the only place where scripted FSM is suspended/resumed. The usual difference between the state's init and precondition is 1 frame but if the scheduler is busy it can take longer. See FSM for more information about FSM's structure.
Groups:
Program Flow

Syntax 1

Syntax:
arguments execFSM fsmFilePath
Parameters:
arguments: Anything - arguments accessible as _this in the FSM
fsmFilePath: String - file with FSM code
Return Value:
Number - FSM handle (also available as _thisFSM in the FSM)

Syntax 2

Syntax:
execFSM fsmFilePath
Parameters:
fsmFilePath: String - file with FSM code
Return Value:
Number - FSM handle (also available as _thisFSM in the FSM)

Syntax 3

Syntax:
arguments execFSM [fsmFilePath, allowTermination]
Parameters:
arguments: Anything - arguments accessible as _this in the FSM
fsmFilePath: String - file with FSM code
allowTermination: Boolean - true to allow FSM termination with terminate command. Optional, default false
Return Value:
Number - FSM handle (also available as _thisFSM in the FSM)

Syntax 4

Syntax:
execFSM [fsmFilePath, allowTermination]
Parameters:
fsmFilePath: String - file with FSM code
allowTermination: Boolean - true to allow FSM termination with terminate command. Optional, default false
Return Value:
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";

Additional Information

See also:
FSM FSM Editor Manual execVM call spawn exec commandFSM completedFSM doFSM getFSMVariable setFSMVariable

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note