MXXIV Posted March 1, 2016 Share Posted March 1, 2016 Despite the lack of any documentation I decided to man up and make my own mod. Obviously, without documentation modding is all about copy pasting and seeing what will happen. Seeing what will happen is pain if you have to restart the game every time. Does anyone know how to reload running mods at runtime? Link to comment Share on other sites More sharing options...
blindcoder Posted March 1, 2016 Share Posted March 1, 2016 The bcUtils mod has a button to reload mods from the Main screen (look in the top-right). Reloading while the game is running would work the same way, but I highly advise against it, as it will lead to events firing multiple times, data structures being reinitialised when they shouldn't and probably some other unpleasentries. Link to comment Share on other sites More sharing options...
MXXIV Posted March 1, 2016 Author Share Posted March 1, 2016 (edited) Well of course the old event listeners should be purged before reloading the mods. Is that not possible? Maybe if there was general pattern for init/teardown for a mod everything would be simpler. Can my mod specifically be designed to support random load unload actions? Edited March 2, 2016 by MXXIV Link to comment Share on other sites More sharing options...
blindcoder Posted March 2, 2016 Share Posted March 2, 2016 I'm not really sure. I've never tried to do that myself, always been going back to the main screen, reloaded the mods and loaded the savegame from there. Link to comment Share on other sites More sharing options...
MXXIV Posted March 2, 2016 Author Share Posted March 2, 2016 Well, you're probably the patient one. Link to comment Share on other sites More sharing options...
Kirrus Posted March 2, 2016 Share Posted March 2, 2016 4 hours ago, MXXIV said: Well, you're probably the patient one. Being patient isn't a bad thing ;). Though, if you work out a way to do it in-game safely, I'm sure others'd appreciate your input MXXIV 1 Link to comment Share on other sites More sharing options...
EnigmaGrey Posted March 2, 2016 Share Posted March 2, 2016 Haven't noticed any negative consequences to reloading Lua within an active game, but BC's suggestion is probably the only way to ensure that errors don't occur. MXXIV 1 Link to comment Share on other sites More sharing options...
MXXIV Posted March 2, 2016 Author Share Posted March 2, 2016 4 hours ago, kirrus said: Though, if you work out a way to do it in-game safely, I'm sure others'd appreciate your input I'd love to do that. I assume such mod would need an event that is fired before lua is reloaded to do proper teardown for all structures and event listeners. I'm not sure if such event exists. I'm actually not very content with the fact people add listeners on mod load instead of adding them when game is started, but I know no better way unfortunatelly. Link to comment Share on other sites More sharing options...
MXXIV Posted March 2, 2016 Author Share Posted March 2, 2016 4 hours ago, EnigmaGrey said: Haven't noticed any negative consequences to reloading Lua within an active game And how did you do it? Please I really need it. I don't care much about errors. Link to comment Share on other sites More sharing options...
EnigmaGrey Posted March 3, 2016 Share Posted March 3, 2016 Launch the game in debug mode. Go to the installation directory of Project Zomboid and right click ProjectZomboid64.bat -> Edit. Add -Ddebug after the -Xmn and -Xmx calls. Launch the game from this script. In game, you can then bring up the Lua debug panel with one of the F* keys then reload Lua from within the game. Though, I forget the details and may have to check. MXXIV 1 Link to comment Share on other sites More sharing options...
Recommended Posts