Using zones recorder in Reference Points Manager?

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
vonotha
Posts: 60
Joined: Thu Jan 19, 2023 2:28 am

Using zones recorder in Reference Points Manager?

Post by vonotha »

Do you plan to allow refering Zones defined in Reference Points Manager in the other interface elements that use Reference Point? And what about referencing these zones in the scripts?

The new Reference Points Manager is an interesting organization tool, with a great potential.

Simple issue example - cannot use a zone in a trigger:

area_manager.jpg
area_manager.jpg (129.1 KiB) Viewed 726 times

CMO v1.06 - Build 1328.18; Steam mode; Tacview and all modules except Falklands
vonotha
Posts: 60
Joined: Thu Jan 19, 2023 2:28 am

Re: Using zones recorder in Reference Points Manager?

Post by vonotha »

At least, it would be nice to be able to copy zone points, in order to use them elsewhere, either in another window, such as Trigger window, or in a script.

CMO v1.06 - Build 1328.18; Steam mode; Tacview and all modules except Falklands
vonotha
Posts: 60
Joined: Thu Jan 19, 2023 2:28 am

Re: Using zones recorder in Reference Points Manager?

Post by vonotha »

..or highlight points on the map, so they can be used in other dialog using zone restriction.

CMO v1.06 - Build 1328.18; Steam mode; Tacview and all modules except Falklands
User avatar
blu3s
Posts: 1400
Joined: Fri Jul 08, 2022 9:45 am

Re: Using zones recorder in Reference Points Manager?

Post by blu3s »

+1
vonotha
Posts: 60
Joined: Thu Jan 19, 2023 2:28 am

Re: Using zones recorder in Reference Points Manager?

Post by vonotha »

I've found out, there is a way to 'extract' managed zone for the use in script.

'Managed zones' are side's standardzones.

Below is a short managed zone extraction code (here I'm extracting a managed zone defined for 'Commercial' player):

Code: Select all

side = VP_GetSide({side='Commercial'})

print(side)

for i, zone in ipairs(side.standardzones) do
    print(zone)
end

zone = side:getstandardzone('C5TQUD-0HMO5L1PQ10FB') -- identified zone's ID; name should work as well

print(zone.area)
And the output:

Code: Select all

side {
 guid = 'C5TQUD-0HMO57O7Q80SH', 
 name = 'Commercial', 
 units = 'table', 
 contacts = 'table', 
 Chalks = 'table', 
}

zone {
 guid = 'C5TQUD-0HMO5L1PQ10FB', 
 description = 'Caspian Sea Basin', 
 isactive = 'True', 
 area = 'table', 
 type = 'Command_Core.Zone'
}

{ [1] = { name = 'RP-704', side = 'Commercial', longitude = 29.2810808866512, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10EO', highlighted = 'No', latitude = 41.4980152551635 }, [2] = { name = 'RP-705', side = 'Commercial', longitude = 28.2499996928011, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10EP', highlighted = 'No', latitude = 41.9970202899879 }, [3] = { name = 'RP-706', side = 'Commercial', longitude = 28.2252036988374, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10EQ', highlighted = 'No', latitude = 42.8253960571373 }, [4] = { name = 'RP-707', side = 'Commercial', longitude = 29.1665571093305, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10ER', highlighted = 'No', latitude = 43.6169943426325 }, [5] = { name = 'RP-708', side = 'Commercial', longitude = 29.2932146544567, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10ES', highlighted = 'No', latitude = 44.325809407106 }, [6] = { name = 'RP-709', side = 'Commercial', longitude = 30.0649241712034, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10ET', highlighted = 'No', latitude = 45.06519153102 }, [7] = { name = 'RP-710', side = 'Commercial', longitude = 30.4896720859324, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10EU', highlighted = 'No', latitude = 45.7547860088616 }, [8] = { name = 'RP-711', side = 'Commercial', longitude = 31.5729452287089, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10EV', highlighted = 'No', latitude = 45.7304968817137 }, [9] = { name = 'RP-712', side = 'Commercial', longitude = 32.2299991001035, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10F0', highlighted = 'No', latitude = 44.7399360020082 }, [10] = { name = 'RP-713', side = 'Commercial', longitude = 32.3180905169019, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10F1', highlighted = 'No', latitude = 43.8318883986565 }, [11] = { name = 'RP-714', side = 'Commercial', longitude = 35.4512817017141, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10F2', highlighted = 'No', latitude = 44.1424651512865 }, [12] = { name = 'RP-715', side = 'Commercial', longitude = 37.6235213462368, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10F3', highlighted = 'No', latitude = 44.0237269653835 }, [13] = { name = 'RP-716', side = 'Commercial', longitude = 40.4747026314371, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10F4', highlighted = 'No', latitude = 42.6102057237874 }, [14] = { name = 'RP-717', side = 'Commercial', longitude = 40.2979975838121, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10F5', highlighted = 'No', latitude = 41.6513934793672 }, [15] = { name = 'RP-718', side = 'Commercial', longitude = 38.9355781911279, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10F6', highlighted = 'No', latitude = 41.5072114213817 }, [16] = { name = 'RP-719', side = 'Commercial', longitude = 36.877947538288, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10F7', highlighted = 'No', latitude = 41.7430330226876 }, [17] = { name = 'RP-720', side = 'Commercial', longitude = 35.2711366638283, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10F8', highlighted = 'No', latitude = 42.2166498613831 }, [18] = { name = 'RP-721', side = 'Commercial', longitude = 33.0568682472099, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10F9', highlighted = 'No', latitude = 42.2021631867175 }, [19] = { name = 'RP-722', side = 'Commercial', longitude = 31.104206350506, locked = 'Yes', guid = 'C5TQUD-0HMO5L1PQ10FA', highlighted = 'No', latitude = 41.7062012233721 } }
Please let me know, whether there is another method.

CMO v1.06 - Build 1328.18; Steam mode; Tacview and all modules except Falklands
vonotha
Posts: 60
Joined: Thu Jan 19, 2023 2:28 am

Re: Using zones recorder in Reference Points Manager?

Post by vonotha »

There is one more operation required if one needs to use "managed zone" in unit:inArea method.

Since inArea requires list of points, they should be "dig out" from zone.area structure:

Code: Select all

managed_area = {}

for i, wp in ipairs(zone.area) do
table.insert(managed_area, wp.name)
end
And finally you can use:

Code: Select all

if *unit:inArea(managed_area) then ...
I'm far from Lua expert so I hope someone will show me a better way.

I desperately ;) needed managed area scripted control, and alternative of implementing Ray Casting algorithm (https://rosettacode.org/wiki/Ray-casting_algorithm) seemed worse.

CMO v1.06 - Build 1328.18; Steam mode; Tacview and all modules except Falklands
Post Reply

Return to “Lua Legion”