obrien979 4 Posted December 29, 2017 I am looking for a way to assign an increasing number (1,2,3,4,5,etc.) to objects that are created via script. I understand how the createVehicle script works and I have gotten that to work flawlessly. I want to expand on that and when the script runs it assigns the object a number and then the next one create has the next number in order. Currently t his is how I am creating the objects: _pad1=createVehicle ["Land_HelipadEmpty_F",position player getPos [50,360],[],0,"None"]; I repeat this for every pole I am creating at the given distance and direction ([50,360]). So instead of using _pad1, then _pad2, etc.. can I use an increasing value ran by the script there? Ultimately I want the poles to be named 1,2,3,4,etc so that I can then order a unit to move to that number in another script, but that script will also need to after the number after _pad# increase in number. Right now this is what I got: _veh = cursorTarget; wpt = group _veh addWaypoint [getPos _pad1,0]; I would like the _pad1 to just be the next pad # in order of the ones created. I really hope that I explained this well. Share this post Link to post Share on other sites
nomisum 129 Posted December 29, 2017 you could store your created objects in an array, thus you can just iterate the array and no numbers are needed at all (in a way the array indexes are actually your numbers if you want to access specific entries later on). Share this post Link to post Share on other sites
AZCoder 921 Posted December 29, 2017 Basically what nomisum said: _padList = []; _pad = createVehicle ["Land_HelipadEmpty_F",position player getPos [50,360],[],0,"None"]; _padList pushBack _pad; If created in order, you can easily iterate through the padlist for each waypoint. Share this post Link to post Share on other sites
obrien979 4 Posted December 29, 2017 Will this automatic name them pad1, pad2,etc..? Share this post Link to post Share on other sites
Grumpy Old Man 3547 Posted December 29, 2017 1 hour ago, obrien979 said: Will this automatic name them pad1, pad2,etc..? No, if you need to access them from another script you could name them globally, like this: //define global array somewhere in init.sqf or similar MyPads = []; //spawn pad _tempPad = createVehicle ["Land_HelipadEmpty_F",position player getPos [50,360],[],0,"None"]; //name it ascending from 0 and handle global array _tempName = format ["Pad%1",count MyPads]; missionNamespace setVariable [_tempName,_tempPad]; MyPads pushBack _tempName; //debug ["Pad0","Pad1","Pad2"] etc systemchat str mypads; There are probably more elegant solutions to this, depending on how you want to integrate it, but this should do the trick. Cheers 1 Share this post Link to post Share on other sites
obrien979 4 Posted December 29, 2017 Thank You for all the great suggestions, I am going to try these out later tonight. Share this post Link to post Share on other sites
obrien979 4 Posted December 29, 2017 How could I modify this to have them created at set distances (increased by 25m each time) out to a final known distance? Share this post Link to post Share on other sites
HallyG 239 Posted December 30, 2017 You could achieve that by putting the code above into a for-loop which will run for a set amount of iterations. The number of iterations will depend on the distance between the start and end positions as well as the desired separation between each helipad. This can be calculated using the following: _distance = vectorMagnitude ( _finalPos vectorDiff _startPos ); _objsToCreate = floor ( _distance / _separation ); The _startPos and _endPos could be created, for example, using: _startPos = position player; _maxDistance = 300; _angle = getDir player; _finalPos = _startPos getPos [ _maxDistance, _angle ]; Share this post Link to post Share on other sites