Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Checking Sensor Arcs

View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Checking Sensor Arcs Page: [1]
Message << Older Topic   Newer Topic >>
Checking Sensor Arcs - 8/19/2021 10:45:49 AM   

Posts: 36
Joined: 9/3/2019
Status: offline
Is there a way to check the arcs for a sensor through the console? If I am changing multiple units default sensor arcs I like do to a quick 'idiot check' to ensure I've added a new sensor correctly. For example if I add an ALQ-99 to an EA-6B with custom arcs using Sensors -> Add Sensor through the GUI, I haven't found a way to go back and check what I have done at a later time.

The best I can get for sensor description through the console is, example again:
local u = ScenEdit_GetUnit({name='EA-18G Growler', guid='ActualUnitGUID'})
print( u.sensors[8] )
this returns:
{ sensor_isactive = 'Yes', sensor_name = 'AN/ALQ-99F-V [EA-18G C2W]', 
sensor_guid = 'ActualSensorGUID', sensor_status = 'Operational', sensor_role = 4001, 
sensor_maxrange = 0, sensor_type = 3002, sensor_dbid = 1901 }

< Message edited by Struan76 -- 8/19/2021 1:17:33 PM >
Post #: 1
RE: Checking Sensor Arcs - 8/19/2021 1:19:54 PM   

Posts: 36
Joined: 9/3/2019
Status: offline
Here's how I'm adding a test OECM sensor:
-- setup Growler arcs
local u = ScenEdit_GetUnit({name='EA-18G Growler', guid='ActualUnitGUID'})
-- need to work out how to remove default loadout sensor for above
ScenEdit_UpdateUnit({guid=u.guid,mode='add_sensor',dbid=1901,arc_detect={'PB1','PB2','SB1','SB2'},arc_track={'PB1','PB2','SB1','SB2'}}) -- this is frontal 45deg sector only
-- don't know yet how to check the above arcs are active
u.obeyEMCON = false;    --Unit will not use emcon setting [required].
local s = {sensor_guid=u.sensors[8].sensor_guid, sensor_isactive=true, sensor_status='Operational'};
u.sensors = s;    --Apply changes for that specific sensor (turn on in this case)
print( u.sensors[8])

(thanks to KnightHawk75 for second half of above code)

< Message edited by Struan76 -- 8/23/2021 1:33:37 AM >

(in reply to Struan76)
Post #: 2
RE: Checking Sensor Arcs - 8/20/2021 3:45:51 AM   


Posts: 1403
Joined: 11/15/2018
Status: offline
I don't know if you 'get' the arcs per-say, but since you're adding a sensor with specific ones, i'm not sure what you mean by check if the above arcs are active. I guess you mean if you say added several, and wanted to only activate certain ones it would be helpful if sensor object had sensor_arctrack sensor_arcdetect fields so you could maybe delineate between several otherwise duplicative entries.

That said as is, nope. I've always in cases of same sensor entries had to relay on index in the sensor table, which in my experience has been consistent in the .sensors returns, but then I have to remember in code index#Y is 0-30d and index#Z is 30-60 etc. You can determine index (or sensor_guid) and save it via say getting sensors by for instance only by specific dbid's into a new table adding an additional field called realindex and tacking the real overall index onto it. Then re-get the same for the sensors table after the successful updateunit() call and then you can find the difference between the tables to find the newly added entry and it's realindex(or sensor_guid), and then store that for later use in a global table you have for storing extra data per unit that you care about.
Yeah it's way more involved then it should be but it works.

Can provide some pseudo\example code for all that if need be.

< Message edited by KnightHawk75 -- 8/20/2021 4:06:53 AM >

(in reply to Struan76)
Post #: 3
RE: Checking Sensor Arcs - 8/20/2021 5:46:30 AM   

Posts: 36
Joined: 9/3/2019
Status: offline
Thanks KH, if you are able to put up some sample code that would be great. IDK how to access the index in the sensor table..

(in reply to KnightHawk75)
Post #: 4
RE: Checking Sensor Arcs - 8/21/2021 12:52:38 PM   


Posts: 1403
Joined: 11/15/2018
Status: offline

IDK how to access the index in the sensor table

I bet you do, probably just over thinking what I mean.
local u = SE_GetUnit({guid=someguid}) --get unit.
u.sensors[1] -- access the first index\key in the sensors table. assuming there is at least 1
u.sensors[2] -- access the second index\key in the sensors table assuming there is at least 2
u.sensors[#u.sensors] --access the last index\key in the sensors table assuming there is at least 1.
-- sensors can change position as you remove odd ones, add new ones etc.

So I went little further that just some code, here is working scene example uses mainly sensor guid tracking more than indexes anyway (though the index can be handy at times so it saves that too).

Load the Individual_Sensor_Addressing.scen in the editor. You will be on side Blue, there are no units.
Load up your \Logs\LuaHistory ... you should see a bunch of successfully loaded xxxx.lua messages. If you don't we got problems. Then set your map settings to show all unit radars.
Press special action button. Press the 'Add USS KH2'. Now is good time to re-open that log and see what it just did. Press play. Wait at least 5 seconds. Watch the pretty radars flicker and change ever 5 seconds. Amazing what's so special about that?

Well it's that it's being done not by randomly picking a entry, but by randomly selecting based on extra data, in this case an arctype code, and finding the sensor with that arc on that unit. Part of the process after unit creation runs through the unit, removes the 3 spy radars that are there by default, and replaces them with 4 6051's variants. During each one of those add's is when the 'magic' happens in that we associate an arctype with each guid and new index and we store that for later use. In a nutshell that's really it.

People often ask for the code in text file form, with that in mind I implemented things such that that everything loads from the \Lua folder inside the included scene folder. This makes editing with external editors very simple while keeping things organized, the only thing embedded in the .scen is what has to be, the bootstrap code to load the scripts, and 1/2 a dozen lines total between the events and the special action.

Attached is it contains
Individual_Sensor_Addr_InstallationNotes.txt - just tells you to drag\drop SensorAddressingScene in anywhere under main Scenarios folder. It's important.
\SensorAddressingScene Folder - The folder containing the scene
\SensorAddressingScene\Individual_Sensor_Addressing.scen - The Scene file.
\SensorAddressingScene\Lua - Critical sub-folder containing 99% of the code.
\SensorAddressingScene\Lua\gKH.lua -- Couple of lines (stripped bare for this scene)
\SensorAddressingScene\Lua\gKH_base.lua - Couple dozen lines. (stripped bare for this scene)
\SensorAddressingScene\Lua\State.lua - Coupe hundred lines (but you can almost completely ignore it)
\SensorAddressingScene\Lua\SensorTracking_5064771.lua - The meat ~600 lines.

Don't freak out, of the total ~900 lines involved, 50% are comments another 25% probably error\parameter checking code.

SensorTracking_5064771.lua has a lot of information in comments as to what is going on and explicitly calls out the 3 main functions that relate to 'grabbing' the data you need, which may be all you are really interested in or need. ALL the rest is really just related to storing, and managing that data as well as "putting it to use" in the form of the radar flipper. I hope it's at least remotely similar to how you may be trying to use it. It does other stuff too like handle saving that "storage" and re-loading it on startup if you create a save file from it after you've added the unit etc.. again stuff you may not need, but a full-working example is better imho then just 3 functions thrown at you.

Scene Requires: DB3k 489, build 1.03.1147.29+

Attachment (1)

< Message edited by KnightHawk75 -- 8/21/2021 1:02:45 PM >

(in reply to Struan76)
Post #: 5
RE: Checking Sensor Arcs - 8/23/2021 1:19:24 AM   

Posts: 36
Joined: 9/3/2019
Status: offline
This is quite awesome...

Will take me a few days to work through this and understand it all!

(in reply to KnightHawk75)
Post #: 6
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Checking Sensor Arcs Page: [1]
Jump to:

New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts

Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI