UnitY() is nil inside of a Target Detected event (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support



Message


NimrodX -> UnitY() is nil inside of a Target Detected event (5/30/2018 3:23:48 AM)

I have an event of the "target detected" sort. There is one single "Unit is Detected" trigger.

I need it to fire only when a specific unit detects the target, so I need a Lua condition that uses ScenEdit_UnitY() to get the detecting unit. I have one single Lua condition for this purpose.

So I have this code for the Lua condition:

quote:


local by = ScenEdit_UnitY()
return by.unit.guid == 'XiaoZhanMa-GUID'


This was working perfectly fine earlier but at some point, for no apparent reason, 'by' is coming up as either nil or empty string every time it runs.

Shoulnd't ScenEdit_UnitY() get set to the detecting unit for both conditions and actions?




michaelm75au -> RE: UnitY() is nil inside of a Target Detected event (6/11/2018 9:08:58 AM)

Found an edge case. If no sensor 'made' the contact, then UnitY() will fail. Updated to pass back UnitY() even if no sensor table.




NimrodX -> RE: UnitY() is nil inside of a Target Detected event (6/12/2018 6:14:38 AM)

Woohoo! Thanks. This will come in handy.

But I am confused as to how a "Unit is Detected" trigger could trigger if no sensor detected the unit?




Dimitris -> RE: UnitY() is nil inside of a Target Detected event (6/12/2018 6:27:59 AM)

There are cases where a "presumed" contact is generated, for example if you detect a torpedo or a missile breaks off the sea surface in an otherwise empty area then a "possible sub contact" is automatically created.




NimrodX -> RE: UnitY() is nil inside of a Target Detected event (6/12/2018 6:40:20 AM)

Ok, but in this case there's a "spy" who spots an aircraft with eyeballs/binoculars. The aircraft didn't fire weapons or do anything to imply that an aircraft should be there. Unless I missed something it's just flying around and should either be seen or not seen by eyeballs/binoculars?

I understand what you mean about the implied existence of something that launches a missile for example, and it makes sense to have no sensors for that case since the contact is essentially an intellectual inference based on the idea that missiles/torpedoes can't come from nowhere. But it doesn't seem like it applies to this case where there's just an airplane flying around not releasing weapons?




michaelm75au -> RE: UnitY() is nil inside of a Target Detected event (6/13/2018 8:36:21 AM)

In this case, the sensor was sometimes 'visual' but more often nothing; I was replaying with the new code and about 3 out of 5 times I got the sensor list with the 'visual' in it with nothing the rest of the time.
This may explain why you say sometimes it was working and others not. Not sure why sometimes the event is being triggered, but by the time the condition kicks in, something has cleared the sensor list.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
1.015625