Difference between revisions of "execFSM"

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\| *((\[\[[a-zA-Z0-9_ |()]+\]\],? ?)+) * \}\}" to "|seealso= $1 }}")
(40 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Command|= Comments
+
{{RV|type=command
____________________________________________________________________________________________
 
  
| arma2 |= Game name
+
| arma2
  
|1.00|= Game version
+
|1.00
____________________________________________________________________________________________
 
  
| Execute the scripted FSM. The FSM file is first searched in the mission folder, then in the campaign scripts folder and finally in the global scripts folder.
+
|gr1= Program Flow
Returns the FSM handler or 0 when failed. |= Description
 
____________________________________________________________________________________________
 
  
| '''execFSM''' filename |= Syntax
+
| 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.}}
  
|p1= filename:  -  |= PARAMETER1
+
| arguments [[execFSM]] fsmFilePath
  
|p2= |= PARAMETER2
+
|p1= arguments: [[Anything]] - Arguments accessible as <tt>_this</tt> in the FSM
  
|p3= |= PARAMETER3
+
|p2= fsmFilePath: [[String]] - file with FSM code
  
| [[Number]] |= RETURNVALUE
+
| [[Number]] - FSM handle
  
 +
|s2= [[execFSM]] fsmFilePath
  
|x1= <pre>execFSM "test.fsm";</pre>|= EXAMPLE1
+
|p21= fsmFilePath: [[String]] - file with FSM code
  
____________________________________________________________________________________________
+
| r2= [[Number]] - FSM handle
  
| [[FSM]], [[FSM_Editor_Manual]], [[commandFSM]], [[completedFSM]], [[doFSM]], [[getFSMVariable]], [[setFSMVariable]] |= SEEALSO
+
|x1= <code>_id = [[player]] [[execFSM]] "test.fsm";</code>
  
| |= MPBEHAVIOUR
+
|x2= <code>_handle = [_a, _b, _c] [[execFSM]] "test.fsm";</code>
____________________________________________________________________________________________
+
 
 +
|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>
+
{{GameCategory|arma2|Scripting Commands}}
[[Category:ArmA 2: New Scripting Commands List|{{uc:{{PAGENAME}}}}]]
+
{{GameCategory|tkoh|Scripting Commands}}
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
+
{{GameCategory|arma3|Scripting Commands}}
 
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
 
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Revision as of 00:42, 17 February 2021

Hover & click on the images for description

Description

Description:
Description needed
Groups:
Program Flow

Syntax

Syntax:
Syntax needed
Parameters:
arguments: Anything - Arguments accessible as _this in the FSM
fsmFilePath: String - file with FSM code
Return Value:
Return value needed

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