Shuffmayn Posted December 12, 2023 Share Posted December 12, 2023 (edited) Hi all! I'm rather new to DCS scripting and MIST, but I've been trying to create a script for a little mission I want to run with some friends. I'm trying to post a message in-game when we've destroyed ~80% of each individual SAM-site and then respawn it, but instead of writing a statement for each individual unit I figured I would simply create a table with all the units I want to be able to respawn, and then put a reference to the table in the mist.flagFunc.group_alive_less_than function. I can't get it to work. I feel like I've tried everything I can imagine to get it to work, but I'm at my wits end. Could someone please look over my code and see if they can figure out where I went wrong? spawnGroups = {} -- table containing units for respawning (and other things) spawnGroups[1] = "Halo 1" spawnGroups[2] = "RED AWACS" spawnGroups[3] = "HOS SU-27" spawnGroups[4] = "SAM NORTH" spawnGroups[5] = "SAM SOUTH" spawnGroups[6] = "CONVOY 1" spawnGroups[7] = "Train 1" local groupNames = {} -- Initialize groupNames table -- Populate groupNames with values from spawnGroups[4], spawnGroups[5], and spawnGroups[6] for a = 4, 6 do local groupName = tostring(spawnGroups[a]) if groupName and mist.DBs.groupsByName[groupName] then groupNames[#groupNames + 1] = groupName else -- Handle the case where the group name is not valid local errorMessage = "Invalid group name or group not found: " .. tostring(groupName) print(errorMessage) env.info(errorMessage) trigger.action.outText(errorMessage, 5) -- Display the error message in-game for visibility end end -- Use the populated groupNames table in mist.flagFunc.group_alive_less_than mist.flagFunc.group_alive_less_than { units = table.concat(groupNames, ","), -- Combine groupNames with commas flag = 100, percent = 20, toggle = true, interval = 60, } Thank you in advance for any and all help on this *edit I just went back to the PDF documentation, and noticed that the description states: mist.flagFunc.group_alive_less_than mist.flagFunc.group_alive_less_than (table vars) vars has the following recognized fields (required entries in blue, optional in green): { groupName = string groupName, flag = number/string flag, percent = number percent, stopflag = number/string stopflag, interval = number interval, toggle = boolean toggle, } but the example reads: mist.flagFunc.group_alive_less_than { units = 'myGroup, flag = 100, percent = 20, toggle = true, } so should I use 'groupName' or 'units' for the variable? Edited December 12, 2023 by Shuffmayn Link to comment Share on other sites More sharing options...
Grimes Posted December 12, 2023 Share Posted December 12, 2023 (edited) I don't really keep the pdf up to date anymore. Best to check the hoggit wiki and the pages on mist for better examples. https://wiki.hoggitworld.com/view/MIST_group_alive_less It is simply easier to update the wiki with new info or fixes than the pdf. This function doesn't support multiple group names, it will only accept one. You would have to call it for each group that is valid. Which might look something like this: spawnGroups = {} -- table containing units for respawning (and other things) spawnGroups[1] = "Halo 1" spawnGroups[2] = "RED AWACS" spawnGroups[3] = "HOS SU-27" spawnGroups[4] = "SAM NORTH" spawnGroups[5] = "SAM SOUTH" spawnGroups[6] = "CONVOY 1" spawnGroups[7] = "Train 1" -- Populate groupNames with values from spawnGroups[4], spawnGroups[5], and spawnGroups[6] for a = 4, 5 do -- you had 6 here, it would have included the group at index 6 mist.flagFunc.group_alive_less_than( { groupName = spawnGroups[a], flag = tostring(a), percent = 20, toggle = true, }) end Alternatively making your own function isn't that bad. local checkGroups = {"SAM NORTH", "SAM SOUTH"} local function checkAndRespawn(gName) timer.scheduleFunction(checkAndRespawn, gName, timer.getTime() + 60) local gp = Group.getByName(gName) if gp then local ratio = gp:getSize()/gp:getInitialSize() if ratio < 0.2 then mist.respawnGroup(gName, true) end end end for i = 1, #checkGroups do checkAndRespawn(checkGroups[i]) end Edited December 16, 2023 by Grimes upmixed 1 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 Link to comment Share on other sites More sharing options...
Shuffmayn Posted December 13, 2023 Share Posted December 13, 2023 On 12/12/2023 at 12:36 PM, Grimes said: I don't really keep the pdf up to date anymore. I found that out I'll be going to the hoggit wiki from now on for references, thank you! On 12/12/2023 at 12:36 PM, Grimes said: -- you had 6 here, it would have included the group at index 6 That's what I want to do though. Convoy 1 is also a group I want to respawn when below the threshold. On 12/12/2023 at 12:36 PM, Grimes said: Alternatively making your own function isn't that bad. It probably isn't, but I spent a lot of time getting to this point with my code and until I feel more confident coding my own stuff in lua I'll continue relying on your work Before getting back into lua a week ago, I haven't looked at a code in years (used to code Arma and Operation Flashpoint) so I'm sloooowly getting back into the swing of things. Link to comment Share on other sites More sharing options...
Shuffmayn Posted December 15, 2023 Share Posted December 15, 2023 On 12/12/2023 at 12:36 PM, Grimes said: local ratio = gp:getSize()/gp:getInitialSize() if decimal < 0.2 then mist.respawnGroup(gName, true) end Shouldn't the above be: local ratio = gp:getSize()/gp:getInitialSize() if ratio < 0.2 then mist.respawnGroup(gName, true) end or am I completely (and this is very likely the case) completely off kilter in my understanding of how lua works? Link to comment Share on other sites More sharing options...
Grimes Posted December 16, 2023 Share Posted December 16, 2023 13 hours ago, Shuffmayn said: Shouldn't the above be: Yeah, you are right. I have a tendency to think one thing and type another. Sometimes I notice it and correct it. Evidently not that time. 1 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 Link to comment Share on other sites More sharing options...
Flasher Posted February 1 Share Posted February 1 Need help with mist.marker.remove ... This command does not work with drawn lines , only with polygons .. Any help please ? Link to comment Share on other sites More sharing options...
Grimes Posted February 3 Share Posted February 3 Yeah looks a little bugged. You can get expected behavior by directly passing the markId that is associated with each segment of the line. local rtn = mist.marker.drawShape("lineTest") -- Then latter you can pass the markId value associated with each shape. for i = 1, #rtn do mist.marker.remove(rtn[i].markId) 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 Link to comment Share on other sites More sharing options...
Death Merchant Posted February 12 Share Posted February 12 Mist is awesome. I'm learning it right now. Are there any sample scripts that I can look at to help me learn? Thanks, DM 1 [PC] ASUS X570E - Ryzen 9 5950X - RX 6900 XT - 32GB 3600Mhz Hornet, A-4E-C, Huey, Ka-50, Mi-8, F-15E, F-14 Join us on Death Dealers PvE server. Link to comment Share on other sites More sharing options...
Wrecking Crew Posted February 13 Share Posted February 13 See the attachment. Someday I'll clean this up WC's Script & Mist Examples.lua Much of what is in here came from the help that I got in this forum. WC's Flags.txt 2 Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site. Link to comment Share on other sites More sharing options...
ENO Posted February 22 Share Posted February 22 (edited) On 2/13/2024 at 10:57 AM, Wrecking Crew said: See the attachment. Someday I'll clean this up WC's Script & Mist Examples.lua 33.68 kB · 4 downloads Much of what is in here came from the help that I got in this forum. WC's Flags.txt 20.65 kB · 2 downloads See you're still busy making miracles happen! Edited February 22 by ENO 1 "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art Link to comment Share on other sites More sharing options...
Death Merchant Posted February 29 Share Posted February 29 On 2/13/2024 at 12:57 PM, Wrecking Crew said: See the attachment. Someday I'll clean this up WC's Script & Mist Examples.lua 33.68 kB · 8 downloads Much of what is in here came from the help that I got in this forum. WC's Flags.txt 20.65 kB · 4 downloads Thanks! That's very helpful! [PC] ASUS X570E - Ryzen 9 5950X - RX 6900 XT - 32GB 3600Mhz Hornet, A-4E-C, Huey, Ka-50, Mi-8, F-15E, F-14 Join us on Death Dealers PvE server. Link to comment Share on other sites More sharing options...
Bossco82 Posted March 5 Share Posted March 5 HI, Does anyone know if it is possible in MIST when using the clone in zone script. To assign a new group name to the newly spawned group? Also can anyone confirm if 4_5_124 is the latest version? Cheers Link to comment Share on other sites More sharing options...
Lekaa Posted March 13 Share Posted March 13 Hello, I have never used the Teleport function in mist and I wonder if I could run a teleport script function where i Teleport the carrier (where people spawn) to another Zone or a specific location in a zone if that zone is blue. I'm using it in Foothold and the carrier group is far out, but it will be more useful if the target zone is now blue to get the carrier group there straight away rather then having the boat travel there if zone is blue with flags. Link to comment Share on other sites More sharing options...
Grimes Posted March 13 Share Posted March 13 13 hours ago, Lekaa said: Hello, I have never used the Teleport function in mist and I wonder if I could run a teleport script function where i Teleport the carrier (where people spawn) to another Zone or a specific location in a zone if that zone is blue. Teleport should keep the unitId value for each unit, that is the main thing that matters when "teleporting" a ship or other objects that people spawn on. Just know that anyone on the ship when it spawns somewhere else will probably fall into the water. Unknown what'll happen to any static objects you have on the deck. 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 Link to comment Share on other sites More sharing options...
Lekaa Posted March 13 Share Posted March 13 6 minutes ago, Grimes said: Teleport should keep the unitId value for each unit, that is the main thing that matters when "teleporting" a ship or other objects that people spawn on. Just know that anyone on the ship when it spawns somewhere else will probably fall into the water. Unknown what'll happen to any static objects you have on the deck. Thank you for responding. This would be done on a mission start level. Unfortunately I don't know how this is used, I checked the wiki but i'm new to this and still feels in Chinese to me. There is no static units either. Question is what will happen to the Waypoints? will the boat go to the first waypoint it have in the first zone? Link to comment Share on other sites More sharing options...
Grimes Posted March 14 Share Posted March 14 mist.teleportInZone("carrierGroup" , "newZone" , false , 1 , { offsetRoute = true} ) Should do the trick. It'll teleport to the zone with the name "newZone". The radius is 1 so basically it'll be exactly on the center of the zone. It passes a table with the value offsetRoute = true which means it will grab the route from the mission, including any tasks assigned, and will offset the position of the points. If WP2 is straight east from WP 1 for 50km then it'll be offset 50km east from newZone. It doesn't check for any terrain issues, that'll be on you to make sure the offset waypoints are on land all a sudden. 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 Link to comment Share on other sites More sharing options...
Lekaa Posted March 14 Share Posted March 14 (edited) 9 hours ago, Grimes said: mist.teleportInZone("carrierGroup" , "newZone" , false , 1 , { offsetRoute = true} ) Should do the trick. It'll teleport to the zone with the name "newZone". The radius is 1 so basically it'll be exactly on the center of the zone. It passes a table with the value offsetRoute = true which means it will grab the route from the mission, including any tasks assigned, and will offset the position of the points. If WP2 is straight east from WP 1 for 50km then it'll be offset 50km east from newZone. It doesn't check for any terrain issues, that'll be on you to make sure the offset waypoints are on land all a sudden. I will try that out, Thanks a lot. This is how the zones look: [url=https://ibb.co/Jzx3b74][img]https://i.ibb.co/y8h4My1/Namnl-s.png[/img][/url] The idea is to push the new zone on a flag depending if the zone is blue or not, but it takes time. Based on how it looks is this Line of code good enough? Edited March 14 by Lekaa Link to comment Share on other sites More sharing options...
Lekaa Posted March 14 Share Posted March 14 Ideally I would like to teleport the group here, then i can set a TASK push to 3 which will move the carrier on the new route nullnull Link to comment Share on other sites More sharing options...
Lekaa Posted March 14 Share Posted March 14 (edited) I managed to get the CVN group to the correct place by using this Code, now how to tell it to go to WP3 when this code is used instead of it turning back to the first Zone (Waypoint 0 ) Also if I could tell the group to have a new Heading. Thank you local vars = {} vars.gpName = 'CVN-72' vars.action = 'teleport' vars.point = {x = 173573, y = 0, z = 186080} mist.teleportToPoint(vars) Edited March 14 by Lekaa Link to comment Share on other sites More sharing options...
Lekaa Posted March 14 Share Posted March 14 (edited) local vars = {} vars.groupName = 'CVN-72' vars.point = {x = 173573, y = 0, z = 186080} vars.action = 'teleport' vars.initTasks = true vars.route = { points = { [1] = { x = 173573, y = 186080, alt = 0, alt_type = "BARO", type = "Turning Point", speed = 7.7083333333333, action = "Turning Point", task = { id = "ComboTask", params = { tasks = { [1] = { enabled = true, auto = true, id = "WrappedAction", number = 1, params = { action = { id = "ActivateBeacon", params = { type = 4, AA = false, unitId = 235, system = 3, name = "ABE", channel = 72, modeChannel = "X", callsign = "ABE", bearing = true, frequency = 1159000000, }, }, }, }, [2] = { number = 2, auto = false, id = "WrappedAction", enabled = true, params = { action = { id = "ActivateICLS", params = { channel = 1, type = 131584, name = "ICLS", unitId = 235, }, }, }, }, [3] = { number = 3, auto = false, id = "WrappedAction", enabled = true, params = { action = { id = "ActivateLink4", params = { frequency = 336000000, name = "ABE", unitId = 235, }, }, }, }, [4] = { number = 4, auto = false, id = "WrappedAction", enabled = true, params = { action = { id = "ActivateACLS", params = { name = "ABE", unitId = 235, }, }, }, }, [5] = { number = 5, auto = false, id = "WrappedAction", enabled = true, params = { action = { id = "Option", params = { value = 2, name = 9, }, }, }, }, [6] = { number = 6, auto = false, id = "WrappedAction", enabled = true, params = { action = { id = "SetInvisible", params = { value = true, }, }, }, }, }, }, }, speed_locked = true, }, [2] = { x = 256778.63795649, y = 88115.518386809, alt = -0, alt_type = "BARO", type = "Turning Point", ETA = 41108.952157286, formation_template = "", name = "next WP", ETA_locked = false, speed = 7.7083333333333, action = "Turning Point", task = { id = "ComboTask", params = { tasks = {}, }, }, speed_locked = true, }, [3] = { x = 210726.84171007, y = 18784.792169668, alt = -0, alt_type = "BARO", type = "Turning Point", ETA = 51906.579389458, formation_template = "", name = "waypoint5", ETA_locked = false, speed = 7.7083333333333, action = "Turning Point", task = { id = "ComboTask", params = { tasks = {}, }, }, speed_locked = true, }, [4] = { x = 139624.89256037, y = 131004.41653938, alt = 0, alt_type = "BARO", type = "Turning Point", ETA = 69140.98296076, formation_template = "", name = "LastWP", ETA_locked = false, speed = 7.7083333333333, action = "Turning Point", task = { id = "ComboTask", params = { tasks = { [1] = { enabled = true, auto = false, id = "GoToWaypoint", number = 1, params = { nWaypointIndx = 4, fromWaypointIndex = 6, }, }, }, }, }, speed_locked = true, }, }, } mist.teleportToPoint(vars) I fixed it using this code, little ChatGPT and some brain cells i managed to get it to work Edited March 14 by Lekaa Link to comment Share on other sites More sharing options...
Floyd1212 Posted March 25 Share Posted March 25 Let me start by admitting that I did not read all 73 pages of the thread, so forgive me if this has been addressed already... I am trying to troubleshoot an issue where teleportToPoint of a group results in the new group not respecting the "Hidden on MFD" setting of the original group. Is there a var I can pass when calling this function to keep the new units hidden? For example, in the Apache, when I enable SHOW > COORD SHOW > PLANNED TGTS/THREATS the enemy SAMs are displayed on the TSD. When I enable SHOW > COORD SHOW > ENEMY UNITS Control measures for other enemy units are shown on the TSD. This shouldn't be happening if Hidden on MFD is checked for the unit group in the ME, which it is for the original groups being teleported. Any suggestions on resolving this? Link to comment Share on other sites More sharing options...
Grimes Posted March 26 Share Posted March 26 Try the latest version of development branch: https://github.com/mrSkortch/MissionScriptingTools/tree/development If you were using that function to teleport the group, rather than clone or respawn, then it wasn't inheriting all of the possible variables for the group. If you were cloning or respawning it should have been respecting the hiddentOnMFD value in the editor. There is no specific option built into the function to set that hiddenOnMFD. It wouldn't take much to add one, but at the same time I should probably make a function that generates the group table without actually spawning the group. That way you can get the table, add what might be needed, and then spawn the group yourself. 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 Link to comment Share on other sites More sharing options...
AlexZander_D Posted April 20 Share Posted April 20 @Grimes, first of all thank you for your great work. Now i wanna ask, i use modified Pretense mission and wanna modify it more. Mission included some static objects from MIST like tent, barracs, hangars and etc. But it is possible to create new static via MIST? For example use SKP-11 or something like this? --- Kind Regards, Alexander "Angry Яussian Simmer" Dementyev simMarket Team Member www.simmarket.com Link to comment Share on other sites More sharing options...
Grimes Posted Sunday at 03:48 AM Share Posted Sunday at 03:48 AM Just like spawning anything, you use mist.dynAdd and mist.dynAddStatic. Both of which will fill in any data they can and pass that to coalition.addGroup and coalition.addStaticObject. https://wiki.hoggitworld.com/view/MIST_dynAddStatic See the example on there and change the type to "SKP-11" 1 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now