Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- pastebin run kqBFGcfV
- pastebin get kqBFGcfV miscFuncs.lua
- ]]--
- function saveVar(name, value)
- local file = fs.open("variables/" .. name, "w")
- file.write(textutils.serialize(value))
- file.close()
- end
- function loadVar(name)
- if(not fs.exists(name)) then
- return nil
- end
- local file = fs.open("variables/" .. name, "r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- function hasVar(name)
- return fs.exists(name)
- end
- function dump(o)
- if type(o) == 'table' then
- local s = '{ '
- for k,v in pairs(o) do
- if type(k) ~= 'number' then k = '"'..k..'"' end
- s = s .. '['..k..'] = ' .. dump(v) .. ','
- end
- return s .. '} '
- else
- return tostring(o)
- end
- end
- function printDump(o)
- print(dump(o))
- end
- function tableClone(orig)
- local orig_type = type(orig)
- local copy
- if orig_type == 'table' then
- copy = {}
- for orig_key, orig_value in next, orig, nil do
- copy[tableClone(orig_key)] = tableClone(orig_value)
- end
- setmetatable(copy, tableClone(getmetatable(orig)))
- else -- number, string, boolean, etc
- copy = orig
- end
- return copy
- end
- function itemsEqual(item1, item2)
- return (item1.name == item2.name and item1.damage == item2.damage and item1.nbtHash == item2.nbtHash)
- end
Advertisement
Add Comment
Please, Sign In to add comment