Users system

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
User avatar
Cauan
Prole
Posts: 22
Joined: Thu Mar 09, 2023 5:58 pm

Users system

Post 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
I'm me, and you are you
User avatar
dusoft
Party member
Posts: 510
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Users system

Post 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.
Andlac028
Party member
Posts: 174
Joined: Fri Dec 14, 2018 2:27 pm
Location: Slovakia

Re: Users system

Post 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.
Post Reply

Who is online

Users browsing this forum: BrotSagtMist, slime and 223 guests