https://github.com/gvx/bitser
Unfortunately it throws a runtime error when it serialises something called "userdata" - which turns out to be an image:
Code: Select all
Lander.imgEngine = love.graphics.newImage("/Assets/engine.png")
Lander.img = love.graphics.newImage("/Assets/ship.png")
I looked at bitser.lua. The way the code is written puts it above my pay grade. Can anyone help me make bitser skip over userdata and not include it in the serialise function?Runtime error:
Error
bitser.lua:280: cannot serialize type userdata
Traceback
[C]: in function 'error'
bitser.lua:280: in function 'serialize_value'
bitser.lua:222: in function <bitser.lua:190>
bitser.lua:281: in function 'serialize_value'
bitser.lua:210: in function <bitser.lua:190>
bitser.lua:281: in function 'serialize_value'
bitser.lua:287: in function 'serialize'
bitser.lua:415: in function 'dumps'
functions.lua:87: in function 'SaveGame'
menus.lua:36: in function 'DrawMainMenu'
main.lua:184: in function 'draw'
[C]: in function 'xpcall'
I think the secret is in line 261 ->265 where the value of t is first determined
Code: Select all
local t = type(value)
if t ~= 'number' and t ~= 'boolean' and t ~= 'nil' and t ~= 'cdata' then
seen[value] = seen[SEEN_LEN]
seen[SEEN_LEN] = seen[SEEN_LEN] + 1
end
Thanks.