I've made a more general purpose data save/load script, which relies on
serpent(MIT license) as serializer.
Here you can find it.
Basic usage:
(nm is the name of the data table and the savefile like %appdata%/data/<nm>.txt)
Code: Select all
GAME.EZF:CreateNewData(nm[,tbl]) --creates a new data table for data to store in (if you provide it with a table(tbl)) its merged in right away
GAME.EZF:ChangeData(nm,tbl) --merges new data into the table[nm]
GAME.EZF:SaveData(nm) --serializes and saves the datainto the file of name <nm>
GAME.EZF:LoadDataInto(nm,itbl,func) --creates data of name <nm>, and loads the file deserialized into the provided itbl table ,the func should be a callback function if the itbl changes but somehow doesn'T work consistently (just leave it out/remove or fix that part)
GAME is my global table to store everything in you may wanna change it in the first line. Or change the entire code (permission granted CC0 etc.)
This way i have a file for my options, one for my last console entries and can easily expand for whatever i need a new file. It's functional but not 100% done.
And it's restricted to only save strings,numbers and bools but can be expanded via the whitelist table.
EDIT:
For buttons you can use my
UI_Base and
Button (CC BY-NC-SA 3.0)scripts if you want.
They might not function out of the box for your problem because you have to make sure to load UI_Base, then Button.lua (which i manage with my folder structure)
EDIT2:Also they rely on my implementation of hooks, ScrW,ScrH(as short fucntions for screen width and height), and a varfuncthat creates set and getfunctions like:
Code: Select all
function VarFunc(tbl,name,default)
tbl[name] = default
tbl["Get"..name] = function(self)
return self[name]
end
tbl["Set"..name] = function(self,v)
self[name] = v
end
end
But it lets you easily create a button like:
local Button = UI("Button"[,Xpos,Ypos,width,height,rotation])
And has a nice Button:Align(enable,X,Y,W,H,Xoffset,Yoffset,Woffset,Hoffset) that sizes your button in real time as the window resizes or the the parent of it etc. If you write 'false' where X,Y,W and/or H belongs it takes the standard values there and the respective offset is also ignored.
If you don't wanna use it you can still reverse engineer it for learning purpose if you can read my code^^ (they got many more functions that might be useful for you)