Slazi Posted August 31, 2014 Posted August 31, 2014 So I've been looking through the 'official' missions, namely the campaigns, and I have noticed that none of them I can see use any scripts. This was quite a surprise to me. I figured scripting in Lua was far more convenient and readable than trying to do things in the editor and remember what all the flags are supposed to mean. Is scripting generally discouraged? Are there performance considerations I should worry about? Most of the missions I've worked on in the past have been done entirely in the ME (with third party scripts where required). Should I stick with the ME or try to do more via lua so I can reuse my work as any good OO programmer should?
Flagrum Posted August 31, 2014 Posted August 31, 2014 The ME is actually quite capable and it would make not much sense to implement the logic for a mission completely as LUA code - it would be way to much work and would not offer real advantages. But there are some aspects where LUA code can actually save either a lot of work or even make things possible that are otherwise not archivable. But for these cases, you usually don't code the logic yourself - instead you call a couple of LUA functions that someone else already has created (i.e. MIST and all those great scripts like "suppression script", etc.) This is at least true for 80 - 90 % of the "average" missions one will design. There are ofc cases where you really invent something new (again, those scripts that add a completely new dimension to a mission). Here you could put your OO skills to good use, I suppose. But the first step would be to have such an idea... :o)
Slazi Posted August 31, 2014 Author Posted August 31, 2014 I was mainly looking at doing common tasks in Lua instead of doing in the ME. Things like simple drops. If you want to set up a a pickup and dropoff there's quite a lot of ME work associated with the radio commands and flags. Having to repeat this for every single item you want to pickup or drop off takes a while. Ideally I want to just have functions (in lua) that get rid of all the heavy lifting.
Flagrum Posted August 31, 2014 Posted August 31, 2014 (edited) I was mainly looking at doing common tasks in Lua instead of doing in the ME. Things like simple drops. If you want to set up a a pickup and dropoff there's quite a lot of ME work associated with the radio commands and flags. Having to repeat this for every single item you want to pickup or drop off takes a while. Ideally I want to just have functions (in lua) that get rid of all the heavy lifting. Well, sure, but initially this will require a bit of work - afaik there are not scripts or function libraries that offer such functionality, yet. But tbh, this sounds like a valuable project idea. MIST is covering rather low to medium level functions - from coordinate calculation to unit handling. Then there are those sophisticated scripts that add a completely new layer to a mission. But something in the middle is perhaps lacking atm. Develop a function library which deals with mission stuff at an abstraction level similar to what the ME offers - would easily spend +rep for that! :o) edit: you could perhaps even re-use existing code. A lot of stuff (like triggers, flags, etc.) in a mission generated by the ME are actually LUA function calls. Maybe you could create a user friendly wrapper around those ... :o) Edited August 31, 2014 by Flagrum
Slazi Posted August 31, 2014 Author Posted August 31, 2014 edit: you could perhaps even re-use existing code. A lot of stuff (like triggers, flags, etc.) in a mission generated by the ME are actually LUA function calls. Maybe you could create a user friendly wrapper around those ... :o) Sounds like a good project! I only wish I had the time. I'll definitely look into getting some of the simpler stuff done via scripts so I don't need to repeat my efforts each time.
FSFIan Posted August 31, 2014 Posted August 31, 2014 Is scripting generally discouraged? Are there performance considerations I should worry about? AFAIK the trigger system uses Lua internally anyway, so doing things in Lua instead of the trigger system should not carry any performance penalty. Depending on your mission, a custom Lua script may even perform better because it can re-use partial computations or decide to check complex trigger conditions less than once a second. The built-in missions probably don't use scripts because they are not too complex for the trigger system to handle and the Mission Editor UI for custom scripts can be annoying to use (you don't want to edit code in the tiny ME text field, so you have to use a DO SCRIPT FILE trigger, which needs a nudge every time you change your script file). They may also have been developed at a time when the scripting system was less capable. If you decide to try writing Lua, check out the Lua Console of my DCS Witchcraft project. It provides a Lua read-eval-print loop so you can poke around in the Lua environment while the mission is running to make debugging easier. DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua
Grimes Posted September 1, 2014 Posted September 1, 2014 Most of the missions and campaigns were written before the scripting engine was properly implemented. Even then the scripting is relatively new and some haven't learned how to use it yet. In total I think there are 3 missions with scripts built in, all of them are for Flaming Cliffs 3 MP and were made by either Speed or myself. 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
Slazi Posted September 1, 2014 Author Posted September 1, 2014 Thanks for all the responses. I'm very interesting in using scripting now. I really want to avoid flags :) It's far easier to understand LoadCargo("TransportA", "30mm") rather than set flag 1 = 3132 Gonna be an interesting side project.
Slazi Posted September 4, 2014 Author Posted September 4, 2014 I tried Witchcraft last night, but I'm having a little difficulty getting DCS to display what is going on in the browser mission editor. Perhaps I missed a step or something. I also ended up blue-screening my computer when using it, but I hope that is just a one off. I'll give it another try tonight - mainly for the LUA script aspect.
Slazi Posted September 6, 2014 Author Posted September 6, 2014 I'm still interested in trying to do this via scripts, but I'm finding it hard to get the basics. I guess what I need are some good tutorials to get me started, so at least I can see how to interface with the game properly.
Recommended Posts