A Saving Lib? [SOLVED]
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: A Saving Lib?
If the post is the answer at a question that requires a one-word answer, yes (I think)... Anyway, writing 'a_table{}' seems to call the __call field of the metatable of a_table (I didn't know it until a few minutes ago). If you want to write the content of the table you should either create a function that turns a table into a string (or something like that) or find a library that does it for you (like json4lua)
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: A Saving Lib?
f{} is syntactic sugar for f({})Nixola wrote:Anyway, writing 'a_table{}' seems to call the __call field of the metatable of a_table (I didn't know it until a few minutes ago).
It works with string literals too. (That's how you can write require "something".)
If you try to call a table, it indeed looks at the __call field of the metatable.
Put those two together, and you get the apparent behaviour.
Help us help you: attach a .love.
Re: A Saving Lib? [SOLVED]
Thanks Robin
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: A Saving Lib? [SOLVED]
I used json it worked perfectly.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
personal page and a raycaster
Re: A Saving Lib? [SOLVED]
Or, you could just write valid lua syntax to a file with love.filesystem and then just require the file to load it. Like this:
This example works for numbers, but can easily be changed to work with strings and other objects as well, including tables.
Code: Select all
string = "a = ".. a.. "/n b = ".. b
love.filesystem.write("data.lua", string)
--to load
require "data"
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Who is online
Users browsing this forum: Bing [Bot] and 4 guests