I getting an error saying something about a specific trigger being a 'nested iteration' when a trigger fires in game, but as far as I can see the trigger is working even though it's giving me an error message. Also, how would I create a trigger to check how many resources a player (specifically a computer, for testing purposes) currently has with a chat message? I want to make sure my other trigger is working for ALL players before I go further.
I once encountered this when a "pick each unit" loop was calling another function that also had a "pick each unit." I discovered that if I changed one to "for each unit" and used an integer variable to loop, the problem solved itself. This might have something to do with their implementation of iterators.
Well here is the trigger I am currently using to select one random player, then set a variable that corresponds with the player's number. Once the variable is set a separate trigger will give that player extra resources every 5 seconds. It should only select one player though, not all of them, and it does. AFAIK the trigger works but maybe you guys should take a look at it:
I once encountered this when a "pick each unit" loop was calling another function that also had a "pick each unit." I discovered that if I changed one to "for each unit" and used an integer variable to loop, the problem solved itself. This might have something to do with their implementation of iterators.
^ This
I suspect it would attempt to use the same variable for that inner "Pick each unit" loop, which would cause unstable and unforeseen side effects. Most of the time it's probably a lot safer to just go with "For each unit" and use a variable of your own making to store the iterator.
Looking at your code, you can't have two "Pick each integer" loops. I would change all your loops to "For each integer" and make a local variable 'a', 'b', etc for each new loop.
Because in the triggers themselves when you call "Picked integer" how does it know which one to use? This is definitely your problem.
I also feel like there's a more elegant way to do this than such a deeply-nested if statement.
In fact, looking at the code...I'm not sure it even makes any sense.
Is there a reason you're looping through these variable setters 8 times?
And your nested 'if' statement can't possibly be giving you the result you want it to. Every time it evaluates one of the 'if' conditions, it re-makes a random number from 1-8 - such that the true/false result of the previous random number from 1 to 8 has no bearing on the next condition check.
I would probably re-evaluate what this trigger is doing...
That break in the 'then' is very important. It's also important that there is always at least one true value in the Alive?[] array, or the loop will run indefinitely.
The loop will continue to run until the random number generator generates a number from 1-8 who's Alive? variable *is* true, at which point it sets the two variables you want.
I suspect it would attempt to use the same variable for that inner "Pick each unit" loop, which would cause unstable and unforeseen side effects. Most of the time it's probably a lot safer to just go with "For each unit" and use a variable of your own making to store the iterator.
Looking at your code, you can't have two "Pick each integer" loops. I would change all your loops to "For each integer" and make a local variable 'a', 'b', etc for each new loop.
Because in the triggers themselves when you call "Picked integer" how does it know which one to use? This is definitely your problem.
I also feel like there's a more elegant way to do this than such a deeply-nested if statement.
In fact, looking at the code...I'm not sure it even makes any sense.
Is there a reason you're looping through these variable setters 8 times?
And your nested 'if' statement can't possibly be giving you the result you want it to. Every time it evaluates one of the 'if' conditions, it re-makes a random number from 1-8 - such that the true/false result of the previous random number from 1 to 8 has no bearing on the next condition check.
I would probably re-evaluate what this trigger is doing...
That break in the 'then' is very important. It's also important that there is always at least one true value in the Alive?[] array, or the loop will run indefinitely.
The loop will continue to run until the random number generator generates a number from 1-8 who's Alive? variable *is* true, at which point it sets the two variables you want.
Mega bump, but damn I guess I'ma have to rethink how I do triggers. I mean I never thought of using a loop. The way I do things is I usually tend to cram as much as I can into one trigger rather than taking the time to make several duplicates. Though I'm not the best and I guess some of it could be avoided by doing such things as this. Thanks.
If you are unsure how to make proper triggers but know quite some of what the triggers do you could open up a few campaign maps (unless you haven't finished it yet ofc for spoilers) and check how Blizzard did it. Afterall, they probably know how to use their editor the best at this point in time.
Also, how would I create a trigger to check how many resources a player (specifically a computer, for testing purposes) currently has with a chat message? I want to make sure my other trigger is working for ALL players before I go further.
I didn't see this answered, so here you go:
right click -> new action -> find Text Message.
Click the green 'message' info, then function radio button, then go to the Conversion label category list, then choose Convert Integer to Text.
Click the green '0' info, then function radio button, then go to the Player label category list, and choose Player Property.
The rest shold be self explanatory I hope.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I getting an error saying something about a specific trigger being a 'nested iteration' when a trigger fires in game, but as far as I can see the trigger is working even though it's giving me an error message. Also, how would I create a trigger to check how many resources a player (specifically a computer, for testing purposes) currently has with a chat message? I want to make sure my other trigger is working for ALL players before I go further.
@ST4RKiLL3R: Go
well, nested means inside of some kind of loop or if/then statement or switch statement, and iteration is like one run through a loop.
@anguule: Go
I once encountered this when a "pick each unit" loop was calling another function that also had a "pick each unit." I discovered that if I changed one to "for each unit" and used an integer variable to loop, the problem solved itself. This might have something to do with their implementation of iterators.
@Thalassicus: Go
Well here is the trigger I am currently using to select one random player, then set a variable that corresponds with the player's number. Once the variable is set a separate trigger will give that player extra resources every 5 seconds. It should only select one player though, not all of them, and it does. AFAIK the trigger works but maybe you guys should take a look at it:
I basically just used the previous trigger's else to lead into the next check. Is that the problem? If so how you trigger this?
^ This
I suspect it would attempt to use the same variable for that inner "Pick each unit" loop, which would cause unstable and unforeseen side effects. Most of the time it's probably a lot safer to just go with "For each unit" and use a variable of your own making to store the iterator.
Looking at your code, you can't have two "Pick each integer" loops. I would change all your loops to "For each integer" and make a local variable 'a', 'b', etc for each new loop.
Because in the triggers themselves when you call "Picked integer" how does it know which one to use? This is definitely your problem.
I also feel like there's a more elegant way to do this than such a deeply-nested if statement.
In fact, looking at the code...I'm not sure it even makes any sense.
Is there a reason you're looping through these variable setters 8 times?
And your nested 'if' statement can't possibly be giving you the result you want it to. Every time it evaluates one of the 'if' conditions, it re-makes a random number from 1-8 - such that the true/false result of the previous random number from 1 to 8 has no bearing on the next condition check.
I would probably re-evaluate what this trigger is doing...
I would do something like this:
That break in the 'then' is very important. It's also important that there is always at least one true value in the Alive?[] array, or the loop will run indefinitely.
The loop will continue to run until the random number generator generates a number from 1-8 who's Alive? variable *is* true, at which point it sets the two variables you want.
Mega bump, but damn I guess I'ma have to rethink how I do triggers. I mean I never thought of using a loop. The way I do things is I usually tend to cram as much as I can into one trigger rather than taking the time to make several duplicates. Though I'm not the best and I guess some of it could be avoided by doing such things as this. Thanks.
If you are unsure how to make proper triggers but know quite some of what the triggers do you could open up a few campaign maps (unless you haven't finished it yet ofc for spoilers) and check how Blizzard did it. Afterall, they probably know how to use their editor the best at this point in time.
I didn't see this answered, so here you go: right click -> new action -> find Text Message. Click the green 'message' info, then function radio button, then go to the Conversion label category list, then choose Convert Integer to Text. Click the green '0' info, then function radio button, then go to the Player label category list, and choose Player Property. The rest shold be self explanatory I hope.