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 » Sun Aug 29, 2010 3:19 pm

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: 560
Joined: Sat Dec 05, 2009 3:19 pm

Re: How to save variables to file

Post by demonnic » Sun Aug 29, 2010 3:28 pm

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 » Sun Aug 29, 2010 3:32 pm

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: 49
Joined: Sun Sep 12, 2010 1:50 am

Re: How to save variables to file

Post by Lucky24 » Thu Oct 21, 2010 11:54 am

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: 49
Joined: Sun Sep 12, 2010 1:50 am

Re: How to save variables to file

Post by Lucky24 » Fri Oct 29, 2010 3:18 am

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 » Fri Oct 29, 2010 7:46 am

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

Who is online

Users browsing this forum: No registered users and 2 guests