TEMPEST.114 Posted March 5, 2023 Posted March 5, 2023 Here is the table I'm creating to spawn my aircraft. { ['taskSelected'] = true, ['modulation'] = 0, ['tasks'] = { }, ['hidden'] = true, ['units'] = { [1] = { ['alt'] = 166.12214660645, ['type'] = 'E-3A', ['alt_type'] = 'BARO', ['livery_id'] = { ['livery_id'] = 'nato' }, ['onboard_num'] = 999, ['name'] = 'DARKSTAR91', ['payload'] = { ['payload'] = { ['pylons'] = { }, ['fuel'] = '65000', ['flare'] = 60, ['chaff'] = 120, ['gun'] = 100 } }, ['speed'] = 0, ['callsign'] = { [1] = 5, [2] = 9, ['name'] = 'DARKSTAR91', [3] = 1 } } }, ['y'] = 13072.155273438, ['x'] = 9961.662109375, ['name'] = 'EMERGENCY_AWACS', ['communication'] = true, ['frequency'] = 309, ['route'] = { ['points'] = { [1] = { ['alt'] = 166.12214660645, ['type'] = 'TakeOffParking', ['action'] = 'From Parking Area', ['alt_type'] = 'BARO', ['x'] = 9961.662109375, ['y'] = 13072.155273438, ['task'] = { ['id'] = 'ComboTask', ['params'] = { ['tasks'] = { [1] = { ['enabled'] = true, ['id'] = 'AWACS', ['auto'] = true, ['params'] = { } }, [2] = { ['enabled'] = true, ['id'] = 'WrappedAction', ['auto'] = true, ['params'] = { ['action'] = { ['id'] = 'EPLRS', ['params'] = { ['value'] = true } } } } } } }, ['airdromeId'] = 6 }, [2] = { ['alt'] = 10667.999983785, ['type'] = 'Turning Point', ['action'] = 'Turning Point', ['alt_type'] = 'BARO', ['x'] = 58586.825139276, ['task'] = { ['id'] = 'ComboTask', ['params'] = { ['tasks'] = { [1] = { ['enabled'] = true, ['id'] = 'Orbit', ['auto'] = false, ['params'] = { ['altitude'] = 10667.999983785, ['speedEdited'] = true, ['pattern'] = 'Circle', ['speed'] = 180.05555578163 } } } } }, ['y'] = 166.12214660645 } } }, ['task'] = 'AWACS', ['uncontrolled'] = false } I have to give it all this data to create it and when added via 'coalition.addGroup()' it gets added to the mission and spawns. Everything is working. Thanks to everyone who helped me understand this along the way. ( @cfrag, @Morpheus @Chump, @Grimes, @SUNTSAG @PravusJSB and anyone I missed). However, later during my mission, my script needs to find this aircraft and get it's callsign, frequency and if it has any TACAN data. The way I was doing this for existing units was looking in env.mission and scraping that, however, as this newly spawned group doesn't exist in that table, I only have the functions provided by the api to get hold of this information. The problem is, that I can't find out how to do that. If I used Unit.getDesc() on the unit of this newly created group I get back this table: { ['speedMax0'] = 280.2799987793, ['massEmpty'] = 60000, ['tankerType'] = 0, ['range'] = 12247, ['box'] = { ['min'] = { ['y'] = -3.1141595840454, ['x'] = -26.12522315979, ['z'] = -22.957130432129 }, ['max'] = { ['y'] = 9.3631839752197, ['x'] = 21.747020721436, ['z'] = 22.924991607666 } }, ['Hmax'] = 12000, ['Kmax'] = 4, ['_origin'] = '', ['speedMax10K'] = 280.2799987793, ['NyMin'] = 0.5, ['fuelMassMax'] = 65000, ['speedMax'] = 280.2799987793, ['NyMax'] = 2.5, ['massMax'] = 148000, ['RCS'] = 80, ['displayName'] = 'e-3a', ['life'] = 60, ['VyMax'] = 10, ['Kab'] = 0, ['attributes'] = { ['Air'] = true, ['Refuelable'] = true, ['Link16'] = true, ['AWACS'] = true, ['NonAndLightArmoredUnits'] = true, ['Planes'] = true, ['All'] = true, ['Datalink'] = true, ['NonArmoredUnits'] = true }, ['typeName'] = 'E-3A', ['category'] = 0 } Which doesn't have any of that information I need in it. In fact, there seems to be no way in the Group class methods to get that information. What am I missing? Can anyone please help?
cfrag Posted March 5, 2023 Posted March 5, 2023 (edited) 11 minutes ago, Elphaba said: In fact, there seems to be no way in the Group class methods to get that information. What am I missing? When faced with a similar dilemma, I remembered that it was me whos pawned the group, so I had that information, I merely chose to discard it. Well, I do it no longer. when you are spawning a new group, clone the table before you spawn, and save it in your own 'mySpawns[]' table, and index them by group name. Now you can retrieve that information just as if you were scraping it. Note that it even easier if you don't modify the table that you scraped from the mission before you spawn your own group. In that case, all you need is a look-up table for the newly spawned group name on which mission group's table that was based on, and again you have access to that information. Edited March 5, 2023 by cfrag
TEMPEST.114 Posted March 5, 2023 Author Posted March 5, 2023 21 minutes ago, cfrag said: When faced with a similar dilemma, I remembered that it was me whos pawned the group, so I had that information, I merely chose to discard it. Well, I do it no longer. when you are spawning a new group, clone the table before you spawn, and save it in your own 'mySpawns[]' table, and index them by group name. Now you can retrieve that information just as if you were scraping it. Note that it even easier if you don't modify the table that you scraped from the mission before you spawn your own group. In that case, all you need is a look-up table for the newly spawned group name on which mission group's table that was based on, and again you have access to that information. Yeah, since I posted this question, I realised I would have to keep tables of all the units and groups I spawn by category and I've done exactly that. Sheesh... what a pain, just for lack of a few getters... Thanks as always @cfrag
TEMPEST.114 Posted March 5, 2023 Author Posted March 5, 2023 I've posted this. Heart (upvotes) might help:
PravusJSB Posted March 30, 2023 Posted March 30, 2023 the getCallsign method works on the unit object but I dont know of a way to get the radios info in Lua without storing yourself on creation. If you write a small spawn class as a wrapper it should make life easy for you. Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb
TEMPEST.114 Posted March 30, 2023 Author Posted March 30, 2023 8 hours ago, PravusJSB said: the getCallsign method works on the unit object but I dont know of a way to get the radios info in Lua without storing yourself on creation. If you write a small spawn class as a wrapper it should make life easy for you. I've solved it. I'm getting all the info I needed/wanted now, dynamically.
Recommended Posts