Add/Removing Data/Comm Links through LUA?

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
LHOANWG
Posts: 5
Joined: Mon Apr 02, 2018 9:12 am

Add/Removing Data/Comm Links through LUA?

Post by LHOANWG »

This is this possible?
User avatar
TitaniumTrout
Posts: 469
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

RE: Add/Removing Data/Comm Links through LUA?

Post by TitaniumTrout »

I've used lua to disable/damage the radio systems to create an out of comms situation.
LHOANWG
Posts: 5
Joined: Mon Apr 02, 2018 9:12 am

RE: Add/Removing Data/Comm Links through LUA?

Post by LHOANWG »

that's a good work around. While we're on the topic, does anyone have any luck using the "filterOnComponent" method? Can't seem to get that to work. I am using it as a method of a Unit instance but maybe I am getting the input format wrong.
User avatar
TitaniumTrout
Posts: 469
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

RE: Add/Removing Data/Comm Links through LUA?

Post by TitaniumTrout »

What syntax are you trying right now for filterOnComponent?
LHOANWG
Posts: 5
Joined: Mon Apr 02, 2018 9:12 am

RE: Add/Removing Data/Comm Links through LUA?

Post by LHOANWG »

I've tried a number of different forms including:
Unit.filterOnComponent('Sensor')
Unit.filterOnComponent(type='Sensor')
Unit.filterOnComponent({type='Sensor'})
...
and several other forms. Was looking for someone who has successfully used the method.
User avatar
TitaniumTrout
Posts: 469
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

RE: Add/Removing Data/Comm Links through LUA?

Post by TitaniumTrout »

Code: Select all

local unit = ScenEdit_GetUnit({side="BLUFOR", unitname="MIG-21"})
 print(unit)
 print(unit.components)
 print(unit:filterOnComponent("Sensor"))

This returns :
unit {
type = 'Aircraft',
subtype = '2001',
name = 'MIG-21',
side = 'BLUFOR',
guid = '6d088198-4a5b-44a5-b87f-75da50f8cf8c',
proficiency = 'Regular',
latitude = '0.706202368990351',
longitude = '-2.44914023444803',
altitude = '10972.8',
heading = '0',
speed = '350',
throttle = 'Loiter',
autodetectable = 'False',
mounts = '1',
magazines = '1',
unitstate = 'Unassigned',
fuelstate = 'None',
weaponstate = 'None',
}
{ [1] = { comp_guid = '33dec6b3-3bef-4858-8c92-4aaf4b8cc31a', comp_type = 'Sensor', comp_status = 'Operational', comp_dbid = 887, comp_name = 'Jay Bird [RP-22M Sapfir-22]' }, [2] = { comp_guid = '6771ae2d-0e11-413a-9321-b1bf0cd7483d', comp_type = 'Sensor', comp_status = 'Operational', comp_dbid = 2750, comp_name = 'SPO-10 Sirena-3M' }, [3] = { comp_guid = 'fe11edda-9b00-4175-a83e-369157d354af', comp_type = 'Sensor', comp_status = 'Operational', comp_dbid = 0, comp_name = 'Mk1 Eyeball' }, [4] = { comp_guid = '721ecc1f-ca3d-42a7-b460-ef43829868c7', comp_type = 'Mount', comp_status = 'Operational', comp_dbid = 274, comp_name = '23mm Gsh-23L [200 rnds]' }, [5] = { comp_guid = '0231e457-4203-4dfc-81ce-5ff0068b6c58', comp_type = 'CommDevice', comp_status = 'Operational', comp_dbid = 20, comp_name = 'UHF/VHF Radio [Unsecure]' }, [6] = { comp_guid = 'f6058dbb-6ce0-4bb0-816b-04437e4a3e75', comp_type = 'Engine', comp_status = 'Operational', comp_dbid = 393, comp_name = 'R-25-300 #1' } }
{ [1] = { comp_guid = '33dec6b3-3bef-4858-8c92-4aaf4b8cc31a', comp_type = 'Sensor', comp_status = 'Operational', comp_dbid = 887, comp_name = 'Jay Bird [RP-22M Sapfir-22]' }, [2] = { comp_guid = '6771ae2d-0e11-413a-9321-b1bf0cd7483d', comp_type = 'Sensor', comp_status = 'Operational', comp_dbid = 2750, comp_name = 'SPO-10 Sirena-3M' }, [3] = { comp_guid = 'fe11edda-9b00-4175-a83e-369157d354af', comp_type = 'Sensor', comp_status = 'Operational', comp_dbid = 0, comp_name = 'Mk1 Eyeball' } }
LHOANWG
Posts: 5
Joined: Mon Apr 02, 2018 9:12 am

RE: Add/Removing Data/Comm Links through LUA?

Post by LHOANWG »

Ah, it was the ":" that I was not using. Lua syntax calls methods differently apparently. Thanks for the help!
User avatar
TitaniumTrout
Posts: 469
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

RE: Add/Removing Data/Comm Links through LUA?

Post by TitaniumTrout »

You're welcome. Share the scenario your working on, would love to see what you're planning.
LHOANWG
Posts: 5
Joined: Mon Apr 02, 2018 9:12 am

RE: Add/Removing Data/Comm Links through LUA?

Post by LHOANWG »

Right now I'm mostly developing unique Special Actions for future use in scenarios. So I'm just exploring how I can accomplish things through Lua.
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Add/Removing Data/Comm Links through LUA?

Post by michaelm75au »

ORIGINAL: LHOANWG

Ah, it was the ":" that I was not using. Lua syntax calls methods differently apparently. Thanks for the help!
Properties are indicated by ".", and methods/functions are indicated by ":".
Michael
Post Reply

Return to “Lua Legion”