VKNorthern Posted April 2, 2024 Posted April 2, 2024 (edited) I had a friend a while back make me a script that would respawn a unit in a mission using a radio command that changes a flag which would then respawn a group into the mission. A while back this script broke and no longer works as it used to. I have no idea about how to use Lua and the friend who made the script also could not figure out as to why it doesn't work anymore. I'd appreciate any help as to why it isn't working. Respawn Script: do function toggleGroup(groupName) local gp = Group.getByName(groupName) if mist.groupIsDead(groupName) or not gp:getUnit(1):isActive() then mist.message.add({ text = groupName.." Respawned", displayTime = 5, msgFor = {coa = {"all"}} }) mist.respawnGroup(groupName, true) else mist.message.add({ text = groupName.." Despawned", displayTime = 5, msgFor = {coa = {"all"}} }) gp:destroy() end end end For reference this is the error I get: VKN_Marianas_Training_Mission_Forum.miz Edited April 2, 2024 by VKNorthern
Solution toutenglisse Posted April 2, 2024 Solution Posted April 2, 2024 Hi, here is a working edited version of your miz. I changed line 6. With your script, when the late activated group is destroyed, and then checked again by function, groupIsDead returns false (instead of true, probably because late activated group specificities?) and then the function tries to access to unit 1 that doesn't exist anymore and that creates the error. So the 1st 2 radio command pushes work and then error happens (activate - destroy - error). VKN_Marianas_Training_Mission_Forum-EDIT.miz 1
VKNorthern Posted April 2, 2024 Author Posted April 2, 2024 34 minutes ago, toutenglisse said: Hi, here is a working edited version of your miz. I changed line 6. With your script, when the late activated group is destroyed, and then checked again by function, groupIsDead returns false (instead of true, probably because late activated group specificities?) and then the function tries to access to unit 1 that doesn't exist anymore and that creates the error. So the 1st 2 radio command pushes work and then error happens (activate - destroy - error). VKN_Marianas_Training_Mission_Forum-EDIT.miz 540.63 kB · 1 download That's wonderful that it works now! Strange how groupIsDead returns false and creates that error as this issue never occured until after a certain update (don't remember which unfortunately). Not sure why it changed like that. Thank you for fixing the script though. I really appreciate it!
Recommended Posts