Page 1 of 1

Question about ScenEdit_AssignUnitToMission

Posted: Wed Mar 22, 2023 11:13 am
by Zyph
Hello,

How do i assign units to mission if i utilize '..math.random' for unit names?

for x = 1, 4, 1 do
local name = 'GrandMaster HSM 46-'..math.random(100,999)
local proficiency = math.random(1,3)+1

ScenEdit_AddUnit({type ='Aircraft', name =name, loadoutid =29537, dbid =273, side ='USA', base="George Bush", HostUnit="CVN", proficiency=proficiency})
end

local missionReferencePoints={'R45-02'}
local mission = ScenEdit_AddMission ('USA', 'Heli CSAR', 'Support',{type= 'AAW',zone= missionReferencePoints,StationThrottleAircraft='8', StationAltitudeAircraft='900 ft', OneThirdRule=true})

--This is where i need help, now its looping for unit 1, 2, 3, 4 but i think the randomize above corrupts it??
for i = 1,4 do
ScenEdit_AssignUnitToMission( "GrandMaster HSM 46-", "Heli CSAR" )
end

Re: Question about ScenEdit_AssignUnitToMission

Posted: Wed Mar 22, 2023 11:56 am
by blu3s
Zyph wrote: Wed Mar 22, 2023 11:13 am Hello,

How do i assign units to mission if i utilize '..math.random' for unit names?

--Declare your mission first--
local missionReferencePoints={'R45-02'}
local mission = ScenEdit_AddMission ('USA', 'Heli CSAR', 'Support',{type= 'AAW',zone= missionReferencePoints,StationThrottleAircraft='8', StationAltitudeAircraft='900 ft', OneThirdRule=true})

for x = 1, 4, 1 do
local name = 'GrandMaster HSM 46-'..math.random(100,999)
local proficiency = math.random(1,3)+1

local unit = ScenEdit_AddUnit({type ='Aircraft', name =name, loadoutid =29537, dbid =273, side ='USA', base="George Bush", HostUnit="CVN", proficiency=proficiency})
ScenEdit_AssignUnitToMission(unit.guid,'Heli CSAR')


end