I have a loop in a trigger that is supposed to create a certain number of objects in random locations.
It works fine the first time through (it's supposed to loop every 10 seconds), but the second time it populates the WHOLE map with the units and gives me the error "too many nested triggers" so.... what is happening?
You're telling it to run the trigger that it's currently in and is already running. The entire point of using the while loop is to keep the trigger running till it's completes its tasks. A couple other notes; while not incorrect you can "modify" the count variable rather than set it. Also this should be in a thread definition.
You're telling it to run the trigger that it's currently in and is already running. The entire point of using the while loop is to keep the trigger running till it's completes its tasks. A couple other notes; while not incorrect you can "modify" the count variable rather than set it. Also this should be in a thread definition.
well the reason I have that there is so the objects will not spawn within a particular region that overlaps with the region they're spawning in. I figured it would stop running the trigger right there when if found that the test object had spawned in an invalid location and just keep starting over until it DID spawn in a valid location.
it works fine when spawning individual objects, but when it's more than 1 and all of them are spawning in random locations then it seems to have a problem.
all I did was take out the "run this trigger" part and now it works fine. I feel so dumb in not noticing that when that happens in the if statement it doesn't affect the invariant so the loop won't progress until it has hit 5. thanks for telling me
Don't worry, these problems happen to everyone! I accedently drop a function into a function sometimes when the UI gets laggy, with the same outcome. Always very irritating. What you have produced is by the way called a recursive function and has some fantastic applications if used right. Its highly useful on folder/hierarchies and other "data-trees".
I figured it would stop running the trigger right there when if found that the test object had spawned in an invalid location and just keep starting over until it DID spawn in a valid location.
Why on earth would it stop the current trigger when you've exactly told it to continue till it loops correctly 5 times. On a couple other notes if is not needed to set the unit to a local variable; and why on earth would you create a unit, check, then remove it, rather than check the point first and then create it or not. If im not mistaken you may even be able to set the region to properly exclude overlapping regions do that its properly picked a point and you're not checking its placement everytime.
I have a loop in a trigger that is supposed to create a certain number of objects in random locations. It works fine the first time through (it's supposed to loop every 10 seconds), but the second time it populates the WHOLE map with the units and gives me the error "too many nested triggers" so.... what is happening?
here is the trigger: http://imgur.com/vIQLq0X
sorry I don't know how to embed an image, i tried clicking the button for it and inputting the link but it just doesn't work
You're telling it to run the trigger that it's currently in and is already running. The entire point of using the while loop is to keep the trigger running till it's completes its tasks. A couple other notes; while not incorrect you can "modify" the count variable rather than set it. Also this should be in a thread definition.
well the reason I have that there is so the objects will not spawn within a particular region that overlaps with the region they're spawning in. I figured it would stop running the trigger right there when if found that the test object had spawned in an invalid location and just keep starting over until it DID spawn in a valid location.
it works fine when spawning individual objects, but when it's more than 1 and all of them are spawning in random locations then it seems to have a problem.
all I did was take out the "run this trigger" part and now it works fine. I feel so dumb in not noticing that when that happens in the if statement it doesn't affect the invariant so the loop won't progress until it has hit 5. thanks for telling me
Don't worry, these problems happen to everyone! I accedently drop a function into a function sometimes when the UI gets laggy, with the same outcome. Always very irritating. What you have produced is by the way called a recursive function and has some fantastic applications if used right. Its highly useful on folder/hierarchies and other "data-trees".
@azaraxzealot: Go
Why on earth would it stop the current trigger when you've exactly told it to continue till it loops correctly 5 times. On a couple other notes if is not needed to set the unit to a local variable; and why on earth would you create a unit, check, then remove it, rather than check the point first and then create it or not. If im not mistaken you may even be able to set the region to properly exclude overlapping regions do that its properly picked a point and you're not checking its placement everytime.