Get Map Value Icon Get Map Value

With this action you can retrieve the value associated with a given key in a map data structure. You supply the variable that holds the map index (as returned by the action Create Map) and then give a "key" (which is the identifier within the map for a value), and also supply a target variable to hold the returned value (which can be flagged as a temporary local variable).

NOTE If you give a key that does not exist in the map then the action will return undefined. You can check for this this using the If Undefined action.

 

Action Syntax:

Get Map Value Action

Arguments:

ArgumentDescription
MapThe index (stored in a variable) of the map to get the value from
KeyThe key to get (real or string)
TargetThe target variable to hold the returned map value

 

Example:

Get Map Value ExampleThe above action block code checks for a collision at the instance position and if one is found then a map is looked up to get a value from the key "damage", and this value is then used to change the calling instance variable "hp".