Page 1 of 1

Users system

Posted: Tue May 16, 2023 3:23 pm
by Cauan
Hi
I'm trying to get to read the users system in love2d
Is saved using

Code: Select all

love.filesystem.write
This is the users system structure:

Code: Select all

users = {{name = 'User'}}

return users
I tried to load it with

Code: Select all

love.filesystem.load
But I didn't get success
It have solutions?
--it have the load system

Re: Users system

Posted: Tue May 16, 2023 7:59 pm
by dusoft
You probably want

Code: Select all

require
function instead, as in:

Code: Select all

local users=require 'users'
to include your helpers and modules.

`save` and `write` are used for saving game states usually.

Re: Users system

Posted: Wed May 17, 2023 3:44 am
by Andlac028
See docs for love.filesystem.load. It loads the code, but doesn’t run it. So you have to do something like:

Code: Select all

local chunk = love.filesystem.load(data_path)
users = chunk()
Or even better, wrap it in pcall or xpcall, so it wouldn’t crash in case of invalid config.