Jump to content

How to reload mods at runtime?


MXXIV

Recommended Posts

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

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

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 by MXXIV
Link to comment
Share on other sites

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

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

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. :x

Link to comment
Share on other sites

  • MadDan locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...