Mission Switch

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
Gunner98
Posts: 5998
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

Mission Switch

Post by Gunner98 »

I'm wondering if there is a slicker way of doing a mission switch for units.

I've been using the following type code which works quite well and is simple enough:

---------------
for i=1,2 do
if ScenEdit_GetUnit({Side='NATO Support', Name="No.101 Sqn RAF #"..i,}) ~= nil then
ScenEdit_AssignUnitToMission("No.101 Sqn RAF #"..i, "Tanker Kef")
end
end
--------------

I am setting up a series of mission where 3 different groups of bombers first marshal and then on a trigger switch to a strike mission. So it is easy enough to do 3 different commands as above but is there a way of saying:

All units assigned to Mission X change to mission Y?

Thanks

B
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Mission Switch

Post by KnightHawk75 »

All units assigned to Mission X change to mission Y?
Sure you can use the unitlist in the mission wrapper to pull the list of units to move.

Code: Select all

local missionX = ScenEdit_GetMission("NATO Support","Mission X")
 if (missionX ~=nil) and missionX.unitlist ~=nil then
   for key,value in pairs(missionX.unitlist) do  --each value is just a guid in this case. 
     ScenEdit_AssignUnitToMission(value, "Tanker Kef")
   end
 end
User avatar
Gunner98
Posts: 5998
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Mission Switch

Post by Gunner98 »

Thanks, I'll give that a try tonight.

B
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
User avatar
Gunner98
Posts: 5998
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Mission Switch

Post by Gunner98 »

Sure you can use the unitlist in the mission wrapper to pull the list of units to move.

Worked the charm! Thank you very much once again.
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
Post Reply

Return to “Lua Legion”