exnihilodub Posted April 25, 2016 Posted April 25, 2016 Hi. I just started mission building and learning MIST. I recently learned how to use respawnGroup for AI upon group death. But i was wondering, instead of creating a trigger for every unit I'd like to respawn, can I make it so that only 1 trigger handles respawning groups with a tag in their group name (for example RESPAWN_Transport1)?
Grimes Posted April 26, 2016 Posted April 26, 2016 The best way is to create a script that handles it. At its simplest you can use something like the following on a trigger that will continuously execute: local prefix = 'RESPAWN' for groupName, data in pairs(mist.DBs.groupsByName) do if string.find(groupName, prefix) then if (Group.getByName(groupName) and Group.getByName(groupName):isExist() == false) or (Group.getByName(groupName) and #Group.getByName(groupName):getUnits() < 1) or not Group.getByName(groupName) then mist.respawnGroup(groupName) end end end What this does is it iterates through the table mist.DBs.groupsByName and then uses string.find to see if the group's name contains the word 'RESPAWN'. If it does then it will do another check to see if every unit in the group is dead. There are 3 conditions that it checks with any of them being true results in running the script to respawn the group. There are other ways to do it, I just whipped that up in about a minute, mostly copied from other code. :) 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
exnihilodub Posted April 26, 2016 Author Posted April 26, 2016 hey thanks man that worked perfectly! and thanks to you again for explaining it step by step. I can use that string.find for numerous functionalities!
Recommended Posts