Difference between revisions of "execFSM"

From Bohemia Interactive Community
Jump to navigation Jump to search
m
(Moving FSM structure info to FSM page)
Line 1: Line 1:
{{Command|= Comments
+
{{Command|Comments=
 
____________________________________________________________________________________________
 
____________________________________________________________________________________________
  
| arma2 |= Game name
+
| arma2 |Game name=
  
|1.00|= Game version
+
|1.00|Game version=
 
____________________________________________________________________________________________
 
____________________________________________________________________________________________
  
| 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>
+
| 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>
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:
+
<br>
* State: <tt>init</tt>-><tt>precondition</tt>
+
The return value is the FSM handle; it can be used to determine (via [[completedFSM]]) when the FSM has finished.
* Conditional link (condition is [[true]]): <tt>precondition</tt>-><tt>condition</tt>-><tt>action</tt>
+
{{Feature arma3|In Arma 3, the FSM handle is also available within the FSM through the <tt>_thisFSM</tt> variable.}}
* Conditional link (condition is [[false]]): <tt>precondition</tt>-><tt>condition</tt>
+
<br>
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 the state's <tt>init</tt> and <tt>precondition</tt> (exception is the '''init state'''). Normally the 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. This is the only place where scripted FSM is suspended/resumed.<br><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|= Description
+
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 <tt>init</tt> and <tt>precondition</tt> (exception is the '''init state''').
 +
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.
 +
This is the only place where scripted FSM is suspended/resumed.}} |Description=
 
____________________________________________________________________________________________
 
____________________________________________________________________________________________
  
| arguments '''execFSM''' filename |= Syntax
+
| arguments [[execFSM]] fsmFilePath |Syntax=
  
|p1= arguments: [[Anything]] - Arguments accessible as <tt>_this</tt> in the FSM|= Parameter 1
+
|p1= arguments: [[Anything]] - Arguments accessible as <tt>_this</tt> in the FSM |Parameter 1=
  
|p2= filename: [[String]] - file with FSM code |= Parameter 2
+
|p2= fsmFilePath: [[String]] - file with FSM code |Parameter 2=
  
| [[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
+
| [[Number]] - FSM handle |Return value=
  
 +
|s2= [[execFSM]] fsmFilePath |Syntax 2=
  
|s2= '''execFSM''' filename |= Syntax
+
|p21= fsmFilePath: [[String]] - file with FSM code |Parameter 21=
  
|p21= filename: [[String]] - file with FSM code [[String]] |= Parameter 2
+
| r2= [[Number]] - FSM handle |Return value 2=
 
 
| 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
 
 
____________________________________________________________________________________________
 
____________________________________________________________________________________________
  
|x1= <code>_id = [[player]] [[execFSM]] "test.fsm";</code>|= EXAMPLE1
+
|x1= <code>_id = [[player]] [[execFSM]] "test.fsm";</code> |EXAMPLE1=
  
|x2= <code>_handle = [_a, _b, _c] [[execFSM]] "test.fsm";</code>|= EXAMPLE2
+
|x2= <code>_handle = [_a, _b, _c] [[execFSM]] "test.fsm";</code> |EXAMPLE2=
  
|x3= <code>_handle = [[execFSM]] "test.fsm";</code>|= EXAMPLE3
+
|x3= <code>_handle = [[execFSM]] "test.fsm";</code> |EXAMPLE3=
 
____________________________________________________________________________________________
 
____________________________________________________________________________________________
  
| [[FSM]], [[FSM Editor Manual]], [[execVM]], [[call]], [[spawn]], [[exec]], [[commandFSM]], [[completedFSM]], [[doFSM]], [[getFSMVariable]], [[setFSMVariable]] |= SEEALSO  
+
| [[FSM]], [[FSM Editor Manual]], [[execVM]], [[call]], [[spawn]], [[exec]], [[commandFSM]], [[completedFSM]], [[doFSM]], [[getFSMVariable]], [[setFSMVariable]] |SEEALSO=
 
 
|  |= MPBEHAVIOUR
 
____________________________________________________________________________________________
 
 
}}
 
}}
  
Line 55: Line 54:
 
[[Category:ArmA 2: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
 
[[Category:ArmA 2: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
 +
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
 
 
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Revision as of 13:39, 29 March 2019

Template:Command

Notes

Bottom Section