Page 1 of 1

Very basic error involving Binser

Posted: Thu Feb 15, 2018 1:40 pm
by frigidaire
This is driving me a little mad. I post this here because due to the very basic nature of my test code it is likely to be a formatting issue than a misuse of Binser. To top it off no one seemed to have that issue. Based on my humble experience it must be something very stupid that I'm missing but yet it escapes me. thanks for taking the time to review this.

Love is returning this error when i try to load a save file
Image

This is the test code.

Code: Select all

binser = require "includes/binser"
local player = {}

function love.load()
    if love.filesystem.exists( 'Save.lua' ) then
        player = binser.d(love.filesystem.load('Save.lua'))
    else
        player[1] = "foo"
        player[2] = "bar"
    end
end
-- etc. etc.
function love.quit()
   love.filesystem.write( 'Save.lua', binser.s(player) )
end
And this is the content of the save file
Image

What am i doing wrong? It should be a straightforward process. Thanks folks.

Re: Very basic error involving Binser

Posted: Thu Feb 15, 2018 4:31 pm
by Nixola
Love.filesystem.load will try to load the file as code. You may want love.filesystem.read to load the contents of the file, so that binser can then deserialize it.
By the way, welcome to the forum!