Part of my game involves me using a factory to create instances of a game object (a boat). The scripts I have written for the game object all reference a Lua Module that exists to store variables that all the scripts need. Unfortunately, every time I create a new instance of the boat game object, it shares the same variables module as the others which creates conflicts and issues.
How could I create a seperate variables module for each game object instance?
or would it be better for me to pursue a different method of storing variables globally across scripts?
This variables module looks a bit like this:
local M = {}
M.velocity= vmath.vector3()
function M.modifyvelocity(value)
M.velocity= value
end
return M
Thanks