Welp, I'll probably get a yes to this question, but I want to see how it is. So, my problem is that I want a condition that checks that ALL players have selected a unit, IF they did then there's a boolean per player that assigns "True" if they did. So, the question is that is there a way to check all players actually have "True" on their corresponding booleans with a function instead of going:
(Player[0]==1)(Player[1]==1)(Player[2]==1)//etc.
I want something like
for(inti=0;i<numberofplayers;i++)(Player[i]==1)
I used C++
here on this last code, but it's just so you get the picture. I'm not certain on how functions work here on the editor.
LocalVariablesi=0<Integer>all=True<Boolean>General-Foreachintegerifrom1tonumOfPlayerswithincrement1,do(Actions)ActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfPlayer[i] != 1
Then
Hmm so this code starts on 0, right? Player[0], then Player[1] and so on? I find it hard to understand when it asks you from where to where in the loop. Like, it should start from i = 0, but it starts from 1? I don't get it.
That is correct. It starts at whatever from integer you set and can even go backwards All loops are basically just while loops at heart with the for each loop including the modification for the variable.
I know, I tried it a long time ago and it didn't work. Incidentally, I tried it yesterday and it didn't work then either. Both times I had expressions, so I had other issues I didn't both to check.
Anyway, I'm glad you mentioned that. It'll help very much not having to do the extra math to flip the current integer.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Welp, I'll probably get a yes to this question, but I want to see how it is. So, my problem is that I want a condition that checks that ALL players have selected a unit, IF they did then there's a boolean per player that assigns "True" if they did. So, the question is that is there a way to check all players actually have "True" on their corresponding booleans with a function instead of going:
I want something like
I used C++ here on this last code, but it's just so you get the picture. I'm not certain on how functions work here on the editor.
The for loop equivalent in GUI is called "For each integer variable"
To check that Player[i] == 1 for all players, you would do something like this:
You could then put that in a condition or function so that you could check easily with one condition e.g.
@DeltaV: Go
Hmm so this code starts on 0, right? Player[0], then Player[1] and so on? I find it hard to understand when it asks you from where to where in the loop. Like, it should start from i = 0, but it starts from 1? I don't get it.
That code starts on 1. If you are using player 0 change that^ ^ ^ to a 0.
@DeltaV: Go
So, the loop starts not from the variable but from the from 1? So for example, you can have the variable be 20, but it will still start from 1?
@joemart06: Go
That is correct. It starts at whatever from integer you set and can even go backwards All loops are basically just while loops at heart with the for each loop including the modification for the variable.
Errrrr.
That's not true for any loop.
Mod or increment -1 ? Works for me.
@hobbidude: Go
Woops, you're right. I know I tried that before and it didn't work, guess I was mistaken.
@Charysmatic: Go
You would also have to swap the starting and ending integers (ie 20 -1 )
@hobbidude: Go
I know, I tried it a long time ago and it didn't work. Incidentally, I tried it yesterday and it didn't work then either. Both times I had expressions, so I had other issues I didn't both to check.
Anyway, I'm glad you mentioned that. It'll help very much not having to do the extra math to flip the current integer.