Table Functions - Lua
Posted: Mon Mar 22, 2010 5:10 am
I utilize tables a lot within my system, but I am used to Python's table and dictionary types. Unfortunatly, Lua does not have standard ways to manipulate data in a table the way I am used to. (Or at least, none that I have found yet, natively)
I have a few functions that work well for giving a bit of functionality to table searching/sorting. Hope this is useful to some others!
I also wanted to ask about Lua tables as variables, and Mudlet's saving of them.
I've tried creating a test table, as a variable and saving it via 'remember('table_var')'.
I then close Mudlet completely, reopen it, and then issue 'loadVars()' and try to access that table that was saved.
This fails, with the table being a 'nil' instead of any table existing.
I've managed to work around this by using table.save() and table.load() for saving my table Variables, but this is extremely cumbersome and using external files to save internal variables is inefficient. Would there be a way to save the table variables WITH Mudlet's 'remember()' command, or another way that would ensure the table would be properly initiated instead of using table.save() and load()? I'd like to minimize the external files I'm using, and would really rather not have them at all for the many table instances I'll be creating.
Thanks.
I have a few functions that work well for giving a bit of functionality to table searching/sorting. Hope this is useful to some others!
I also wanted to ask about Lua tables as variables, and Mudlet's saving of them.
I've tried creating a test table, as a variable and saving it via 'remember('table_var')'.
I then close Mudlet completely, reopen it, and then issue 'loadVars()' and try to access that table that was saved.
This fails, with the table being a 'nil' instead of any table existing.
I've managed to work around this by using table.save() and table.load() for saving my table Variables, but this is extremely cumbersome and using external files to save internal variables is inefficient. Would there be a way to save the table variables WITH Mudlet's 'remember()' command, or another way that would ensure the table would be properly initiated instead of using table.save() and load()? I'd like to minimize the external files I'm using, and would really rather not have them at all for the many table instances I'll be creating.
Thanks.