Targets to missions

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
wqc12345
Posts: 176
Joined: Mon Dec 07, 2015 2:56 pm
Location: San Francisco, CA

Targets to missions

Post by wqc12345 »

Hi Everyone,

For some reason I cannot get targets to be added to a mission that I generate via Lua.

local mission = ScenEdit_AddMission ( 'RAF', 'RAF Nairobi Strike', 'strike',{ type = 'land' })

The method > ScenEdit_AssignUnitAsTarget({'target1','target2'},mission.name) does not add targets to the mission
I'm assuming this is the wrong target assignment (for something else)

So, I went down the ScenEdit_SetMission method and I can't get anything to work.

ScenEdit_SetMission(mission.side, mission.name,{strikeFlightSize=3}) works

Under the mission wrapper, there is a targetlist table, but nothing works.. using GUIDs, or names, ?? Does anyone have an example of adding targets to a land strike mission? The targets being on the opposing side.
User avatar
michaelm75au
Posts: 12467
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Targets to missions

Post by michaelm75au »

ScenEdit_AssignUnitAsTarget({'target1', 'target2'}, 'Land strike')
This should work.
Can you supply a save so I can see what's up.
Michael
User avatar
michaelm75au
Posts: 12467
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Targets to missions

Post by michaelm75au »

Console:
local m = ScenEdit_GetMission('sidea','test strike')
print(m.targetlist)
local x = ScenEdit_AssignUnitAsTarget({'ammo shelter','4503e1fa-b6be-43c0-87bf-a602dded4001'}, 'test strike')
print(x)

{ [1] = 'c866539a-664c-48b2-88e3-be8e32514320' }
{ [1] = '73a4a4a5-377a-4454-b840-7a2da0840f7d', [2] = '86dcde75-1516-4c92-8e60-59388b0350e7', [3] = 'cd74546f-2cc2-4617-ada1-cccdd3830ed1', [4] = 'b8a6a828-8190-46e2-9136-caa99c88e9cf', [5] = '818de559-cc06-4bcb-972d-48a3cee304f8', [6] = '5f7cf19a-8818-4e7e-aad1-02a3425c79f1', [7] = '1d059408-f889-4773-af68-cb48b8230967', [8] = '067ac085-a6d0-4b33-a2d5-03b4b0f02a04', [9] = '4d13b7be-2a32-47bf-9673-744d277dbec0', [10] = 'c638b7b1-aa7a-48aa-b9bc-cb16b90b1cac', [11] = 'fb305cc0-ccd5-4bef-98f3-260bcee6ecc8', [12] = '2d315183-fe39-47da-8839-3604f13ee5ba', [13] = 'cdac6218-fe86-45e7-ada8-3b46a3772aad', [14] = 'f0e312fc-45e9-4ceb-8495-d948cd6e85aa', [15] = '19aaa581-1cfc-439c-b6cc-88b72d15532a', [16] = '80cbcb64-b9b5-4cb2-b232-b90970c415e5', [17] = '51b66b9e-5eff-4ef7-9a09-451162fef724', [18] = 'ae35d4a3-fb49-4644-a241-e9bcbc0a3908', [19] = '375cb220-9d82-4230-9bec-e598d4decbcf', [20] = '88e718b5-96df-4f0c-93a9-3b0fda9851d3', [21] = '5a354446-0a66-4809-8d35-5e572fa4d659', [22] = '7d3e1ad0-297b-4c1c-9856-ecfd863f8e9c', [23] = 'f86a4357-222b-486d-9bac-2f4bc9acc022', [24] = '60db3f67-4f84-4e10-b685-462c7ffcd5cf', [25] = 'abe5c909-2c82-4ea1-ae11-6bff206e72eb', [26] = 'ec7be4cf-723e-428a-9c67-378ce104b96b', [27] = '1b14599e-30a8-42c9-a69b-1d89eef1d9cf', [28] = 'fe3d233d-b3c9-409c-a21a-8046a6733aa4', [29] = '8d46bab4-d701-4596-8c01-42fe17d6d2a2', [30] = '0bd9a3f2-61ce-4cae-9f8a-2de5569f4dd6', [31] = '8d2beaf7-d2d9-4587-a7c7-ea03e129eacb', [32] = 'be648d92-c8f8-46ef-b01d-280381e20871', [33] = '39fbfc66-f63d-4556-9087-6b53661c0726', [34] = 'bf774525-acd2-4e8b-96fe-69f3333ba657', [35] = 'f35a727c-2dba-4e87-93d1-904162b22e5d', [36] = 'c7718d65-f432-4bc2-bd1a-69d029b3e304', [37] = '2b4246e7-6f04-4bc9-97f3-3a760b0fe9aa', [38] = 'fdbae461-128d-4daf-a360-a9348b95bc50', [39] = '11bda400-5b7f-4e98-b588-b01ef5cf5c7a', [40] = 'd37352ad-ac08-40e8-b4ca-fd2734c8f0cb', [41] = 'ef75848a-ca6a-4777-931f-4e58972f0292', [42] = '4ef5593b-a5cd-43e6-bf8e-3087b4c95db2', [43] = '46360dcb-5399-4642-aba6-e5fa469c22e1', [44] = '828d6486-d93f-407f-9395-2ac5cdc18bd8', [45] = '4d598002-f001-4853-89ed-13b49adb4fcf', [46] = '7ea1beb7-70c6-4149-9119-3054c70dd16e', [47] = 'bbc82c07-18d3-4a7e-b286-294f558a62f2', [48] = 'cb730228-07c4-4449-97a2-43d1241e4d07', [49] = 'eca93b01-79a5-4d10-99fc-2f2f1845e0ab', [50] = '237a4fe3-3a46-4cd8-b164-f8ce9f9d87bc', [51] = 'b6df656d-1e54-43c2-9961-cb01521214fa', [52] = 'aebf2cac-a7a8-4bdc-b17d-8bbb0c939a5e', [53] = 'fa7cec0c-dd67-494f-8833-7311e921aebb', [54] = '40935dd4-d9db-4fba-bdc9-3debecbc6f06', [55] = '7cc6b4c9-278c-4213-9ab7-3889823ec568', [56] = '6268d681-b4c6-4240-b73d-37104d557d3f', [57] = '36448b2c-5aad-46a4-8be4-ef7e3683cb9b', [58] = '2894737f-7836-4097-a538-a3bcbb598ae0', [59] = 'b0a9d8ef-4949-4d23-ac81-002396622277', [60] = '2f53d855-aa6a-4296-811a-6c1778b49912', [61] = 'fb1433be-29a6-4e12-a751-50a23479b252', [62] = 'fbe4fbc4-e2d3-4862-867f-f21944fe42b0', [63] = 'bc43172c-964c-407f-af67-ec85b06de8fa', [64] = '18846b9a-b431-4222-8e24-1fe284477023', [65] = '47c11b00-9011-45ed-928b-a70408bdf2f2', [66] = 'f5311eca-1312-4c23-8ce6-f67414ec6b1f', [67] = '091e51a6-8a87-4bc9-9769-fbdcd59cd69e', [68] = 'be36b2a6-3411-4e55-bf8c-323ca6064481', [69] = '7d9177eb-f325-467a-9213-e74e952a9a44', [70] = '06b41d05-1ebd-480f-8b10-b74609457721', [71] = '297ea2f1-36cc-4642-8314-67578264e4a9', [72] = '5d009be7-6793-4f73-b220-215922955e94', [73] = '211b50ee-3d31-475c-bfe2-0daa434f6481', [74] = '35e92e2d-416a-4ed8-967c-3c05397bcdd5', [75] = '679e1a0f-6ca1-497d-844b-6e2ffeac0d65', [76] = '038f9321-792f-431e-894e-c2e0ccb03d3c', [77] = 'cf79a24e-1663-41f4-aca5-7853e07bec58', [78] = '0a1f0d15-22d1-46fa-846e-969344ff06c2', [79] = '857d1ada-54cf-43a5-baba-665ea3ec32cc', [80] = '4042ad08-ceeb-4ce0-b5b8-0244414d6ae1', [81] = '53dd3478-2499-41b5-a56e-b3b1a7470ccd', [82] = '0507cd51-7ab3-4588-87de-c216d13ef38f', [83] = '9766a30a-2246-4f5f-b09d-fddfa1e301ef', [84] = 'f4723e92-b340-4910-881b-ea6ab199d53b', [85] = '392acfdc-f6ee-4f38-bb7d-9b38f511e3fd', [86] = '572e37c6-ca7d-444b-a452-420b70986587', [87] = 'ccd2c7fc-c489-4e70-8854-7e418a9d15dd', [88] = '3d4d776b-6640-40f1-9cf6-a7e1b3acd365', [89] = '5d9bb7dd-d3da-4f19-93cd-c204b46a6dca', [90] = 'fbd13920-8888-4673-a999-fbcf7d074c31', [91] = '3c1c1895-303a-4bd1-8db0-1cf2bcbd02e3', [92] = '09a41cca-9aad-4ef8-a0ca-806392aaa52d', [93] = '613f33e2-fbf4-4bdc-94bd-92041afa73fd', [94] = 'c464145b-8e54-4973-af51-ecd5d4793e9b', [95] = 'cfdd1269-8ed8-4f4e-b9a8-616e8050397e', [96] = 'ea478ce1-5ebc-42cf-8616-ef1ebb016391', [97] = 'd0cbc435-6e73-47ed-8cb3-2898ca991fb4', [98] = 'd4410aff-3353-4f0d-84b5-1c0f9eb3eeda', [99] = '7bc50f99-172b-47c1-abb5-84c2115c1be9', [100] = '2c5949c6-25ca-4dd9-bd0e-fb1a6a4bfcac', [101] = '4c1ed1c4-3827-4292-9b4c-8f21e787fd42', [102] = 'ca610273-3ed5-44cc-8ff6-7d4a1d7a7978', [103] = '11427143-b75a-45cf-a1f6-4e726a44c660', [104] = '70dbb45f-58f7-48fc-b4b6-a86b9746b1c3', [105] = '32e1002c-4b63-4dd8-9b27-34712bb5bb9e', [106] = 'f2c7e636-6d22-4b3f-a5ee-5d31e2d942ae', [107] = 'ffacde75-8a0f-4df9-8682-1b00c7e80b90', [108] = 'e1fb079b-c43a-44dd-bdb8-55344025e0f1', [109] = '63fa9fc6-f9b9-4e0b-979a-0d5535b3f54d', [110] = '569653fe-c149-41a4-86ac-d826f4c482c1', [111] = '70cdfee9-6f11-4552-ac8b-47d6482f7050', [112] = '57c85a68-c09f-4f87-9d0b-5c307e9db403', [113] = '62c2aa4d-84c1-44a5-8a51-bed37bbcc896', [114] = '6bd37745-ef5a-4206-8afe-36a0075a812d', [115] = 'fbac61af-8b4f-452b-a732-9c12222b91f7', [116] = '7c18ba1f-03b9-4417-a984-ec2805f16e7a', [117] = 'b066fb2d-a7ae-4805-b173-6e2ee77ce943', [118] = 'dc5e3971-02c1-41c5-90fc-cbe09164d18a', [119] = 'c2c242eb-2dfb-4384-8528-41bcac325137', [120] = '403ab502-c030-48d5-af11-b850da695be0', [121] = 'd9c25aaf-6dc7-4281-9c56-ee93fac79bd1', [122] = '4509b449-a24d-48ba-b12f-2c95b3cd1011', [123] = '2bb49852-6c92-4e3d-96ac-896caeced0b9', [124] = '6e4fde1e-388d-4c99-a804-925abf1e367e', [125] = '7776bc29-af93-4516-a65a-f6192ad83a9a', [126] = 'c5a62418-485f-4026-a214-b5b85a0d87c5', [127] = '2e4cf799-860d-4d0d-931d-373749e1a2ac', [128] = 'fd9d0a10-1e8b-40f4-b204-d712f6bfa50d', [129] = '7fa2e2ba-b53e-4b01-aeea-a994fd3ec91f', [130] = 'b2ca8582-ccc7-4cb3-8c53-06d5ec1afc69', [131] = '5ed599ce-4e6a-42bc-a014-3d95b9af30f0', [132] = '7ca1847a-f06a-45fe-a7cf-7352e043005f', [133] = '7203234f-418d-43ae-8748-8535c08d684b', [134] = '56a49830-b83c-4720-9d03-441648cb63f2', [135] = '330d4dae-cd1d-4de5-b5a9-0929f9fb5173', [136] = '1e883864-73cb-417d-8b26-d61f322e7bdf', [137] = '0472fe65-2a2e-415a-86a8-652329414402', [138] = 'b8b7a9f7-da06-4947-8fea-9cc63ea7fef1', [139] = 'db928f8c-f352-49c5-8ab5-61f2bcc04876', [140] = '8fe19ca1-16c8-4af9-9451-6f7e88fa9204', [141] = 'be54a9c4-3b10-4f07-acc2-1b2d16b30ff7', [142] = '3a7145af-0cb8-4ebd-9c3a-303173b751e2', [143] = '2d9eccc8-dc25-438f-9df6-b0f970a0ab32', [144] = 'f9ea83bf-fa39-48f0-ad77-a4d03b1169e3', [145] = '645e800e-ac3d-424f-90dd-233765b03d8d', [146] = '2092cd68-5e0b-437b-b781-6138b6da9649', [147] = '800411c9-3b93-4bbb-b90a-506b3e62d4a8', [148] = '867fc172-19ef-4933-84e0-8a06c00eeee7', [149] = '6ae628da-115f-477c-bd57-ba7b71dc01e0', [150] = 'c34eff48-3436-478e-bb1c-20ecf8ef97db', [151] = 'b2138aa3-3c2b-4505-bbd0-c13e836efa2f', [152] = '9315ee23-a617-4990-a96a-3a5cd4dfbf26', [153] = '14dd7615-c6bb-47dd-930c-2fe1c08abcea', [154] = '819b4030-4705-431b-af49-c0a73646fa7e', [155] = 'dd2d81e7-9d86-4413-9c15-240a2c3cec2c', [156] = 'e0ec4f6f-efbc-4326-81f0-004afe1ddaf7', [157] = 'b319901d-221c-4502-a45e-1911d4a1fc7b' }
...
Michael
User avatar
wqc12345
Posts: 176
Joined: Mon Dec 07, 2015 2:56 pm
Location: San Francisco, CA

RE: Targets to missions

Post by wqc12345 »

Hi Michael, thanks as always for replying.

Attached is the save. I'm making a script to build the entire scenario (setup.lua). So, this is the built file.

I'm at the point in the script where running > ScenEdit_AssignUnitAsTarget({'Runway 1', 'Ammo Pad 2'}, 'RAF Nairobi Strike')

Results in NOTHING. No targets are added to the mission. Nothing.

Let me know.
Attachments
TestScenarioCode.zip
(60.14 KiB) Downloaded 17 times
User avatar
wqc12345
Posts: 176
Joined: Mon Dec 07, 2015 2:56 pm
Location: San Francisco, CA

RE: Targets to missions

Post by wqc12345 »

I think it's a bug..

I can get the group to assign, but not the units in the group.. very odd.

local m = ScenEdit_GetMission('RAF','RAF Nairobi Strike')
print(m.targetlist)
local x = ScenEdit_AssignUnitAsTarget({'Nairobi Air Force Base (KDPA)'}, m.name)
print(x)

Works..

local m = ScenEdit_GetMission('RAF','RAF Nairobi Strike')
print(m.targetlist)
local x = ScenEdit_AssignUnitAsTarget({'Runway 1'}, m.name)
print(x)

Does not.
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Targets to missions

Post by KnightHawk75 »

You have more than 1 'Runway 1' in the scene.

local m = ScenEdit_GetMission('RAF','RAF Nairobi Strike')
print(m.targetlist)
local x = ScenEdit_AssignUnitAsTarget({'Runway1's_GUID_HERE'}, m.name)
print(x)

Does work, so maybe ambiguous name because RAF also has a 'Runway1', it can't tell which one you want so it does nothing. Maybe in the script setting up the airports include the side in the name if you want to use names so it's like RAF_Runway1...etc that way it's more unique.

That or just get the guid for the unit in question prior to the assignment call and use that.




User avatar
michaelm75au
Posts: 12467
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Targets to missions

Post by michaelm75au »

There is a defect I found this morning while looking at something else where the contact id is not being validated against the 'base contact' list (only the units). If it is a base group, it should be expanding to the units.
The example I showed above (which is a grouped airfield) was actually after I fixed the contact validation issue.

Using actual unit names should working, but as you have seen, if there are multiple units with the same name, then that will cause issues with any function.

Using GUID for units (or almost anything) where possible is 'best practice' and helps to eliminate runtime issues. The other way is to uniquely name every unit[8D].
Michael
User avatar
michaelm75au
Posts: 12467
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Targets to missions

Post by michaelm75au »

ORIGINAL: wqc12345

I think it's a bug..

I can get the group to assign, but not the units in the group.. very odd.

local m = ScenEdit_GetMission('RAF','RAF Nairobi Strike')
print(m.targetlist)
local x = ScenEdit_AssignUnitAsTarget({'Nairobi Air Force Base (KDPA)'}, m.name)
print(x)

Works..

local m = ScenEdit_GetMission('RAF','RAF Nairobi Strike')
print(m.targetlist)
local x = ScenEdit_AssignUnitAsTarget({'Runway 1'}, m.name)
print(x)

Does not.
As KH mentioned, there are 2 units with the same name 'Runway 1'. It should have picked the first one it found, but if that was for mission's side, then it would have ignored that entry as you can't target yourself.[:D]
Michael
User avatar
wqc12345
Posts: 176
Joined: Mon Dec 07, 2015 2:56 pm
Location: San Francisco, CA

RE: Targets to missions

Post by wqc12345 »

Makes total sense and I thank you both.. just tested and it worked flawlessly.
Post Reply

Return to “Lua Legion”