Table Save/Load helper

Share your scripts and packages with other Mudlet users.
Post Reply
User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Table Save/Load helper

Post by demonnic »

Because I can see this sort of thing coming up a fair bit, I created a little set of aliases/scripts to interact with table.save and table.load via mudlet's command line.

Usage is as follows:

t-save <table> "<location>"
t-load <table> "<location>"
t-overwrite <table> "<location>"

For example,
t-save myTable "myTable.lua"

would save the contents of myTable into the file getMudletHomeDir()/myTable.lua . I have it doing everything under the profile's root directory for sanity's sake, to keep files separate/etc. If for some reason you need a table from another profile, you can use "../<other profile name>/<filename>" .. for instance:

t-load groggyStats "../groggy/stats.lua"

Each of the commands will print out what table is to be saved/loaded/overwritten, and what file (relative to the profile root) it will be saved/loaded/overwritten from. It will then instruct you to type yes within thirty seconds if you are sure you want to go through with it.

Rather than using tempAliases, I simply aliased ^yes$ and if there's no active wait timer for confirmation, it sends the yes along to the MUD.

If you input any of the aliases without any arguments, it will print usage. t-load meshes the information from the file into an existing table if a table with that name already exists, whereas t-overwrite will reset the table to only contain the information from the file.

Questoins/Comments/Concerns welcomed!
Attachments
TableIOHelper.xml
The goods
(7.94 KiB) Downloaded 473 times

Post Reply