MSFS Mission Script - Calculator: Difference between revisions
(Created page for msfs script calculator) |
(Add explanation for calculator) |
||
| Line 21: | Line 21: | ||
| XP9 = false | | XP9 = false | ||
}} | }} | ||
You can use calculators for more advanced logic in your mission. It can take in multiple variables and trigger different actions based on a logic. You can also use this to calculate a mission score and probably many more applications which you can think of. | |||
{{:Transclusion_MSFS_Mission_Script}} | {{:Transclusion_MSFS_Mission_Script}} | ||
== Calculator object == | |||
A calculator has four main parts: | |||
{|class='wikitable' | |||
!CalculatorFormula | |||
|CalculatorFormulas are the most important part of the calculator. They are written in [[Reverse Polish Notation]] and can be used as a ''condition'' (same as in a [[Property_Trigger|PropertyTrigger]]) or as an ''action'' (same as in a [[Execute_RPN_Action|ExecuteRPNAction]]) or both at the same time. | |||
|- | |||
!CalculatorValue | |||
|A calculator has a ''CalculatorValue'' that can be used by [[Reverse_Polish_Notation#Mission_Script_Elements_that_use_RPN|objects that use RPN]]. This value is determined by the main ''CalculatorFormula'', ''StartValue'', ''OnActivatedValue'', and ''OnDeactivatedValue''. | |||
|- | |||
!CalculatorParameters | |||
|A calculator can have ''parameters'', which are ''Calculator Variables'' that can be used in ''CalculatorFormulas''. See: [[#List_of_parameter_types|the list of parameter types]]. | |||
|- | |||
!CalculatorActions | |||
|A calculator can have associated actions that execute when the calculator is activated, deactivated, or when a condition has been met. | |||
|} | |||
== Calculator parameters / variables == | |||
You can create a ''Calculator Variable'' by adding a ''CalculatorParameter'' to a calculator. In ''NameInFormula'' you give the variable a name. You can later reference the ''Calculator Variable'' using <code>(X:VariableName)</code> or <code>[VariableName]</code>. | |||
=== List of parameter types === | |||
{|class='wikitable' | |||
!ReferenceParameter | |||
|You can use another Calculator's ''CalculatorValue'' as a parameter. | |||
|- | |||
!FormulaParameter | |||
|You can use [[Reverse_Polish_Notation|RPN]] code as a reference. Which means you can use [https://docs.flightsimulator.com/html/Additional_Information/Reverse_Polish_Notation.htm#Types all variables] such as ''SimVars'' and ''Calculator Variables''. | |||
|- | |||
!InputParameter | |||
|You can use a user input as a parameter. | |||
|- | |||
!RunwayParameter | |||
|You can add data relating to runways as a parameter. | |||
|- | |||
!PathParameter | |||
|You can add data relating to paths as a parameter. | |||
|- | |||
!MouseParameter | |||
|You can add the position of the mouse as a parameter. | |||
|- | |||
!RacerParameter | |||
|You can add data relating to players in a race as a parameter. | |||
|} | |||
can | == Calculator Actions == | ||
{|class='wikitable' | |||
!DeactivateAfterExecution | |||
|Deactivate the entire calculator after execution. | |||
|- | |||
!CalculatorFormula | |||
|If this formula is true, the actions will execute. | |||
|- | |||
!NameInFormula | |||
|This ''CalculatorFormula'' can also be referenced. | |||
|- | |||
!StartValue | |||
|Starting value of the CalculatorFormula. | |||
|- | |||
!On(De)ActivatedValue | |||
|What the value will change to when the calculator is activated. | |||
|- | |||
!OnActionCompleteFormula | |||
|Formula to execute when all the actions have finished. | |||
|- | |||
!Actions | |||
|Actions that execute when the CalculatorFormula is true. | |||
|} | |||
Notes: | |||
when a CalculatorFormula uses its own parameter, it will stay a variable | |||
what is (X:dtime), time between calls of calculator? | |||
What if NameInFormula creates duplicate names? | |||
(X:) or [] difference? | |||
{{Template:Navbox-Mission-Creation-MSFS}} | {{Template:Navbox-Mission-Creation-MSFS}} | ||
Revision as of 17:30, 11 December 2021
| This page is a work-in-progress. Generic message - Please note some detail may possibly be missing or incorrect. |
| Applicable |
|---|
| MSFS |
| MS Flight |
| LM P3D5 |
| LM P3D4 |
| LM P3D3 |
| LM P3D2 |
| LM P3D |
| FS World |
| FSXSE |
| FSXA |
| FSX |
| FS2004 |
| FS2002 |
| XP11 |
| XP10 |
| XP9 |
You can use calculators for more advanced logic in your mission. It can take in multiple variables and trigger different actions based on a logic. You can also use this to calculate a mission score and probably many more applications which you can think of. See MSFS Mission Script for general information about creating a mission script.
Calculator object
A calculator has four main parts:
| CalculatorFormula | CalculatorFormulas are the most important part of the calculator. They are written in Reverse Polish Notation and can be used as a condition (same as in a PropertyTrigger) or as an action (same as in a ExecuteRPNAction) or both at the same time. |
|---|---|
| CalculatorValue | A calculator has a CalculatorValue that can be used by objects that use RPN. This value is determined by the main CalculatorFormula, StartValue, OnActivatedValue, and OnDeactivatedValue. |
| CalculatorParameters | A calculator can have parameters, which are Calculator Variables that can be used in CalculatorFormulas. See: the list of parameter types. |
| CalculatorActions | A calculator can have associated actions that execute when the calculator is activated, deactivated, or when a condition has been met. |
Calculator parameters / variables
You can create a Calculator Variable by adding a CalculatorParameter to a calculator. In NameInFormula you give the variable a name. You can later reference the Calculator Variable using (X:VariableName) or [VariableName].
List of parameter types
| ReferenceParameter | You can use another Calculator's CalculatorValue as a parameter. |
|---|---|
| FormulaParameter | You can use RPN code as a reference. Which means you can use all variables such as SimVars and Calculator Variables. |
| InputParameter | You can use a user input as a parameter. |
| RunwayParameter | You can add data relating to runways as a parameter. |
| PathParameter | You can add data relating to paths as a parameter. |
| MouseParameter | You can add the position of the mouse as a parameter. |
| RacerParameter | You can add data relating to players in a race as a parameter. |
Calculator Actions
| DeactivateAfterExecution | Deactivate the entire calculator after execution. |
|---|---|
| CalculatorFormula | If this formula is true, the actions will execute. |
| NameInFormula | This CalculatorFormula can also be referenced. |
| StartValue | Starting value of the CalculatorFormula. |
| On(De)ActivatedValue | What the value will change to when the calculator is activated. |
| OnActionCompleteFormula | Formula to execute when all the actions have finished. |
| Actions | Actions that execute when the CalculatorFormula is true. |
Notes:
when a CalculatorFormula uses its own parameter, it will stay a variable
what is (X:dtime), time between calls of calculator?
What if NameInFormula creates duplicate names?
(X:) or [] difference?
- Flightplan
- Weather definitions
- Flight file
- Mission script
- Triggers
- Actions
- ObjectActivationAction · DialogAction · AdjustPayloadAction · ChangeAssistanceItemAction · FadeToColorAction · RandomAction · RequestTeleportAction · CountAction · ResetTimerAction · TimerAdjustAction · GoalResolutionAction & SubGoalResolutionAction · GrantRewardAction · PointOfInterestActivationAction · ActivateWaypointsAction · AITakeControlsAction · SendMessageToAIAction
- Mission objects
- Calculator
- Flow states
- Events
- Areas
- Library objects
- Sim objects
- RTC