I’m very new to Defold and Lua so pardon if this question is stupid but I’m trying to pass a table to be set on the newly created object from a factory:
if message_id == hash("respawn") then
factory.create("#factory", go.get_position(), vmath.quat(), {history: message.history})
end
I then want to use this history in the new object:
go.property("history", {})
...
-- do stuff with self.history
However, this doesn’t work since I’m getting “Only these types are available: number, hash, msg.url, vmath.vector3, vmath.vector4, vmath.quat”.
What is the correct way to solve this? The history table will be of unknown length (basically recording stuff from the game that the new object needs to take into account).
As the error message state you can not send tables in messages. One way to solve it would be to have the history in a globally available lua module instead:
history.lua:
local _M={
history={}
}
return _M
some_script.script:
local history=require(“history.lua”)
function some_function(self)
– do stuff with history.history
end