Page 1 of 1

Add/Removing Data/Comm Links through LUA?

Posted: Mon Apr 02, 2018 9:14 am
by LHOANWG
This is this possible?

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

Posted: Mon Apr 02, 2018 11:43 am
by TitaniumTrout
I've used lua to disable/damage the radio systems to create an out of comms situation.

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

Posted: Mon Apr 02, 2018 12:23 pm
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.

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

Posted: Mon Apr 02, 2018 12:54 pm
by TitaniumTrout
What syntax are you trying right now for filterOnComponent?

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

Posted: Mon Apr 02, 2018 1:01 pm
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.

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

Posted: Mon Apr 02, 2018 1:41 pm
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' } }

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

Posted: Mon Apr 02, 2018 1:47 pm
by LHOANWG
Ah, it was the ":" that I was not using. Lua syntax calls methods differently apparently. Thanks for the help!

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

Posted: Mon Apr 02, 2018 1:51 pm
by TitaniumTrout
You're welcome. Share the scenario your working on, would love to see what you're planning.

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

Posted: Mon Apr 02, 2018 2:01 pm
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.

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

Posted: Tue Apr 03, 2018 6:46 am
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 ":".