Speed Posted December 4, 2012 Posted December 4, 2012 (edited) Mission Scripting Tools Expanded Lua Scripting Library for mission scripting by Speed and Grimes What is it? MIssion Scripting Tools (Mist) is a collection of Lua functions and databases that is intended to be a supplement to the standard Lua functions included in the simulator scripting engine. Mist functions and databases provide ready-made solutions to many common scripting tasks and challenges, enabling easier scripting and saving mission scripters time. The table mist.flagFuncs contains a set of Lua functions (that are similar to Slmod functions) that do not require detailed Lua knowledge to use. However, the majority of Mist does require knowledge of the Lua language, and, if you are going to utilize these components of Mist, it is necessary that you read the Simulator Scripting Engine guide on the official ED wiki. Community Contributions The purpose of Mist is to provide a set of scripts for the DCS community, by the DCS community. We are open to people contributing their own scripts into Mist, but we reserve the right to edit your script in any way we see fit before “officially” including it into Mist. Also, feel free to contribute ideas as for what scripts to develop next. Usage Rights Feel free to modify or redistribute Mist in any way you see fit (even including it in paid content is OK by us), AS LONG AS you don’t try claim that our work is your own. How to use it? Mist is not a mod of the game files. You include it into your missions simply by using the DO SCRIPT or DO SCRIPT FILE trigger actions to load Mist at or near mission start. Mist Guide A full .pdf guide for Mist is included in the attached Mist v3_3.rar file. Additionally, documentation is available online here. Example DBs are also included. Current feature overview “Flag functions” – functions that can be used by persons with very little Lua knowledge. Functionally similar to many Slmod functions, these set a flag to true when they detect a certain game condition. mist.flagFunc.mapobjs_dead_zones mist.flagFunc.mapobjs_dead_polygon mist.flagFunc.units_in_zones mist.flagFunc.units_in_moving_zones mist.flagFunc.units_in_polygon mist.flagFunc.units_LOS “Scripting functions”- intended to be used within a larger Lua script. These require knowledge of the Lua language to use. General mist.scheduleFunction mist.removeFunction mist.addEventHandler mist.removeEventHandler mist.getGroupPoints mist.getUnitsInZones mist.getUnitsInMovingZones mist.pointInPolygon mist.getDeadMapObjsInZones mist.getDeadMapObjsInPolygonZone mist.getUnitsLOS mist.getNorthCorrection mist.getHeading mist.getPitch mist.getRoll mist.getYaw mist.getAoA mist.getClimbAngle mist.getAttitude Utilities mist.utils.makeVec2 mist.utils.makeVec3 mist.utils.toDegree mist.utils.toRadian mist.utils.deepCopy mist.utils.round mist.utils.dostring mist.utils.basicSerialize mist.utils.serialize mist.utils.serializeWithCycles mist.utils.oneLineSerialize mist.utils.tableShow Debug mist.debug.dump_G mist.debug.writeData mist.debug.dumpDBs Vector Operations in Vec3 mist.vec.add mist.vec.sub mist.vec.scalar_mult mist.vec.dp mist.vec.cp mist.vec.mag Demos mist.demos.printFlightData Databases- databases built for easier mission scripting. (Example DBs included with Mist v3_3.rar file). STATIC DBs Unit DBs mist.DBs.units mist.DBs.unitsByName mist.DBs.unitsById mist.DBs.unitsByCat mist.DBs.unitsByNum Group DBs mist.DBs.groupsByName mist.DBs.groupsById Zone DBs mist.DBs.zonesByName mist.DBs.zonesByNum Human-controllable unit DBs mist.DBs.humansByName mist.DBs.humansById Misc. static DBs mist.DBs.navPoints mist.DBs.missionData REAL-TIME DBs mist.DBs.aliveUnits mist.DBs.deadObjects DOWNLOAD LATEST VERSION HERE Edited January 31, 2018 by BIGNEWY updated mist link and removed old mist version 3 Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc.
Speed Posted December 4, 2012 Author Posted December 4, 2012 Reserved Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc.
Grimes Posted December 4, 2012 Posted December 4, 2012 (edited) V4+ must be used for DCS 1.5 or higher. MIST on Github for latest release Mist 4.1 Download and info Posthttp://forums.eagle.ru/showpost.php?p=2495849&postcount=910 Mist Online Documentation: http://wiki.hoggit.us/view/Mission_Scripting_Tools_Documentation Some great references for LUA in general: http://www.lua.org/pil/ http://lua-users.org/wiki/TutorialDirectory http://lua-users.org/wiki/SampleCode Also feel free to make suggestions for features you might want to see added. Edited January 11, 2016 by Grimes 4.0 release 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
gunterlund21 Posted December 5, 2012 Posted December 5, 2012 speed what is the difference between mist.flagfunc.units_in_moving_zone and the function in SLmod. Looks the same. I was in Art of the Kill D#@ it!!!!
Grimes Posted December 5, 2012 Posted December 5, 2012 They are basically the same. However the key difference is that Slmod functions require slmod to be installed. Mist is added to the mission file itself and therefore DOESN'T require the end user to install a mod in order for the function to work. 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
gunterlund21 Posted December 5, 2012 Posted December 5, 2012 They are basically the same. However the key difference is that Slmod functions require slmod to be installed. Mist is added to the mission file itself and therefore DOESN'T require the end user to install a mod in order for the function to work. Ahhh thats awesome. Now it makes the mission more modular and transportable and still get the benefits of slmod... Nice!!!!!! I also like the ability to create zones that arent just circular. I was in Art of the Kill D#@ it!!!!
mwd2 Posted December 5, 2012 Posted December 5, 2012 New Toys :thumbup: but i haven`t manage the old ones....! :lol: Playing: F-16C Intel i7-13700KF, 64GB DDR5 @5600MHz, RTX 4080 ZOTAC Trinity, WIN 11 64Bit Prof. Squadron "Serious Uglies" / Discord-Server: https://discord.gg/2WccwBh Ghost0815
chromium Posted December 5, 2012 Posted December 5, 2012 Thanks guys :D Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
chromium Posted December 5, 2012 Posted December 5, 2012 PS: seems the attachment doesn't exist now :( Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
Speed Posted December 5, 2012 Author Posted December 5, 2012 (edited) ATTENTION: There was a major problem with Mist v1_0. The mist.addEventHandler function was broken. You know how they always say "if it ain't broke don't fix it"? Well, yea... maybe I should have listened :( Anyway that also broke the mist.DBs.deadObjects database, preventing it from being populated. I've already updated the Mist post to include Mistv1_1, which fixes these problems (never thought we'd see version 1.1 so early...). The only change is the fixing of mist.addEventHandler (and mist.DBs.deadObjects). Edited December 5, 2012 by Speed Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc.
Speed Posted December 5, 2012 Author Posted December 5, 2012 Here's the mist.demos.printFlightData function applied to weapons fired. For example, load the attached mission "Mist Weapon Flight Data.miz", select an F-15, and fire an AMRAAM- the mist.demos.printFlightData will output real-time flight data for the weapon: When applied to player aircraft, there's still some shakiness in the acceleration-based values that I need to sort out, but angular data and velocity works very well- "Mist Player Flight Data.miz" is mist.demos.printFlightData applied to the player aircraft. mist.demos.printFlightData isn't really useful for mission scripting, that's why we put it in the "demos" table- it demonstrates some of the power of the Simulator Scripting Engine for collecting data about the game environment. You can embed Tacview-like data collecting into your mission itself, base mission logic off of it if you want, and if you "unsanitize" the io and lfs libraries in MissionScripting.lua, then you can even output your data to a file and graph it using like Excel or something.Mist Weapon Flight Data.mizMist Player Flight Data.miz Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc.
chromium Posted December 5, 2012 Posted December 5, 2012 To use those script, can I: 1) execute by Triggered actions - command - run script action? + trigger with AI TASK action 2) load a .lua file instead of "run script" text? Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
Speed Posted December 5, 2012 Author Posted December 5, 2012 To use those script, can I: 1) execute by Triggered actions - command - run script action? + trigger with AI TASK action 2) load a .lua file instead of "run script" text? Yes Yes Anywhere the mission editor lets you put Lua, that Lua will run in the global environment, where it will "see" Mist. Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc.
chromium Posted December 5, 2012 Posted December 5, 2012 (edited) ok the last questions (than I will leave you at work ;) ): How do I load a function by file? I have to copy & paste (notepad ++) the function text in a new .lua file named as I want (es. functionLOS.lua)? If I have to send the mission to other people, do this loaded file will be stored in the .miz archive? Or I have to send also the .lua files to be loaded? thanks a lot :) (as usual I'm keeping group names between consecutive mission and scenarios, so I need to reduce at most the "porting" workload to save time and prevent errors) ------------------------------------------------------ PS: Speed, Grimes, would you like to see a "script wish list thread" to let the mission builder to tell you what functions could be intersting to be added? Edited December 5, 2012 by chromium Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
Speed Posted December 5, 2012 Author Posted December 5, 2012 ok the last question (than I will leave you at work ;) ): How do I load a function by file? I have to copy & paste (notepad ++) the function text in a new .lua file named as I want (es. functionLOS.lua)? Yes, this is part of why I prefer using DO SCRIPT instead of DO SCRIPT FILE. Also, you're probably aware of the rare "crap, my mission lost all its attachments" bug. DO SCRIPT FILE may also be affected by this bug; DO SCRIPT is immune to it. So yea, I like using DO SCRIPT instead. However, Grimes often prefers using DO SCRIPT FILE... to each his own, I guess. If I have to send the mission to other people, do this loaded file will be stored in the .miz archive? Or I have to send also the .lua files to be loaded? thanks a lot :) Yes, the Lua file is included in the zipped .miz archive, just like any sounds or pictures your mission might also use. Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc.
chromium Posted December 5, 2012 Posted December 5, 2012 Perfect... ehm... to be onest I'm not aware of that attachment problems, but I'll find my way using it :). Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
Megagoth1702 Posted December 5, 2012 Posted December 5, 2012 The attachment problem often happened to me when I saved the mission withou actually changing anything within it. You know, you alt tab out for a long time, then alt tab back in and you're not sure whether you saved the mission or not. So you just save it one more time. That's when I lost my files within the mission. I believe it is enough to move a unit a little bit to make the mission "changed". Speed, have you gotten this bug WITHOUT not having changed it between saves? [sIGPIC][/sIGPIC] System specs:2500k @ 4.6 GHz 8GB RAM HD7950 OC'd Win7 x64 Posting tracks to make your DCS better - attention bump incoming!
chromium Posted December 5, 2012 Posted December 5, 2012 You know, you alt tab out for a long time, then alt tab back in and you're not sure whether you saved the mission or not. So you just save it one more time. That's when I lost my files within the mission. sounds like the story of my editing life: I suffer a compulsive "PRESS SAVE BUTTON" syndrome. I'll definitely go thrugh the DO SCRIPT if it's like you told. Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
Megagoth1702 Posted December 5, 2012 Posted December 5, 2012 Awesome, no SLmod but pretty much the same functions, haha. Speed, looking at the mist manual I can not find anything like "unitsFiring", that sets a flag to true once a unit has fired something. Am I overlooking something? Thanks. [sIGPIC][/sIGPIC] System specs:2500k @ 4.6 GHz 8GB RAM HD7950 OC'd Win7 x64 Posting tracks to make your DCS better - attention bump incoming!
chromium Posted December 5, 2012 Posted December 5, 2012 Maybe is on work... I miss the POS & PTS... they're almost necessary to me :) Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
Grimes Posted December 5, 2012 Posted December 5, 2012 (edited) The only attachment issue I've had is that sometimes an attachment fails to be added to the .miz. I haven't really experienced it in a while, but I could never fully diagnose the cause. But part of the reason I've been using "Do Script File" is because my mission scripts are nearly approaching the size of Mist itself and more than a few times I've failed to completely copy over the old code with the new :) PS: Speed, Grimes, would you like to see a "script wish list thread" to let the mission builder to tell you what functions could be intersting to be added? Thats a good question. A thread in the mission builders corner would likely work. Eventually I hope a moderator adds a sticky for scripts to be posted in. In terms of Mist vs SLMod, my understanding is that Speed is going to implement as much of Slmod into Mist as possible. Really the only things we can't use the scripting engine for that Slmod can do are related to the network lua environmental. Stuff like getting player names, reading chat, etc. I'm sure you will see more of slmod ported into mist, this is version 1 after-all, and we wanted to get it out there for people to start using asap. I have two missions that are waiting to be release once some bugs get fixed. I was hoping to show them off in their entirety once Mist was released, however it will have to wait for the bugs to get fixed. However I've attached below a script segment that I am using in both of the missions. I sort the client list by a generic type: Fighters, strike aircraft, and helicopters. I've done this so I have an easy to work with table of units and so that the mission will automatically adjust for any changes made to it. Anyone can add or delete client aircraft without an issue. Also Unit.getAttribute() only works on alive units and client aircraft are 'nil' until a player spawns in. Its not the most optimized code but it works do possible_client_list = mist.utils.deepCopy(mist.DBs.humansByName) client_aircraft = { ['blue'] = { ['fighters'] = {}, -- add unit names to this list for testing purposes. ['strike'] = {}, ['heli'] = {}, }, ['red'] = { ['fighters'] = {}, ['strike'] = {}, ['heli'] = {}, }, } end function buildclientDB() mist.scheduleFunction(buildclientDB, {}, timer.getTime() + 5) for acName, acData in pairs(possible_client_list) do if Unit.getByName(acName) then punit = Unit.getByName(acName) if type(acData) == 'table' then if acData.coalition == 'red' then if punit:hasAttribute('Fighters') then table.insert(client_aircraft['red'].fighters, acName) elseif punit:hasAttribute('Battleplanes') then table.insert(client_aircraft['red'].strike, acName) elseif punit:hasAttribute('Attack helicopters') then table.insert(client_aircraft['red'].heli, acName) end elseif acData.coalition == 'blue' then if punit:hasAttribute('Fighters') then table.insert(client_aircraft['blue'].fighters, acName) elseif punit:hasAttribute('Battleplanes') then table.insert(client_aircraft['blue'].strike, acName) elseif punit:hasAttribute('Attack helicopters') then table.insert(client_aircraft['blue'].heli, acName) end end possible_client_list[acName] = nil end end end --mist.debug.writeData(mist.utils.serialize,{'client_list', possible_client_list}, 'client_list.txt') end Edited December 5, 2012 by Grimes 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
chromium Posted December 5, 2012 Posted December 5, 2012 Added and populated : http://forums.eagle.ru/showthread.php?p=1622678#post1622678 Author of DSMC, mod to enable scenario persistency and save updated miz file Stable version & site: https://dsmcfordcs.wordpress.com/ Openbeta: https://github.com/Chromium18/DSMC The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.
Quax456 Posted December 5, 2012 Posted December 5, 2012 Hi folks, maybe someone can help me. I'm trying for weeks to get this to work: I just want to do a message to a specific group via trigger.action.outTextForGroup but all I get is an error that the GroupID is nil. Maybe I'm too dumb to get this ID by using this one Group.getByName(string):getID() Regards My Rig: Windows 11 Pro, Intel i7-13700k@5.4GHz, 64GB DDR5 5200 RAM, Gigabyte Z790 AORUS Elite AX, 2TB Samsung 990 PRO, RTX4080, Thrustmaster HOTAS WARTHOG Stick + WINWING ORION 2 + MFG Crosswinds, LG 32" 4K 60FPS, ACER 30" 4K 60FPS GSync Display, HP Reverb G2 V2
Speed Posted December 5, 2012 Author Posted December 5, 2012 The attachment problem often happened to me when I saved the mission withou actually changing anything within it. You know, you alt tab out for a long time, then alt tab back in and you're not sure whether you saved the mission or not. So you just save it one more time. That's when I lost my files within the mission. I believe it is enough to move a unit a little bit to make the mission "changed". Speed, have you gotten this bug WITHOUT not having changed it between saves? I thought that perhaps it could have to do with having two copies of the DCS ME open at the same time, editing the same mission, but when I tried to reproduce it with this method, it didn't work. I'll try your method! Awesome, no SLmod but pretty much the same functions, haha. Speed, looking at the mist manual I can not find anything like "unitsFiring", that sets a flag to true once a unit has fired something. Am I overlooking something? Thanks. Currently, the way to get information about weapons firing is to use an event handler. If the event is a shot event (world.event.S_EVENT_SHOT), then you treat the event.weapon table as a Unit, and use Unit.getTypeName on it- theoretically, this should give you the name of the weapon. However, currently, Unit.getTypeName does not work on all weapon types. For some, it will give you the name of the weapon; for others, it will give you nil. We hope this will be fixed in future versions of DCS, but as long as this problem exists, I cannot port the weapons_firing Slmod functionality into Mist. Or... perhaps I can, if we are OK with a mist.flagFunc.units_firing function that does not work for some weapon types? Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc.
Recommended Posts