Page 1 of 1

Mission Switch

Posted: Thu Mar 25, 2021 6:07 pm
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

RE: Mission Switch

Posted: Fri Mar 26, 2021 3:47 am
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

RE: Mission Switch

Posted: Fri Mar 26, 2021 6:07 am
by Gunner98
Thanks, I'll give that a try tonight.

B

RE: Mission Switch

Posted: Fri Mar 26, 2021 2:53 pm
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.