OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: granQ on 16 Aug 2009, 23:53:52
-
I am making a mission where you can capture cities, like warfare, now this will be sorta dynamic but all markers (cities, bases) will be added into an array. What I want to do is run some code once ALL markers are red, any ideas how to make it nice and smart?
lets say we got this to play with
markers_array
getmarkercolor "ColorRed"
thanks for your help
-
_red = true;
{
_red = _red and (markerColor _x == "ColorRed");
} forEach markers_array
Be aware, no markers are red ;)
(And untested)
-
i like your idea even if I must say at current stage it shouldn't work.
if the marker is blue, then it will be:
_red = true and false
which is strange for me??
-
Just some boolean logic:
and | true | false | | or | true | false |
true | true | false | | true | true | true |
false | false | false | | false | true | false |
true combined with false via and will result in false.
So _red will get to false and never can get back to true since false combined via and will only be false.
and is a check if both values are true. or will check if one of those is true.
And this inspires me to new code:
_red = true;
_i = 0;
while {_red} do {
_red = _red and (markerColor (markers_array select _i) == "ColorRed");
_i = _i + 1;
};
In basic the same code as above, but as soon as it encounters a non red marker it will exit the loop.
-
made a minor edit to it, thanks a lot.. think we got cased closed :)
Thanks a lot you would probably throw up if you saw what I tried to do.
_red = true;
_i = 0;
while {_red} do {
_red = _red and (markerColor (markers_array select _i) == "ColorRed");
if (_i == count mmai_towns) then {_i = 0};
_i = _i + 1;
};