Creating, Loading and Saving Tables best practices

Post Reply
Darmir
Posts: 226
Joined: Sun May 01, 2011 6:51 pm
Contact:

Creating, Loading and Saving Tables best practices

Post by Darmir »

Hey now that I have my triggers working and I am now wanting to capture the data into a table. The table will be persistant table. I am going to save the information with table.save and I want to load the table when my profile loads.

What is the best practice to do this? I saw there is a an event called sysLoadEvent but I am not sure how to do them correctly.
Any suggestions?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Creating, Loading and Saving Tables best practices

Post by Vadi »

See http://mudlet.org/asciidoc/manual.html#savingVariables

sysLoadEvent is when your profile is being loaded. It might be a good idea to load your serialized data as well then.

Darmir
Posts: 226
Joined: Sun May 01, 2011 6:51 pm
Contact:

Re: Creating, Loading and Saving Tables best practices

Post by Darmir »

I've read through the manual and it kind of explains it, but I wanted to know how you gurus handle it. Also the event are really explained. I did watch the video but is it the same for system events?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Creating, Loading and Saving Tables best practices

Post by Vadi »

yup

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

Re: Creating, Loading and Saving Tables best practices

Post by Lucky24 »

I decided to post here instead of making a new thread, but not quite sure if it should go here.

Anyway, table.save() and table.load() saves tables to files inside the Mudlet installation folder, not into the GetMudletHomeDir() folder (in windows: %userprofile%\.config\Mudlet\<ProfileName>)

This means mudlet overwrites saved tables if multiple profiles are used. In addition, table.load() throws an error if the file can't be found. I tried wrapping it with
Code: [show] | [select all] lua
status, message = pcall(table.load("tableString",tableID))
but that seems to only capture the error if the pcall is around the final called function, not when wrapped around the table.load() call itself.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Creating, Loading and Saving Tables best practices

Post by Vadi »

See "Saving via table.save & table.load" of the manual, it describes how to save it in the proper file location, not the installation directory which is not accessible on all platforms.

Post Reply