I keep getting errors in my triggers while i'm testing saying "too many threads". I think this is tied to the "unit dies" events I use to count kills and add behavious depending on an amount of kills too.
The trigger script is intensive.
I was previously using "whiles" and changed to "if then else" for my scripts but it only seems to have gotten worse in some instances.
Can anyone help me? Also what is the most efficient way of creating a loop and running a "unit dies" event.
I can't see the script and therefore I can't help you specifically. However, what I believe is the best way to create a loop is by using the "While" function, but remember that you must have a "Wait" at the end of the While-"actions", else you will recieve and overflow. That MAY be your problem by using "while".
Secondly, you could also use two triggers and a simple conditional trigger.
TRIGGER 01___
Event - When any unit dies
Condition - <Conditon A> == true
Action - Turn on <Trigger A>
______
TRIGGER 02___
Event - Ever X seconds
If/Then/Else
If - <Conditon B> == true
then- <Action A>
else -<Turn off this trigger"
_____
However, this way of creating a loop is very unnecessary, in the most cases there are other kinds of workarounds.
Events
Unit - Any Unit dies
Local Variables
Conditions
1 <= (Owner of (Triggering unit)) <= 8
Actions
Variable - Modify Player Kill Counter[(Killing player)]: + 1
and my "unit die" trigger which automatically kills some units each second.
Events
Timer - Every 1.0 seconds of Game Time
Local Variables
Conditions
Actions
Trigger - Add (Actions) to the action queue
Actions
Unit Group - Pick each unit in (Any units in Neutral Die owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
Unit - Kill (Picked unit)
Without reading anything - I think it might be your while loops
Muahaha!
Ok seriously now:
if-then-else
if-then-else
if-then-else
or
if-then-else
--if-then-else
if-then-else (formatting messed up but its copy paste from your post)
Those 2 ways are not the same, the first way does the 'then' part, then skips else, then goes into the next 'then' (assuming it passes conditions)
The second way ONLY goes into the second 'then' if it does NOT go in the first 'then'
So basically, it only goes into the second statement if it fails the conditions of the first statement
I found out what the problem is. It's neither the unit spawn OR the unit dies. It's my timer arrays for spawns. Somehow I think i'm generating an infinate loop somehow.
I keep getting errors in my triggers while i'm testing saying "too many threads". I think this is tied to the "unit dies" events I use to count kills and add behavious depending on an amount of kills too.
The trigger script is intensive.
I was previously using "whiles" and changed to "if then else" for my scripts but it only seems to have gotten worse in some instances.
Can anyone help me? Also what is the most efficient way of creating a loop and running a "unit dies" event.
I can't see the script and therefore I can't help you specifically. However, what I believe is the best way to create a loop is by using the "While" function, but remember that you must have a "Wait" at the end of the While-"actions", else you will recieve and overflow. That MAY be your problem by using "while".
Secondly, you could also use two triggers and a simple conditional trigger. TRIGGER 01___ Event - When any unit dies
Condition - <Conditon A> == true
Action - Turn on <Trigger A>
______
TRIGGER 02___ Event - Ever X seconds
If/Then/Else
If - <Conditon B> == true
then- <Action A>
else -<Turn off this trigger"
_____
However, this way of creating a loop is very unnecessary, in the most cases there are other kinds of workarounds.
I think one of my problems is that I don't use action queues.
Here is a question for you.
I have a trigger which picks a player and then runs the script for each player. It is a long script and has about 8 if-then-else.
Should I create it like like the example below or the second example where the next if statement is attached to the else statement?
if-then-else
if-then-else
if-then-else
or
if-then-else
----------if-then-else
if-then-else
The error always references the same 2 triggers.
My kill counter trigger
Events
Unit - Any Unit dies
Local Variables
Conditions
1 <= (Owner of (Triggering unit)) <= 8
Actions
Variable - Modify Player Kill Counter[(Killing player)]: + 1
and my "unit die" trigger which automatically kills some units each second.
Events
Timer - Every 1.0 seconds of Game Time
Local Variables
Conditions
Actions
Trigger - Add (Actions) to the action queue
Actions
Unit Group - Pick each unit in (Any units in Neutral Die owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
Unit - Kill (Picked unit)
Without reading anything - I think it might be your while loops
Muahaha!
Ok seriously now:
if-then-else if-then-else if-then-else
or
if-then-else
--if-then-else if-then-else (formatting messed up but its copy paste from your post)Those 2 ways are not the same, the first way does the 'then' part, then skips else, then goes into the next 'then' (assuming it passes conditions)
The second way ONLY goes into the second 'then' if it does NOT go in the first 'then' So basically, it only goes into the second statement if it fails the conditions of the first statement
@SweetZombieJesus:
I see.
There is definitely problems with the amount of threads my map is generating. I think it is one of two triggers causing the problem.
I have 3 triggers setup to use "unit dies" event.
The main spawn unit script which uses a lot of conditions.
T compensate i'm using "wait for trigger" wherever possible and narrow down the real cause.
I'm wondering if I can use "queue action" for the unit dies events. Would that help? not used those before.
Is it possible to create a "queue actions" trigger and then a "wait for trigger to complete"?
Does that make sense? Maybe i'm being too complicated.
Have not used queues myself
Yes you are being too complicated :P You can simplify your code code with logic and avoid these too many threads
I suggest you go through your entire code and really look at it all and realize what everything does, then you should find it
I found out what the problem is. It's neither the unit spawn OR the unit dies. It's my timer arrays for spawns. Somehow I think i'm generating an infinate loop somehow.
For the observer/hellfire nuke/x-plodie bug.