Caldera Posted November 24, 2023 Posted November 24, 2023 (edited) Hey All, I started looking into randomizing missions. But that is not my critical problem. I have created a test mission for the purpose of learning random spawn locations. I have also been trying to figure out how the "assert" command works, mostly to shorten my debugging time. The problems I am having is two fold. I can get "mist.respawnInZone" to work just fine by itself. I am using Test-01.lua to create this script. So from using this script my problems begin. Problems: I can not get "assert(loadfile("E:\DCS Scripts\Test-01.lua"))()" to work I am not able to despawn (deactivate) the unit created by Test-01 I have attached Test-01.lua and my test mission. I was hoping that someone might have the time to look at it and help me out. Thanks in advance, Caldera Test-01.lua RANDOM SPAWN IN ZONE TEST 01.miz Edited November 24, 2023 by Caldera
Grimes Posted November 28, 2023 Posted November 28, 2023 Triggers with groups/units manipulated by scripting can be unreliable. Best to do the scripting equivalent to perform a given action. local gp = Group.getByName('Rotary-1') if gp then gp:destroy() end The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Caldera Posted November 28, 2023 Author Posted November 28, 2023 Thanks Grimes, Any clue why my assert(loadfile... is not working? Caldera
Kanelbolle Posted November 29, 2023 Posted November 29, 2023 (edited) As far as i remember the path you are loading file has to have \\ and not \ Like this: assert(loadfile("E:\\DCS Scripts\\Test-01.lua"))() or you can put the path in like this [[E:\DCS Scripts\Test-01.lua]] And if not done, you have to open for IO and LFS by de-sanitizeing them in disk:\DCS World OpenBeta\Scripts\MissionScripting.lua (Comment them out) sanitizeModule('io') sanitizeModule('lfs') -- Do this at own risk, since it opens DCS scripts to read and wirte to your system. (Don't run other people's missions or join mp servers with them dezanitized) Edited November 29, 2023 by Kanelbolle WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/
Caldera Posted November 29, 2023 Author Posted November 29, 2023 (edited) OK! Grimes, Your script file works! But so far it only works once. Because I have gotten assert(loadfile to work I tested this after the first deactivation. Where I ran assert(loadfile again to re-spawn rotary-1 and that worked OK. But the script you provided no longer has any effect for deactivation of rotary-1. Does not really matter as I was just testing the script. Thanks again! Kanel, Using \ or \\ made no difference at all. So I tried [[<filename>]] and it works as expected. But I noticed that notepad++ doesn't like it and turns the text red (error?). Thanks again! Caldera Edited November 29, 2023 by Caldera
Caldera Posted November 29, 2023 Author Posted November 29, 2023 So I got this to work in my test mission. The premise is for an AH-64D mission where hostile infantry can re-spawn in multiple waves with logic to end the re-spawn madness. I have attached the mission file which I know by many standards is a bit clunky, but it works. I have also attached a track file showing multiple waves based upon unit death administered by the activation of some friendly Abram tanks. Select F10 and speed up time a bit. I also noticed that "mist.respawnInZone" does not work with non circular zones. Caldera RANDOM SPAWN IN ZONE TEST 01.miz SPAWN IN ZONE TEST 01.trk
Recommended Posts