on load, im trying to make "my_data" from nil into a table (basically deserialize all that i previously saved into "game_save.dat"
so, it becomes something like
function deserialize_into_table(name, table_pointer)
if filesystem.getInfo(name) then
local file = filesystem.newFile(name, "r")
local serializedData = file:read()
file:close()
local deserializedData = binser.deserialize(serializedData)
deserializedData = deserializedData[1]
for k, v in pairs(deserializedData) do
table_pointer[k] = v
end
end
end
deserialize_into_table("game_save.dat", my_data)
Can you provide more code, or say what your exact error/issue is? At a glance, if your "my_data" variable is nil when you call the deserialize_into_table function, "table_pointer" won't be a table; it'll be nil. Additionally, binser.deserialize already returns a table, so you might be better off doing (assuming your serialized file is just a table):
function deserialize_into_table(name)
if filesystem.getInfo(name) then
local serializedData = love.filesystem.read ( name )
return binser.deserialize(serializedData)
end
end
my_data = deserialize_data("game_save.dat")
I do note that I have more familiarity with bitser, so I'm not sure if binser does certain things differently.