Difference between revisions of "execFSM"

From Bohemia Interactive Community
Jump to navigation Jump to search
m
m (Text replacement - " \| *(game[0-9]|version[0-9]|gr[0-9]|serverExec|mp|pr|descr|s[0-9]|p[0-9]{1,3}|r[0-9]|x1?[0-9]|seealso) *= +" to " |$1= ")
 
(32 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|= Comments
+
{{RV|type=command
____________________________________________________________________________________________
 
  
| arma2 |= Game name
+
|game1= arma2
 +
|version1= 1.00
  
|1.00|= Game version
+
|game2= arma2oa
____________________________________________________________________________________________
+
|version2= 1.50
  
| Executes scripted [[FSM]] and returns 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. In Arma 3 FSM handle is also available in <tt>_thisFSM</tt> variable. Variables set inside FSMs can be read/modified externally, using [[setFSMVariable]] and [[getFSMVariable]] commands.<br><br>
+
|game3= tkoh
The scripted FSM structure normally consists of one '''init state''', one or more '''conditional links''', one or more '''normal states''' and one or more '''final states'''. Each state has <tt>init</tt> and <tt>precondition</tt> section, while each conditional link has <tt>precondition</tt>, <tt>condition</tt> and <tt>action</tt> sections. The order of execution is:
+
|version3= 1.00
* State: <tt>init</tt>-><tt>precondition</tt>
 
* Conditional link (condition is [[true]]): <tt>precondition</tt>-><tt>condition</tt>-><tt>action</tt>
 
* Conditional link (condition is [[false]]): <tt>precondition</tt>-><tt>condition</tt>
 
Scripted FSMs are added into the scheduler just like [[exec]] scripts, [[execVM]] scripts and [[spawn]] scripts. 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 state's <tt>init</tt> and state's <tt>precondition</tt> (exception is the '''init state'''). Normally the difference between state's <tt>init</tt> and <tt>precondition</tt> is 1 frame but if the scheduler is busy it can take longer. This is the only place where scripted FSM is suspended/resumed.<br><br>
 
To see what FSMs are currently in the scheduler, use [[diag_activeMissionFSMs]] command|= Description
 
____________________________________________________________________________________________
 
  
| arguments '''execFSM''' filename |= Syntax
+
|game4= arma3
 +
|version4= 0.50
  
|p1= arguments: [[Anything]] - Arguments accessible as <tt>_this</tt> in the FSM|= Parameter 1
+
|gr1= Program Flow
  
|p2= filename: [[String]] - file with FSM code |= Parameter 2
+
|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 <tt>_this</tt> variable inside FSM. Variables set inside FSMs can be read/modified externally, using [[setFSMVariable]] and [[getFSMVariable]] commands.<br>
 +
<br>
 +
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.}}
 +
<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.
 +
{{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.
 +
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.}}
  
| [[Number]] - FSM handle, can be used to determine (via [[completedFSM]]) when the execed FSM has finished. In Arma 3, the handle is also available inside the FSM in <tt>_thisFSM</tt> variable. |= Return value
+
|s1= arguments [[execFSM]] fsmFilePath
  
 +
|p1= arguments: [[Anything]] - Arguments accessible as <tt>_this</tt> in the FSM
  
|s2= '''execFSM''' filename |= Syntax
+
|p2= fsmFilePath: [[String]] - file with FSM code
  
|p21= filename: [[String]] - file with FSM code [[String]] |= Parameter 2
+
|r1= [[Number]] - FSM handle
  
| r2= [[Number]] - FSM handle, can be used to determine (via [[completedFSM]]) when the execed FSM has finished. In Arma 3, the handle is also available inside the FSM in <tt>_thisFSM</tt> variable. |= Return value
+
|s2= [[execFSM]] fsmFilePath
____________________________________________________________________________________________
 
  
|x1= <code>_id = [[player]] [[execFSM]] "test.fsm";</code>|= EXAMPLE1
+
|p21= fsmFilePath: [[String]] - file with FSM code
  
|x2= <code>_handle = [_a, _b, _c] [[execFSM]] "test.fsm";</code>|= EXAMPLE2
+
|r2= [[Number]] - FSM handle
  
|x3= <code>_handle = [[execFSM]] "test.fsm";</code>|= EXAMPLE3
+
|x1= <code>_id = [[player]] [[execFSM]] "test.fsm";</code>
____________________________________________________________________________________________
 
  
| [[FSM]], [[FSM Editor Manual]], [[execVM]], [[call]], [[spawn]], [[exec]], [[commandFSM]], [[completedFSM]], [[doFSM]], [[getFSMVariable]], [[setFSMVariable]] |= SEEALSO
+
|x2= <code>_handle = [_a, _b, _c] [[execFSM]] "test.fsm";</code>
  
| |= MPBEHAVIOUR
+
|x3= <code>_handle = [[execFSM]] "test.fsm";</code>
____________________________________________________________________________________________
+
 
 +
|seealso= [[FSM]], [[FSM Editor Manual]], [[execVM]], [[call]], [[spawn]], [[exec]], [[commandFSM]], [[completedFSM]], [[doFSM]], [[getFSMVariable]], [[setFSMVariable]]
 
}}
 
}}
 
<h3 style='display:none'>Notes</h3>
 
<dl class='command_description'>
 
<!-- Note Section BEGIN -->
 
 
<!-- Note Section END -->
 
</dl>
 
 
<h3 style='display:none'>Bottom Section</h3>
 
[[Category:ArmA 2: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
 

Latest revision as of 23:02, 19 June 2021

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

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

Alternative Syntax

Syntax:
execFSM fsmFilePath
Parameters:
fsmFilePath: String - file with FSM code
Return Value:
Number - FSM handle

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:
FSMFSM Editor ManualexecVMcallspawnexeccommandFSMcompletedFSMdoFSMgetFSMVariablesetFSMVariable

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