Skip to content

Save Value

Save Value

Saves engine-specific data from a Data Source into a Variable or Switch, connecting runtime engine data to your own data layer.

Source

Name Explanation
Data Source The Data Source to save from.

Targets

Name Explanation
Global / Local Targets a single Variable.
Global / Local Range Targets multiple contiguous Variables.
Global / Local Reference Targets a single Variable based on a Variable index.

Examples

Save Party Active Member Count to Global Variable 0

This retrieves the active member count from the Party data source and saves it into Global Variable 0.

$gv[0] = save_value(party, active_member_count);
{"Data":{"IsSwitch":0,"Source":{"$":"PartyDataSource","ParameterIndex":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":null,"VariableIndex":0,"Metadata":null},"PartyProperty":0,"Metadata":null},"Index":0,"IndexEnd":null,"IsLocal":0,"IsOperandReference":0,"IsReference":0,"OperandGlobalIndex":null,"OperandLocalIndex":null,"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Data.SaveValueCommand"}

Save Party Member Unique ID, Based on Global Variable 1, to Global Variable 0

This retrieves the Unique ID of a party member at a position specified by Global Variable 1, from all members in the Party data source, and saves it into Global Variable 0.

$gv[0] = save_value(party, member_unique_id, $gv[1]);
{"Data":{"IsSwitch":0,"Source":{"$":"PartyDataSource","ParameterIndex":{"IsGlobalVariable":true,"IsLocalVariable":false,"IsValue":false,"Value":null,"VariableIndex":1,"Metadata":null},"PartyProperty":12,"Metadata":null},"Index":0,"IndexEnd":null,"IsLocal":0,"IsOperandReference":0,"IsReference":0,"OperandGlobalIndex":null,"OperandLocalIndex":null,"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Data.SaveValueCommand"}

Save Inventory Slot Usability Flag to Global Switch 0, Based on Global Variable 5

This checks whether an item is usable in the menu, from an inventory slot identified by the Unique ID stored in Global Variable 5, and saves the result into Global Switch 0.

$gs[0] = save_value(inventory_slot, $gv[5], is_useable_in_menu);
{"Data":{"IsSwitch":1,"Source":{"$":"InventorySlotDataSource","ParameterIndex":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":null,"VariableIndex":0,"Metadata":null},"InventorySlotFlag":0,"InventorySlotProperty":0,"IsLocal":0,"SourceIndex":5,"Metadata":null},"Index":0,"IndexEnd":null,"IsLocal":0,"IsOperandReference":0,"IsReference":0,"OperandGlobalIndex":null,"OperandLocalIndex":null,"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Data.SaveValueCommand"}