How to save variables to file

Post Reply
Parnakra
Posts: 35
Joined: Tue Apr 21, 2009 10:48 am

How to save variables to file

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

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: How to save variables to file

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

Parnakra
Posts: 35
Joined: Tue Apr 21, 2009 10:48 am

Re: How to save variables to file

Post 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!

Lucky24
Posts: 52
Joined: Sun Sep 12, 2010 1:50 am

Re: How to save variables to file

Post 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 :)

Lucky24
Posts: 52
Joined: Sun Sep 12, 2010 1:50 am

Re: How to save variables to file

Post by Lucky24 »

Well I dunno what I did, but for some reason they aren't called automagically for me in pre6 anymore :(

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: How to save variables to file

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

Post Reply