After resetting the vehicle every module and global variable is lost. Is there any way to store the variables (apart from saving them into a json file)? P.S. by storing the variables I meant their values, for example, M.var = "someValue". I know I can create a module for GE Lua which I would write the values into but this approach seems a little clumsy.
Ok, I figured it out. If your module (extension) is in \lua\vehicle\extensions directory, you can use M.onSerialize and M.onDeserialized functions. For example: Code: M.variable = "morning" -- some code that changes M.variable to, for example, "afternoon" M.onSerialize = function() local data = {} data["variable"] = M.variable return data end M.onDeserialized = function(data) M.variable = data.variable -- the variable value is reassigned to "afternoon" end
In the vehicle lua vm lua is never reset with a vehicle reset aslong as you dont listen to the reset event and reset everything yourself. I guess you are rather talking about a vehicle reload `CTRL+R`? Can i ask why you need to keep data between vehicle reloads?
Oh, ctrl+r is called reloading... I've made a gravity mod which dynamically shifts a planet object. A user can enter custom values in the Imgui window, which are then sent to the vehicle module. So the problem was that these values were not saving while reloading