| 02-09-2006, 09:01 AM | #1 |
So I got an If statement to check if a unit is loaded in a transport or not. Let me rewind a little...I have a trigger that fires when a unit recieves an order targeting an object, first there is a Wait of adequate length, the the aformentioned If statement. Fine, here is an illustration: Here is where the freaking crap comes in. No matter how I try to set it up, if the unit is loaded, it says LOADED, as it should. But if it fails to load because the Barracks is full...nothing happens. One would think that if an if doesn't do its then, then it will do it's else, but apparently my map likes to ignore the laws of reason. This doesn't happen if I create the trigger on a new map, so I think I must have really bungled up my map somehow. All other triggers seem to be acting OK though. |
| 02-09-2006, 09:10 AM | #2 |
Lol? game-time seconds? why you don't use normal wait? |
| 02-09-2006, 11:46 AM | #3 |
Because polled wait is better. So, this exact trigger works in a blank map, but not in your map? wierd. Try putting another debug message before the if/then/else. |
| 02-09-2006, 04:39 PM | #4 |
Try just having a trigger that checks if a certain unit is being loaded, and have it triggered by a typed command, and then investigate if the condition is messed up. |
| 02-11-2006, 09:40 AM | #5 |
I figured out that the problem has to do with the fact that the unit is created just prior to being ordered to board the barracks. For some reason if a unit has just been created and the transporting unit is already full and then the unit is ordered to board the transport, the order doesn't actually happen. That is why I was seeing LOADED but not NOT LOADED, the trigger wasn't actually firing if their was no room left to board. But if the unit is told to board after the first failed attempt, the trigger does fire! So that is still weird, but I'm getting somwhere. Any suggestions how I can handle this differently? Or better yet, how could I tell if a unit can board another unit without even having to give an order and then seeing if it worked? |
| 02-11-2006, 07:49 PM | #6 |
Hurray, I solved it! I merged this trigger in with the trigger that creates the units, which is how I originally had it, but it didn't work that way before either and this is why: I was using the trick where you can create a local variable prefixed with udg_ and then you can use that variable in GUI functions by using the global variable of the same name. (I needed a local variable because I need a small wait so the unit has time to load). But unbeknownst to me, that trick doesn't work on the condition in GUI if statements. Is that common knowledge to the rest of you? I was having another "what the freaking crap" moment because the debug messages were accurately returning the name of the unit but not accurately figuring out the loaded state of the unit. I recreated the if statement as custom code and it worked fine! |
