Code: Select all
function tableSave(name,tablename)
if string.char(getMudletHomeDir():byte()) == "/" then _sep = "/" else _sep = "\\" end
local filename = getMudletHomeDir() .. _sep .. name .. ".lua"
table.save(filename, tablename)
end -- func
function tableLoad(name,tablename)
loaded = false
if string.char(getMudletHomeDir():byte()) == "/" then _sep = "/" else _sep = "\\" end
local filename = getMudletHomeDir() .. _sep .. name .. ".lua"
if (io.exists(filename)) then
table.load(filename, tablename)
loaded = true
else
loaded = false
end -- if
return loaded
end -- function
I use these quite extensively because I have a lot of tables that contain data I want to survive between sessions.
while these seem to work fine, I've experienced -some- frustration with the limited abilities these functions impart. For instance, I have to make a whole separate function if I wanted to actually see if it's loaded or not
Code: Select all
function loadSystemTable()
loadTable("systemVariables", sys.var)
if loaded then
cecho("system variables loaded fine.")
else
cecho("Error loading system variables.")
end -- if
end -- function
And for the second part of my request, anyone mind giving me a nudge in the direction on how to script a compare function, for whenever I exit mudlet, it will compare the tables saved in mudlet, and the tables saved on my computer, and if there are differences, overwrite the ones on the computer with the new data? I ask this, because I currently have the unefficient method of just saving the table after -every- change, and that can bog down my decade old laptop.
Thanks in advance!