RicardoLew 10 Posted January 24, 2018 I want to make a simple script that gives me the position of each element of an array that i created. That's all i got so far, but taking the position of each object is not working for me. _array = []; _objs = player nearObjects ["Land_cargo40_blue_f", 30]; _array pushback _objs; I tried to make "getpos forEach _objs" but it didnt work. Maybe someone can help me? Thanks! Share this post Link to post Share on other sites
HazJ 1289 Posted January 24, 2018 { hintSilent format ["> %1 (%2)", _x, (_forEachIndex)]; } forEach _array; Depending on what you are doing, you may not need to store (pushBack) nearObjects to an array. { _objectPos = getPos _x; hintSilent format ["> %1 (%2)", _x, (_forEachIndex)]; systemChat format ["Object position: %1", _objectPos]; player setPos _objectPos; } forEach player nearObjects ["Land_cargo40_blue_f", 30]; None tested, it is very late (or early) here, need coffee... 2 Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted January 24, 2018 Got plenty of coffee flowing through my veins so here goes: 2 hours ago, RicardoLew said: _array = []; _objs = player nearObjects ["Land_cargo40_blue_f", 30]; _array pushback _objs; Use -showscripterrors start parameter and utilize the debug console, which is capable of monitoring certain variables and what they're holding. NearObjects returns an array, so all you're doing is pushing an array into an array. You can use apply to change the contents of an array, like this: _objs = player nearObjects ["Land_cargo40_blue_f", 30]; _positions = _objs apply {getpos _x}; Cheers 4 Share this post Link to post Share on other sites
RicardoLew 10 Posted January 24, 2018 Thanks for the help! I think some more practice is needed if i want to be good in this coding world! Share this post Link to post Share on other sites
pierremgi 4906 Posted January 25, 2018 or even _obs apply [_x, getpos _x]; so you can work with the couple (object,position). 1 Share this post Link to post Share on other sites