Boolean trouble

Here are my triggers. Read them before looking at my question.

Code:
Boolean Turn 2
????Events
????????Unit - A unit enters Turn2 <gen>
????Conditions
????????VariableCheck[1] Equal to True
????Actions
????????Unit - Order (Entering unit) to Move To (Center of Turn3A <gen>)
????????Set VariableCheck[1] = False

------------------------------Trigger 2----------------------------------------

Boolean Turn 2B
????Events
????????Unit - A unit enters Turn2 <gen>
????Conditions
????????VariableCheck[1] Equal to False
????Actions
????????Unit - Order (Entering unit) to Move To (Center of Turn3B <gen>)
????????Set VariableCheck[1] = True

Problem: Why is it that when 2 units enter the region (one after the other) that BOTH units go the same direction? Shouldn't they be alternating??

Yes I know, easy question most likely. But this is my first time using boolean variables :p
 
Werbung:

Abelhawk

New Member
That's weird. The only reason it should do that is if they entered the region at the same precise moment. If you want you might try using an integer variable. aka VariableCheck[1] = 1 then do this, VariableCheck[1] = 0 do that.
 
That's weird. The only reason it should do that is if they entered the region at the same precise moment. If you want you might try using an integer variable. aka VariableCheck[1] = 1 then do this, VariableCheck[1] = 0 do that.
[/b]
I could try that. Thanks.
I'll get back to you on that though, I must go now.

Edit - Rep added either way!

EDIT: Is this what you meant?

Code:
Boolean Turn 2
????Events
????????Unit - A unit enters Turn2 <gen>
????Conditions
????????VariableCheck[1] Equal to 0
????Actions
????????Unit - Order (Entering unit) to Move To (Center of Turn3A <gen>)
????????Set VariableCheck[1] = 1
--------------------------------------------Trigger 2----------------------------------------------------
Boolean Turn 2B
????Events
????????Unit - A unit enters Turn2 <gen>
????Conditions
????????VariableCheck[1] Equal to 1
????Actions
????????Set VariableCheck[1] = 0
????????Unit - Order (Entering unit) to Move To (Center of Turn3B <gen>)



Well it doesn't work.
 

Xeridanus

New Member
have one trigger off at any one time, and the other on. so the second last line in your code will be to turn this trigger off and the last line in your code will be to turn on the other trigger.

btw, boolean is exactly the same as if you used an integer of 1 or 0.

one last thing... why is the boolean var an array?
 
one last thing... why is the boolean var an array?
[/b]


Thanks you oh and for the question, there were going to me multiple regions that were going to require this variable so to save space I made it an array.

EDIT: Grr this doesn't work either!! Sigh...
 

Undead_Lives

New Member
Maybe try reducing the region size? You'd have to figure a way to point it out...but if only one unit can go through at a time it could solve your problem.
 

Zergleb

New Member
Oh come on evaluate what is going on, what happens is you have 2 triggers that will both stack in the queue at the same time so here is what happens.

the first trigger will check conditions and order accordingly. so now you have a unit going in that direction. Then after you set the boolean variable to true/false so that the other trigger will be set up to work.

but now you forgot that right after that trigger, the second trigger is going to execute, but you just barely set this trigger up so that it will work! so that means that even though you ordered the unit to move one way, this trigger is just going to change those orders so he will move the other way! So what happens is it will always move in the direction of the second trigger in your script.

re-do your trigger this way(rough guess of what it will look like)

Event:
Unit - A unit enters Turn2 <gen>
Conditions:
None
Actions
if VariableCheck[1] == true then
Unit - Order (Entering unit) to Move To (Center of Turn3A <gen>)
Set VariableCheck[1] = False
else
Unit - Order (Entering unit) to Move To (Center of Turn3B <gen>)
Set VariableCheck[1] = True
endif

That is not the exact way I would do it but that is a working conversion of your trigger(I hope its a working one)But this way you don't have 2 triggers messing each other up.
 
Werbung:
Top