cfrag Posted October 4, 2021 Posted October 4, 2021 (edited) So it finally has come to the point that I dreaded for some time - and it seems with good reason: I need to write a small script that is to be run by the server from the /DCS/Scrips/Hooks directory. I'm starting small, and only have installed the bare minimum - a small script that implements the onPlayerChangeSlot() callback. I've got that working - hooray! Going from there I wanted to expand my tests to branch out slightly more (test additional callbacks, call into spaces like 'mission'), only to find out that the lua files seem to be cached, so each time I make a small change to my lua script, the file only propagates to DCS when I completely exit the app, i.e. I have to exit DCS entirely, and re-start it from scratch, and then start a new server (because - of course! - the hooks seemingly don't load when I start a mission I develop from ME). So a set of complete server noob's questions: Is there any good place to read up on server-related issues such as these (of course I've read up on the stuff available at hoggitworld for server gameGUI) Is it true that the server caches the luas in /Hooks, and can I force a re-load without quitting DCS? A server config setting perhaps? [Edit - I misread. The files in /Hooks seem indeed to be read when DCS starts up, since other functions are also controlled with that. Is there a way to force a re-load of them when the server start up?] Can I have the server start from ME to test the server code? Thank you so much for any pointers -ch Edited October 4, 2021 by cfrag
Grimes Posted October 4, 2021 Posted October 4, 2021 7 hours ago, cfrag said: Is there any good place to read up on server-related issues such as these (of course I've read up on the stuff available at hoggitworld for server gameGUI) Is it true that the server caches the luas in /Hooks, and can I force a re-load without quitting DCS? A server config setting perhaps? [Edit - I misread. The files in /Hooks seem indeed to be read when DCS starts up, since other functions are also controlled with that. Is there a way to force a re-load of them when the server start up?] Can I have the server start from ME to test the server code? The hoggit wiki and the DCS_controlAPI.html are about it. Its like if you modified any other file from the game. It all gets loaded once as the game loads. I suppose you could have your hooks call code that is executed from another file and then command that file to be reloaded on something like a mission change. So have some file make a global function that the hook calls. If you reload that file with the global function it will redefine what the hook calls. However my answer to your last question also applies for this. No you can't. But what you can do is run two instances of DCS on your PC at the same time. One is rendered with a UI and the other is a dedicated server. Dedicated servers tend to start up faster, will load directly into the last ran mission, and you can keep your rendered version on the MP UI to quickly re-join the server. Actually if you disconnect from the server, stop the server, don't refresh the server list, and then restart the server it should still be a valid option in your list and you can just instantly rejoin it. This is how I test slmod or in general any other server side issues. Likewise you can leverage the fact that it will re-load a mission on startup so you can make your change and just restart the server. Alternatively you can keep the server online, switch it to an alternative mission while you change something in the editor, then when ready have the server load that mission again. To run headless copy of the game on your PC you can put a batch file that runs the following code in your install folder: bin\DCS.exe --server --norender -w DCS.DS_openbeta -w is simply the write directory command, so in this case it will make a saved games folder DCS.DS_openbeta. Doesn't matter what you have there other than it is required so that you aren't using the same saved games folder for your rendered and headless server. 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
PravusJSB Posted October 4, 2021 Posted October 4, 2021 You're much better running a dedicated server to test code really, and yes you can make a change to any user scripts and reload in mission using DCS.reloadUserScripts (Im not sure if that's the right one but you'll see it if you print the function names from the DCS class to log). I also use a call back tied to a chat command which re-loads a script file and outputs the result which allows for quick changes and code dynamism live in mission. That way I can effectively use my IDE as a console. Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb
cfrag Posted October 5, 2021 Author Posted October 5, 2021 (edited) Thank you so much @Grimes and @PravusJSB for the added insight! I'll look into setting up a separate server instance to test the code (unfortunately, being a Unix guy, I'm not familiar with Windows networking, so I'll have another hill to climb and find the Windows analogues for ssh & co first. Then again, that was to be expected ) Edited October 5, 2021 by cfrag
cfrag Posted October 5, 2021 Author Posted October 5, 2021 6 hours ago, PravusJSB said: I also use a call back tied to a chat command Of course! Thank you! Can't believe I didn't think of that myself - especially since what I'm trying to do is install a couple of simple server commands! -ch
Recommended Posts