OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: Nephris on 27 Oct 2009, 20:11:20
-
Hi folks,
i am sure this has been answered several times but i seem to be too stupid to find the right solution...
So how can i create random positions on the map, on what e.g. objects/compositions or whatever can be spawned or moved at misson start?
I tried sth like that, but then it left me....
_spawns = ["mkpos1", "mkpos2", "mkpos3"] ;// ingame marker
_logs = ["log1", "log2", "log3"] ;//ingame logic
_spawn = _spawns select floor random count _spawns ;// select marker
_log = _logs select floor random count _logs ;//select logic
_log setpos getmarkerpos _spawn;
-
Didn't test, but something like?
call compile format ["
log%1 setpos [(getmarkerpos ""mkpos%2"" select 0),(getmarkerpos ""mkpos%2"" select 1),0]
",ceil(random 3),ceil(random 3)];
-
When i understand your example right, i guess we misunderstood.
I dont want to create a random position around a marker, which could be handled via Editor.
I would like to postition log1 random at mkpos1,mkpo2 or mkpos3.
-
You have set of markers and set of logics, you then randomly select a marker and randomly select a logic. Then you move the selected logic to the location of the selected marker?
-
Yes, that is the basic idea.
It doesnt hve to be a logic, as it can also be any object.
I just would like to have a general script i can use,to place logics,objects or units by random to positions that have been created before.
-
Then why did you reject my code without trying?
If you want to move a specific logic/object, just remove the random for that part:
call compile format ["
myLogicOrSomething setpos [(getmarkerpos ""mkpos%1"" select 0),(getmarkerpos ""mkpos%1"" select 1),0]
",ceil(random 3)];
That will move myLogicOrSomething to location of either mkpos1, mkpos2 or mkpos3 marker.
-
I am so sry m8!
Works as it should!
Nevertheless i absolutely dont understand the few lines of script...
What does that mean?
""mkpos%1""
-
Double quote marks are because it's inside a string already (format command). They make sure the marker name is a string and not a variable ("mkpos1" vs mkpos1).
%1 is part of the format command, it is replaced by the first value given to it. In this case our first, and only one, "ceil(random 3)", which returns 1, 2 or 3. So, the %1 is replaced by either 1, 2 or 3 and giving us "mkpos1", "mkpos2" or "mkpos3".
-
Getting light on Planet Darkness...
That means if we would have 10 markers, named from mkpos1 - mkpos10 it would be "ceil(random 10)" ?
-
yes
-
coolaroony, cheerz m8
:good: