Attach an array to another array

Verse has built-in map data types which you use to define key value pairs. For example, if I wanted to map Ids to Players I could make:

# Create a map that holds an integer for every player variable
PlayersToID : [player]int = map{}

# If I wanted to acces a Player's ID
PrintPlayerID(Player : player) : void =
    # Here, we acces the id that corresponds to the player we passed in 
    # This ID gets assigned to PlayerID
    # Note that to access elements in a map, you must do so in an if expression
     if (PlayerID := PlayersToID[Player]):
          Print("Your player ID is {PlayerID}")

Now one important note is that you generally cannot create maps where the Key is a device, for example

# This throws an error, because devices are not comparable, and maps must
# have unique keys per entry,  which you must somehow be able to compare
SpawnersToCinematicsMap : [player_spawner_device]cinematic_sequence_device = map{}

1 Like