Jump to content

Recommended Posts

Having horrible difficulties with the ! thing. It's too short to search for on the forum, the wiki and command reference don't explain why I'm having difficulties, and I've spent many hours on a very simple script, to no avail.

I'm trying to write a check to ensure that a unit has spawned, because if I hit "disable AI" before the mission starts, the disabled units are apparently considered neither dead nor alive. They don't activate my "unit is dead" trigger nor my "unit is alive" trigger. So in order to have the mission end when it's supposed to, I'm trying to make a trigger which checks to see if each playable unit is in the mission. I'm doing this with a "any group member present" trigger, grouped to each of the four units (each of which is in its own group). On activation, spawn1 = true for unit1, spawn2 = true for unit2, etc.

The second trigger contains in the Condition field !spawn2 and in On Act. obj2p2 = true. Here's where the problem lies, as I finally found out by gradually eliminating all of the other scripts in the mission. !spawn2 is evidently not being recognized as a condition, although no errors pop up in "showscripterrors" mode. How can I get around this?

Share this post


Link to post
Share on other sites

You must initialize those variables, with for example spawn1 = false and spawn2 = false in the init.sqf, for example.

Share this post


Link to post
Share on other sites
You must initialize those variables, with for example spawn1 = false and spawn2 = false in the init.sqf, for example.

Correct! I've run into this several times to, but starting to learn. The theory is this:

Until a variable is initilalized (by being assigned a value) it is regarded as "uninitialized" (isNil "variable" == true).

If an uninitialized value appears in a condition, the condition is regarded not true nor false (so an if clause would not be executed, nor its else clause).

In an ordinary simple trigger this is not a problem. You usually only have statements to execute if the condition is true, and nothing to execute if it's false or uninitialized. But in your exemple you need to be aware of this.

Share this post


Link to post
Share on other sites

Ah, I think I understand now. Thank you, gentlemen.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×