Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Config API - (c) monster010
- local cfg = {}
- local pfad = ""
- function load(path)
- pfad = path
- if fs.exists(pfad) then
- local file = fs.open(pfad, "r")
- cfg = textutils.unserialize(file.readAll())
- file.close()
- else
- create()
- end
- end
- function create()
- local file = fs.open(pfad, "a")
- file.close()
- end
- function save()
- local file = fs.open(pfad, "w")
- file.write(textutils.serialize(cfg))
- file.close()
- end
- function getConfig()
- return cfg
- end
- function get(key)
- return cfg[key]
- end
- function set(key, val)
- cfg[key] = val
- save()
- end
Advertisement
Add Comment
Please, Sign In to add comment