Difference between revisions of "Ar Map"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Odessa
(Created page with "==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 specifi...")
 
imported>Odessa
(correction: float keys are permitted)
 
Line 2: Line 2:
Added by NVSE V4. Returns a "map" or "stringmap" array variable with the specified key::element pairs as its entries.  
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 specified during creation, although more can be added using alternative functions on subsequent lines.
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 int or string, which will cause the function to return an array of the type "map" or "stringmap", respectively.
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'.  
Array elements may be of any type in any combination. To assign the function return to a variable, the <b>Let .. := ..</b> command must be used, rather than '<b>set .. to ..</b>'.  


==Syntax==
==Syntax==
<pre>
<pre>
(array) Ar_Map Key(int-or-str)::Value(multi) ...
(array) Ar_Map Key(int/float/string)::Value(multi) ...
</pre>
</pre>
==Example==
==Example==
Line 42: Line 42:
let aPartners := Ar_Map SunnyREF::EasyPeteREF, VeronicaREF::CraigBooneREF
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 int.  
; 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
; Side note: NVSE4 adds ToNumber and ToString to convert types


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


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


</pre>
</pre>

Latest revision as of 08:46, 13 July 2014

Description[edit | edit source]

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[edit | edit source]

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

Example[edit | edit source]

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[edit | edit source]