Bingo911 Posted April 9, 2024 Posted April 9, 2024 (edited) Is there any benefit in pasting LUA (do script) into the mission editor vs having the lua's in text files outside of the editor itself (do script file)? Is there any benefits to performance, etc. or is it just preference? Edited April 9, 2024 by Bingo911
razo+r Posted April 9, 2024 Posted April 9, 2024 Better overview if you do it in a lua file and perhaps even bigger scripts are possible.
Pizzicato Posted April 9, 2024 Posted April 9, 2024 (edited) Do Script (using dofile to load your script) reads the Lua script from your HD every time you run the mission. This means that every time you tweak the script and save it, it's automatically updated in the mission. This is perfect while you're writing, testing, and iterating your scripts. The downside, though, is the mission won't work for anyone else because it'll be looking for a Lua file that only exists on your HD. Do Script File is the exact opposite. It embeds the script into the mission, but it doesn't update it unless you reimport it. This makes it perfect for sharing, but horrendous for testing and iterating your work. The takeaway is use Do Script while you're writing and testing your mission, then switch to Do Script File when you're ready to share. Edited April 9, 2024 by Pizzicato 1 i7-7700K @ 4.9Ghz | 16Gb DDR4 @ 3200Mhz | MSI Z270 Gaming M7 | MSI GeForce GTX 1080ti Gaming X | Win 10 Home | Thrustmaster Warthog | MFG Crosswind pedals | Oculus Rift S
razo+r Posted April 9, 2024 Posted April 9, 2024 (edited) 21 minutes ago, Pizzicato said: Do Script File reads the Lua script from your HD every time you run the mission. This means that every time you tweak the script and save it, it's automatically updated in the mission. This is perfect while you're writing, testing, and iterating your scripts. The downside, though, is the mission won't work for anyone else because it'll be looking for a Lua file that only exists on your HD. If you work on the script files it won't be automatically updated as the missioneditor will save the loaded file within the mission file itself and use that one and not the one on your drives/storage. This also means that since the scripts come with the mission, it will work for everyone else aswell. Edited April 9, 2024 by razo+r
Solution cfrag Posted April 9, 2024 Solution Posted April 9, 2024 (edited) 5 hours ago, Bingo911 said: Is there any benefit in pasting LUA (do script) into the mission editor vs having the lua's in text files outside of the editor itself (do script file) If you are using plain vanilla DCS/Mission Editor, pasting script files has a small advantage in handling scripts should you develop scripts yourself: If you "doscriptfile", a copy of that script file is incorporated into the miz file; it is a 'snapshot' of that script at that moment. Any changes that you make to the script on your storage will NOT be included into your mission until you again select the file through the 'doscriptfile' action dialog. It is slightly easier to simply copy/paste the updated script into the doscript dialog. Also, when debugging, the doscript option is slightly ahead of doscriptfile as doscriptfile prepends an illegible temporary file descriptor that gets in the way of identifying which table has caused the error. NEITHER of them is comfortable or even remotely what one would expect of a program that was developed around the turn of the century/millennium, today the term 'unacceptable' comes to mind. 5 hours ago, Bingo911 said: Is there any benefits to performance There is no performance benefit for either. 2 hours ago, Pizzicato said: Do Script File reads the Lua script from your HD every time you run the mission. Unfortunately, that is currently not the case. Your script is read once, at the very moment that you choose it from the file dialog, and a snapshot copy of that file as it is on your storage at that exact moment is placed inside your mission. There are ways to do what @Pizzicato was kind enough to describe (load and execute external files at the moment that the mission is run), but these are advanced topics that in themselves are fraught with issues that you must be aware of (the mission is no longer portable - and this fact can be used as a poor man's copy protection, so to speak). I recommend that you only try that after you have some experience with mission scripts to appreciate the difference and feel the necessity. Unless you are developing scripts yourself, it makes no difference what you choose to include scripts; when in doubt, do what the script provide recommends. If people use scripts that I have created, I tend to advocate "DOSCRIPT" as it makes it easier for me to trace an error should they run into one. YMMV. Edited April 9, 2024 by cfrag 1
Bingo911 Posted April 9, 2024 Author Posted April 9, 2024 Thanks everyone, especially cfrag, your scripts are amazing.
Pizzicato Posted April 9, 2024 Posted April 9, 2024 Ugh. i inadvertently got my explanations of Do Script and Do Script File the wrong way around. I was writing on my phone just before bed, and my first thought when I woke up this morning was "Oh crap... I think mixed up the explanations." Sorry for any confusion. I've fixed my note now. i7-7700K @ 4.9Ghz | 16Gb DDR4 @ 3200Mhz | MSI Z270 Gaming M7 | MSI GeForce GTX 1080ti Gaming X | Win 10 Home | Thrustmaster Warthog | MFG Crosswind pedals | Oculus Rift S
Recommended Posts