set: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "\[\[Category:Scripting Commands OFP 1.[4-9]{2}(\|(\{\{uc:\{\{PAGENAME\}\}\}\}|#|[A-Z]+))?\]\] " to "") |
m (formatting) |
||
Line 1: | Line 1: | ||
{{RV|type=command | {{RV|type=command | ||
| | |game1= ofp | ||
|1.75 | |version1= 1.75 | ||
|game2= ofpe | |||
|version2= 1.00 | |||
|game3= arma1 | |||
|version3= 1.00 | |||
|game4= arma2 | |||
|version4= 1.00 | |||
|game5= arma2oa | |||
|version5= 1.51 | |||
|game6= tkoh | |||
|version6= 1.00 | |||
|game7= arma3 | |||
|version7= 0.50 | |||
|gr1= Arrays | |gr1= Arrays | ||
Line 9: | Line 33: | ||
|gr2= HashMap | |gr2= HashMap | ||
| Changes the element at the given | |descr= Changes the element at the given zero-based index of the [[Array|array]]. If the index is out of bounds, the array will [[resize]] to incorporate the index as its last value, padding with [[nil]] as necessary. See [[set#Examples| Example 4]]. | ||
If the index is out of bounds, the array will [[resize]] to incorporate the index as its last value, padding with [[nil]] as necessary. See [[set#Examples| Example 4]]. | |||
| array '''set''' [index, value] | |s1= array '''set''' [index, value] | ||
|p1= array: [[Array]] | |p1= array: [[Array]] | ||
| [[ | |p2= index: [[Number]] | ||
| s2= hashMap '''set''' [key, value] | |p3= value: [[Anything]] | ||
|r1= [[Nothing]] | |||
|s2= hashMap '''set''' [key, value] {{Since|arma3|2.02|y}} | |||
|p21= hashMap : [[HashMap]] | |p21= hashMap : [[HashMap]] | ||
|p22= key: [[HashMapKey]] | |p22= key: [[HashMapKey]] | ||
|p23= value: [[Anything]] | |p23= value: [[Anything]] | ||
|r2= [[Boolean]] - [[false]] if the key is new to the hashmap, [[true]] if a value got overwritten | |r2= [[Boolean]] - [[false|False]] if the key is new to the hashmap, [[true]] if a value got overwritten | ||
|x1= <code>_arrayOne [[set]] [0, "Hello"];</code> | |x1= <code>_arrayOne [[set]] [0, "Hello"];</code> | ||
Line 43: | Line 69: | ||
</code> | </code> | ||
| | |seealso= [[resize]] [[reverse]] [[select]] [[deleteAt]] [[deleteRange]] | ||
}} | }} | ||
Revision as of 11:16, 27 March 2021
Description
- Description:
- Changes the element at the given zero-based index of the array. If the index is out of bounds, the array will resize to incorporate the index as its last value, padding with nil as necessary. See Example 4.
- Groups:
- ArraysHashMap
Syntax
- Syntax:
- array set [index, value]
- Parameters:
- array: Array
- index: Number
- value: Anything
- Return Value:
- Nothing
Alternative Syntax
- Syntax:
- hashMap set [key, value] Template:Since
- Parameters:
- hashMap : HashMap
- key: HashMapKey
- value: Anything
- Return Value:
- Boolean - False if the key is new to the hashmap, true if a value got overwritten
Examples
- Example 1:
_arrayOne set [0, "Hello"];
- Example 2:
- Append "Bye" as last element to _arrayTwo:
_arrayTwo set [count _arrayTwo, "Bye"];
- Example 3:
- Replace the last element of _arrayThree with 23:
_arrayThree set [(count _arrayThree) - 1, 23];
- Example 4:
- Using set with an index that is out of bounds:
_array = ["A"]; _array set [2, "C"]; // _array is now ["A", nil, "C"] _array set [1, "B"]; // _array is now ["A", "B", "C"]
Additional Information
- See also:
- resize reverse select deleteAt deleteRange
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Categories:
- Scripting Commands
- Introduced with Operation Flashpoint version 1.75
- Operation Flashpoint: New Scripting Commands
- Operation Flashpoint: Scripting Commands
- Operation Flashpoint: Elite: Scripting Commands
- ArmA: Armed Assault: Scripting Commands
- Arma 2: Scripting Commands
- Arma 2: Operation Arrowhead: Scripting Commands
- Take On Helicopters: Scripting Commands
- Arma 3: Scripting Commands
- Command Group: Arrays
- Command Group: HashMap