Atari800XL Posted September 20, 2023 Posted September 20, 2023 (edited) Hi, I'm learning MOOSE and have actually a logical problem (hopefully): -- Defined random spawns of ground-units for weapontraining: -- MOOSE: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Spawn.html knownSpawnZones = { ZONE:New("TANK_SPAWN_1") , ZONE:New("TANK_SPAWN_2") , ZONE:New("TANK_SPAWN_3") } spawnPlan = { -- { quantity, templateName, target zone } { 1 , "TGT_Tank1" , "TANK_SPAWN_1"}, { 2 , "TGT_Tank1" , "TANK_SPAWN_2"}, { 5 , "TGT_Tank5" , "TANK_SPAWN_3"} } totalSpawns = 0 for i,plan in ipairs(spawnPlan) do q = plan[1] local templateName = plan[2] local targetZone = plan[3] local tmpTargetSpawnZone = ZONE:New( targetZone) local dbgMess = MESSAGE:New( i .. ": " .. tostring(q) .. "x " .. templateName .. " randomly in " .. targetZone):ToAll() local tmpTargetSpawnZone = ZONE:New( targetZone ) --[[ tempTank = SPAWN:New( templateName ) :InitLimit( 3, 3 ) :InitRandomizeRoute( 1, 1, 200 ) :SpawnInZone( tmpTargetSpawnZone ) :Spawn() --]] totalSpawns = totalSpawns + q end dbgMess = MESSAGE:New( tostring(totalSpawns) .. " tanks spawned"):ToAll() Every template and zone exists in my mission, the defined templates should be useable over the whole spawnPlan, not only one time. (duplicate template before instancing?) My Problem: during the iteration over the table spawnPlan every time my last spawned tank is overwritten so finally only one tank appears (but all dbgMess are displayed so the iteration runs through). My Question: is there a kind of queue, a stack or something like that where I can push my tempTank and the DCS-engine makes the rest? Or any other MOOSE-workflow for this iterated spawns? Thanks and best regards, Andreas Edited September 20, 2023 by Atari800XL DCS MT, all maps except channel, FC3, F-16C Viper, F-15E, F/A-18C, AH-64D, F-5E, F-4E, P-51D, Spitfire, Fw-190D, MiG-21bis, L-39, AJS-37 Supercarrier, WWII-AP, CA, TrackIR5, F/A-18-Stick + Thrustmaster 16000, Stream Deck 8x4, 2x MFD Cougar Ryzen9 5950X SMT off, 64GB RAM, RTX 4070 SUPER TI, UWQHD 3440x1440, Win11+DCS from separate M.2
Atari800XL Posted September 20, 2023 Author Posted September 20, 2023 I tried to copy my tank-template but this also fails: local master = GROUP:FindByName( templateName ):GetTemplate() local tempTank = SPAWN:NewFromTemplate( master ,"Tank") DCS MT, all maps except channel, FC3, F-16C Viper, F-15E, F/A-18C, AH-64D, F-5E, F-4E, P-51D, Spitfire, Fw-190D, MiG-21bis, L-39, AJS-37 Supercarrier, WWII-AP, CA, TrackIR5, F/A-18-Stick + Thrustmaster 16000, Stream Deck 8x4, 2x MFD Cougar Ryzen9 5950X SMT off, 64GB RAM, RTX 4070 SUPER TI, UWQHD 3440x1440, Win11+DCS from separate M.2
Solution Atari800XL Posted September 20, 2023 Author Solution Posted September 20, 2023 Solved, the following code makes it: (maybe useful for other MOOSE beginners) -- ###LUA!### <-- Token to search for in dcs.log in case of crashing script -- Defined random spawns of ground-units for weapontraining: -- MOOSE: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Spawn.html -- env.info( 'maybe some special token to set a tail on in dcs.log' ) knownSpawnZones = { ZONE:New("TANK_SPAWN_1") , ZONE:New("TANK_SPAWN_2") , ZONE:New("TANK_SPAWN_3") } spawnPlan = { -- { quantity, templateName, target zone } { 1 , "TGT_Tank1" , "TANK_SPAWN_1"}, { 2 , "TGT_Tank1" , "TANK_SPAWN_2"}, { 3 , "TGT_Tank2" , "TANK_SPAWN_3"} } totalSpawns = 0 for i,plan in ipairs(spawnPlan) do q = plan[1] templateName = plan[2] targetZone = plan[3] tmpTargetSpawnZone = ZONE:New( targetZone) dbgMess = MESSAGE:New( i .. ": " .. tostring(q) .. "x " .. templateName .. " randomly in " .. targetZone):ToAll() master = GROUP:FindByName( templateName ):GetTemplate() for ii = 1,q do local newAlias = "Tank-" .. i .. "-" .. ii local tempTank = SPAWN:NewWithAlias( templateName , newAlias) :SpawnInZone( tmpTargetSpawnZone , true) totalSpawns = totalSpawns + q end end dbgMess = MESSAGE:New( tostring(totalSpawns) .. " tanks spawned"):ToAll() DCS MT, all maps except channel, FC3, F-16C Viper, F-15E, F/A-18C, AH-64D, F-5E, F-4E, P-51D, Spitfire, Fw-190D, MiG-21bis, L-39, AJS-37 Supercarrier, WWII-AP, CA, TrackIR5, F/A-18-Stick + Thrustmaster 16000, Stream Deck 8x4, 2x MFD Cougar Ryzen9 5950X SMT off, 64GB RAM, RTX 4070 SUPER TI, UWQHD 3440x1440, Win11+DCS from separate M.2
Recommended Posts