Jump to content
AZCoder

Trigger nil on startup

Recommended Posts

I am having a terrible time here. I guess this "broke" in the latest patch of Arma 3. Basically I have a trigger on the map with a name (trgCDF). During mission load I am trying to "list trgCDF" to get the units in the trigger, but it comes back "nil". Ok, I figure the script is running before the trigger is "populated" but I can't find a way to delay the script until the trigger is ready. Using something like "sleep 2" fixes the problem, but that's not a good solution. Normally I would use waitUntil, but latest version is a lot more stringent about type checking boolean. For some reason, checking the typeName of "list trgCDF" does not return true or false, so that fails. Wait a second or two and it would work, but that's my point. typeName (list trgCDF) comes back as nothing. If you wait a second, it comes back as ARRAY as expected. So I'm at a loss here. If I can't check the type and I can't wait on it, then it's totally broken (unless I use sleep). It's a large mission so there's a lot to load. Has anyone faced this problem and have a suggestion? I would appreciate it, thanks.

Share this post


Link to post
Share on other sites

@AZCoder

Quote

like "sleep 2" fixes the problem


If "sleep 2" works then "sleep 0.5" should also work and that is the frequency triggers operate at.

Have fun!

Share this post


Link to post
Share on other sites

There were no changes between 1.94 and 1.96 that would cause this. waitUntil operates exactly as in 1.94. If you run your script from init of an object and this object is added in editor before the trigger it may well cause trigger be nil at the time script runs.

Share this post


Link to post
Share on other sites
1 hour ago, killzone_kid said:

There were no changes between 1.94 and 1.96 that would cause this. waitUntil operates exactly as in 1.94. If you run your script from init of an object and this object is added in editor before the trigger it may well cause trigger be nil at the time script runs.

There is no object added by the script. To rephrase my question, how do you get the result from "list trigger_name" from within a script during the mission load? This is no longer possible as it comes back <null> and the error specifically states that waitUntil expected a boolean. For further clarification, I also had it called from inside the trigger init itself in another case and that too comes back as an error. Last May it worked fine, I took some time off, and now this does not work.

 

Share this post


Link to post
Share on other sites
2 hours ago, wogz187 said:

@AZCoder


If "sleep 2" works then "sleep 0.5" should also work and that is the frequency triggers operate at.

Have fun!

Yes I can use sleep on my PC, but considering that load time of the mission is a factor, we don't know that 0.5 is enough for other players with slower machines. Waiting for the trigger condition to have a value has been the safer option in the past, except that waitUntil no longer recognizes "list trigger_name" as a valid boolean right away.

Share this post


Link to post
Share on other sites
5 hours ago, AZCoder said:

There is no object added by the script. 

Who said anything about object added by script? I said object added in editor. The config is generated and objects added later are after objects added before and init executes in order of objects added

Share this post


Link to post
Share on other sites
5 hours ago, AZCoder said:

and now this does not work.

waitUntil works EXACTLY like last May with exception of error message

Share this post


Link to post
Share on other sites
4 hours ago, killzone_kid said:

waitUntil works EXACTLY like last May with exception of error message

I never said it didn't. I didn't need waitUntil back in May. I could initialize trigger list inside the trigger at that time. Now that comes back as null during mission startup. So I moved it from trigger init to script and trying to use waitUntil but it sees null instead of boolean. I am simply asking how to make it work.....

Share this post


Link to post
Share on other sites

If I'm right, list, thisList work with the pre-condition of the trigger, i.e. detected by the trigger (BLUFOR present...)

Perhaps, you should consider a "none" trigger (no list) but scripted conditions like:

west countSide (allUnits select {_x inArea thisTrigger}) >0

or even:

waitUntil {!isNull player}; west countSide (allUnits select {_x inArea thisTrigger}) >0

 

  • Like 1

Share this post


Link to post
Share on other sites

If your trigger is nil then `list trigger` will also be nil. waitUntil {!isNil {trigger}}; then your code

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
4 hours ago, killzone_kid said:

If your trigger is nil then `list trigger` will also be nil. waitUntil {!isNil {trigger}}; then your code

Let me review my code tonight, I did something like that but perhaps I got the syntax wrong. Thanks!

 

Update: I got it to work. In case anyone else needs the solution it was this:


waitUntil { !(isNil {list trgCDF}) };

Thanks @killzone_kid for getting me here, I just had to add list in front of the trigger name. I didn't realize you could isNil {code} so that's what I needed!

  • Like 1

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

×