OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Luke on 23 Jul 2008, 01:43:04
-
Hey all,
I was wondering if it was possible if you could get the select # of an array, like:
_array=[_array] + [_thing1]
_array=[_array] + [_thing2]
_array=[_array] + [_thing3]
_thing2 ""command"" _array returns "select 1"
Let me know if/when you find something.
Luke
-
I dont understand your question, much less your example, anyway might be this is what you are looking for:
_array = [];
_array=_array + [_thing1];
_array=_array + [_thing2];
_array=_array + [_thing3];
// (_array select 1) is _thing2
-
Quite possibly.
Very specifically, what i am looking for is a function/command, that if I provide a name and an array, this command will tell me what select number the name is in the array.
Luke
-
So you want a command like the php function array_search (http://www.php.net/manual/en/function.array-search.php).
Searches the array for a given value and returns the corresponding key if successful.
EDIT: see attached files.
-
Umm.
There is actually already a function for that, nicely named find (http://community.bistudio.com/wiki/find). ;) I won't link to the COMREF one since the example is wrong, but basically:
_name = "Doodle";
_array = ["Doodle", 146, lollerskates];
_nr = _array find _name;
hint format ["%1 is number %2 in the array %3", _name, _nr, _array];
Should do it :)
Wolfrug out.
-
Thought that there was such a function, but couldn't find it in the COMREF :whistle:
-
If it is a matter of looking for a value inside an array:
_array = ["A", "B", "C"];
_index = _array find "C";
// _index = 2
_array = ["A", "B", "C"];
_index = _array find "H";
// _index = -1
-
Mando,
This (http://ca.youtube.com/watch?v=Up3TIPoVh-M&feature=related) is for you!! :D
Thanx a LOT. :)
Luke