Home   Help Search Login Register  

Author Topic: End mission when all makers turn red  (Read 1670 times)

0 Members and 1 Guest are viewing this topic.

Offline granQ

  • Contributing Member
  • **
    • Anrop.se
End mission when all makers turn red
« 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
Cura Posterior

Offline i0n0s

  • Moderator
  • *****
Re: End mission when all makers turn red
« Reply #1 on: 17 Aug 2009, 00:10:08 »
Code: [Select]
_red = true;
{
_red = _red and (markerColor _x == "ColorRed");
} forEach markers_array
Be aware, no markers are red ;)
(And untested)

Offline granQ

  • Contributing Member
  • **
    • Anrop.se
Re: End mission when all makers turn red
« Reply #2 on: 17 Aug 2009, 00:28:22 »
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??
Cura Posterior

Offline i0n0s

  • Moderator
  • *****
Re: End mission when all makers turn red
« Reply #3 on: 17 Aug 2009, 00:56:34 »
Just some boolean logic:
andtruefalseortruefalse
truetruefalsetruetruetrue
falsefalsefalsefalsetruefalse

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:
Code: [Select]
_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.

Offline granQ

  • Contributing Member
  • **
    • Anrop.se
Re: End mission when all makers turn red
« Reply #4 on: 17 Aug 2009, 01:32:48 »
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.
Code: [Select]
_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;
};
Cura Posterior