Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Set up table(s)
- local jails = {}
- -- Load jail positions
- local savefile = io.open(minetest.get_worldpath() .. "/jails.data","r")
- local getjails = savefile:read("*a")
- jails = minetest.deserialize(getjails)
- savefile:close()
- getjails = nil
- -- Register command for admin which allows him to create a new jail position
- minetest.register_chatcommand("createjail", {
- params = "",
- description = "Create a new jail position",
- privs = {admin=true},
- func = function(name, param)
- local admin = minetest.get_player_by_name(name)
- local pos = admin:getpos()
- local raw = {
- position = pos,
- player = false
- }
- table.insert(jails, raw)
- local prepare4save = minetest.serialize(jails)
- local savefile = io.open(minetest.get_worldpath() .. "/jails.data","w")
- savefile:write(prepare4save)
- savefile:close()
- end
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement