Ar Map

From the Fallout3 GECK Wiki
Revision as of 07:46, 13 July 2014 by imported>Odessa (correction: float keys are permitted)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Description

Added by NVSE V4. Returns a "map" or "stringmap" array variable with the specified key::element pairs as its entries.

Up to 20 key::element pairs may be specified during creation, although more can be added using Let or alternative functions on subsequent lines.

All keys must be of the same type, either numeric (ints and floats can be mixed) or string, which will cause the function to return an array of the type "map" or "stringmap", respectively.

Array elements may be of any type in any combination. To assign the function return to a variable, the Let .. := .. command must be used, rather than 'set .. to ..'.

Syntax

(array) Ar_Map Key(int/float/string)::Value(multi) ...

Example

array_var aOutfit
ref rItem

let aOutfit := Ar_Map 2::ArmorLeather, 10::CowboyHat05, 5::WeapNV357Revolver

; I've created a "map" with those 3 key::element entries

let rItem := aOutfit[10] ; this ref now points to CowboyHat05

Identical style for a "stringmap":

array_var aContacts
ref rActor

let aContacts := Ar_Map "Nemesis"::EasyPeteREF, "Saviour"::DocMitchelREF, "Bestie"::SunnyREF

; I've created a "stringmap" with those 3 key::element entries

let rActor := aContacts["Nemesis"] ; rActor is my nemesis, EasyPeteREF

The next example illustrates a possible mistake- it is incorrect and will fail:

array_var aPartners

let aPartners := Ar_Map SunnyREF::EasyPeteREF, VeronicaREF::CraigBooneREF

; FAILURE- you can not use a ref as a key, it must be either a string or number. 
; Side note: NVSE4 adds ToNumber and ToString to convert types

let aPartners := Ar_Map "key"::SunnyREF, 45::VeronicaREF

; FAILURE- all keys must be the same type, either strings or numbers, not a combination of both

See Also