Page 1 of 1

How to save variables to file

Posted: Sun Aug 29, 2010 3:19 pm
by Parnakra
What is the best way to save variables (and tables) to a file? Especially considering multidimensional tables.

I've tried using the remember() function from luaGlobal.lua, but it doesn't seem to be working.

Re: How to save variables to file

Posted: Sun Aug 29, 2010 3:28 pm
by demonnic
remember("VariableName")
saveVars()


the quotes are important, you have to pass remember() the name of your variable as a string, not the variable itself. To load 'em back up:

loadVars()


There're other ways, but this method does work.

Re: How to save variables to file

Posted: Sun Aug 29, 2010 3:32 pm
by Parnakra
Ah, I didn't know you had to call saveVars() and loadVars() explicitly, as the comments said they should only be used by Mudlet and I assumed they were called implicitly when you quit/start Mudlet.

Thanks!

Re: How to save variables to file

Posted: Thu Oct 21, 2010 11:54 am
by Lucky24
they are called automatically in the new 2.0 pre6 version you can download. I haven't seen any major bugs while using it, I suggest you try it out :)

Re: How to save variables to file

Posted: Fri Oct 29, 2010 3:18 am
by Lucky24
Well I dunno what I did, but for some reason they aren't called automagically for me in pre6 anymore :(

Re: How to save variables to file

Posted: Fri Oct 29, 2010 7:46 am
by Heiko
The function saveVars() has never been called by Mudlet because this set of functions is not generic enough to be generally useful imho.

People have to take care of variable saving themselves and should use the general table.save()/table.load() backbone directly imho.