Jump to content
Sign in to follow this  
charliereddog

Lost my ofp knowledge! Help with scripting simple random location

Recommended Posts

Hi all,

I *KNOW* I solved this way back in OFP but I've long since lost the mission files and I can't hit my head against a wall forever again.

I'm trying to do a simple thing. I have 6 game logics on the map. I want to move a marker to one of those logics. That's all. I have

_myLocation = ceil(random 6);

to determine which of the logics to move to and

"mkr1" setmarkerpos (getpos....)

to set the marker position. What I need to fill in is the ....? Is there some way of concatenating "lc" & the myLocation variable into an object name that works?

Share this post


Link to post
Share on other sites

So you placed logic objects named lc1, lc2, ... in the editor? If yes then I think this should do the deal

_randomLogic = [lc1, lc2, lc3, lc4, lc5, lc6] call BIS_fnc_selectRandom;
"mkr1" setMarkerPos (getPos _randomLogic);

or

_locations = [lc1, lc2, lc3, lc4, lc5, lc6];
_randomLogic = _locations select floor(random(count _locations));
"mkr1" setMarkerPos (getPos _randomLogic);

or

_randomLogic = missionNamespace getVariable format ["lc%1", ceil(random 6)];
"mkr1" setMarkerPos (getPos _randomLogic);

Last one generates lcX string and gets variable with such name from mission namescape (main scripting namespace, all named vehicles placed in editor are there too)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×