Difference between revisions of "Ar Map"

Jump to navigation Jump to search
91 bytes added ,  07:46, 13 July 2014
correction: float keys are permitted
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>
Anonymous user

Navigation menu