AutoDetect UnitEntersArea Event

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

AutoDetect UnitEntersArea Event

Post by Parel803 »

Goodevening,
Hope somemone can help me. Try to make a contact autodetectable when entering a circle around a MPA. As simulating sort of an AIS.
I made a circle on a fake side which updates it's position every 15 seconds, position update is the Blue MPA as centre.
The event for autodetect has a trigger: unit enters area with the RP's of that circle.
The action of the event I made is: ScenEdit_SetUnit ({side=UnitX().side, unitname=UnitX().name, Autodetectable=true})
When my AIS track enters the circle the detection window stops but no autodetect is given. Also the name is't changing to the correct one. Looking at that unit is says it's has autodetect.
Another track which is autoDetect given in advance is showing it's correct name.I misused the RP's circle or I made errors in the action of the event.

with regards Gert-Jan
Attachments
AutoDetectOnRange.zip
(13.61 KiB) Downloaded 12 times
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: AutoDetect UnitEntersArea Event

Post by KnightHawk75 »

Either I don't follow exactly or I can't reproduce the problem playing under 1147.29.

I press play... the circles move, eventually they cover the 2 Civ AIS units, those units get marked autodetectable and show up as such on say the smugglers side.
I then added a sailboat to side Civilian AIS for added test, to west of the moving circle, marked as not-autotectable, waited a bit for circle to cover it, it changed them to autodetectable as expected and shows up as such on other sides such as smugglers within a couple seconds.
Also the name is't changing to the correct one.
[&:] Not sure what you mean by name change, I see no code for changing any unit or contacts name?

Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: AutoDetect UnitEntersArea Event

Post by Parel803 »

KnightHawk, thank you for you're time. Apologize for my english, even my dutch is rubbish.
For a autodetect unit which I did in advance via editor the name I see of that contact is the name I gave it with initiating (name is tstAutoDetect). The Skunk in bearing 272, detected on radar at 55nm, has a regular updated detection on the Right side of the screen. When the event is fired (AIS Autodetect On) the update detection stops, no showing autodetect. The image and DB name is showing but het name stays "Skunk #3". Her given platform name is UK 323.
I was wondering why I, as Blue Side, don't see het Platform name. If it is intended, I apaologize for time lost. If it is not I'm looking for my error.

with regards Gert-Jan
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: AutoDetect UnitEntersArea Event

Post by KnightHawk75 »

Oh the the contact name change you meant, ah ok.
I'll take another look at that see what I can see - I vaguely remember issues in certain instances a year ago when testing detectionlevel changes like that.


KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: AutoDetect UnitEntersArea Event

Post by KnightHawk75 »

Yup. If the ship\skunk contact is previously spotted prior to detection level changing\jumping to auto-detect|4, it's contact name is not updated, where as if it was previously unknown it's properly labeled by the unit name. I would report that. There may be some reasoning for that logic\way it operates, but I can't think of any right now.

Attached (autodetectonragekh.zip) a dirty sledgehammer workaround (ie there are better ways to workaround it) which updates all ship contact names that are auto detected to their unit names every so often.

Not directly related but would not be surprised if detection triggers based on level-4 may not fire too, even though you don't have any in the scene, it's what I was remembering from when I saw something similar some time ago.
fb.asp?m=4942330
fb.asp?m=4942303
Attachments
AutoDetectOnRangeKH.zip
(14.23 KiB) Downloaded 14 times
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: AutoDetect UnitEntersArea Event

Post by Parel803 »

KnightHawk, thanks again. Will check out the work around.
regards Gert-Jan

small question, should I post this in Tech? Or is it just the way the game works.
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: AutoDetect UnitEntersArea Event

Post by KnightHawk75 »

If you want it fixed\changed I'd post in tech support, the current behavior doesn't strike me as intentional but that's the only way to find out for sure.
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: AutoDetect UnitEntersArea Event

Post by Parel803 »

Thx for you're help and time,
with regards
Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: AutoDetect UnitEntersArea Event

Post by Parel803 »

Follow Up questions if I may. My LUA still in embryotic stage.
Sometimes almost understand stuff and then it's gone :-)
Again working on the AIS simulation (and IFF) in CMO. Made a scen with a circle and circle keeps updating.

In my previous scen I had an event where UnitX changed autodetectable when entering the area. Worked great, especially with the update name function from KH.
ScenEdit_SetUnit ({side=UnitX().side, unitname=UnitX().name, Autodetectable=true}) with regular trigger

But now I have the circle RP's (names) later on in the scenario, so can't select the RP's in trigger: unit enters area.
I was wondering if this could be solved with a function where it says when an unit from side CivilianAIS side enters the circle defined in another event switches to AutoDetectable?
Or could it be done in something that's making a complete event as shown on the github site?
Or is it just a stupid question, if so, disregard entirely.

Thoughts were to activate the new event when the circle is initiated? But not really know how to start getting the RP's when unitX enters etc.

with regards GJ
Attachments
TestIAS.zip
(8.51 KiB) Downloaded 6 times
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: AutoDetect UnitEntersArea Event

Post by KnightHawk75 »

If you are asking if you have an arbitrary bounded location you want to check if something is inside that polygon, without using in-area triggers directly yeah there are ways. If you mean can you add\change the defined RP's 'after the fact' because they don't exist before hand (I think this is what you mean), yeah you can, along with creating the entire trigger dynamically if needed.

You programmatically update\create the Triggers Area entries 'later' inside the trigger involved with set trigger mode=update and feed it what's needed. http://commandlua.github.io/#ScenEdit_SetTrigger
Now sometimes finding all the options that are available or exact option name or format can be tricky, it's best to just create a sample trigger with the gui and in the lua console interrogate the options names and cases\spellings.
ev = ScenEdit_GetEvent('EventNameHere')
print(ev.details.triggers); --dump the triggers to see what's available

There are some samples as I recall buried in the Legion for dynamically creating detection trigger events, keywords would be UnitDetected targetfilter.
https://www.matrixgames.com/forums/tm.asp?m=4973762
https://www.matrixgames.com/forums/tm.asp?m=4986324

If you need to create your own area trigger system, you could do that too (I don't think this applies to your needs - just saying). You do that by looking yourself who's inside a given area at timed intervals say every 15sec, and keeping track (if needed) of what shows up and what disappears 'detect' arrival, presences, and exit. But that's all custom code and as extensive or as light as you need it to be. Basically you end up creating your own little event system. There you can make use of sideWrapper:unitsInArea().
http://commandlua.github.io/#wrapper_Side

Another option if that doesn't work for you is you can search the forums for an InPolygon function and example usage I posted a while ago. It actually what lead me to the request the addition of what became side:unitsInArea. I use the side:unitsInArea option when ever I need area and pre-filtering, and still use the pure Lua InPolygon for quick checks for 'is something in side something else' as I can avoid needing a side wrapper and RP's entirely and just feed numeric lat\lons. Each has it's place. But random shout out to Michael again for adding unitsInArea.

Parel803
Posts: 941
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: AutoDetect UnitEntersArea Event

Post by Parel803 »

KnightHawk, thx again for your time and help
with regards GJ
Post Reply

Return to “Lua Legion”