Very basic error involving Binser

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
frigidaire
Prole
Posts: 1
Joined: Thu Feb 15, 2018 1:27 pm

Very basic error involving Binser

Post 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.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Very basic error involving Binser

Post 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!
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Post Reply

Who is online

Users browsing this forum: _JM_, Ahrefs [Bot] and 25 guests