Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. -- Set up table(s)
  2.     local jails = {}
  3.    
  4. -- Load jail positions
  5.     local savefile  = io.open(minetest.get_worldpath() .. "/jails.data","r")
  6.     local getjails  = savefile:read("*a")
  7.     jails   = minetest.deserialize(getjails)
  8.     savefile:close()
  9.     getjails = nil
  10.    
  11. -- Register command for admin which allows him to create a new jail position
  12.     minetest.register_chatcommand("createjail", {
  13.     params = "",
  14.     description = "Create a new jail position",
  15.     privs   = {admin=true},
  16.     func = function(name, param)
  17.         local admin = minetest.get_player_by_name(name)
  18.         local pos   = admin:getpos()
  19.         local raw   = {
  20.             position    = pos,
  21.             player  = false
  22.         }
  23.         table.insert(jails, raw)
  24.         local prepare4save  = minetest.serialize(jails)
  25.         local savefile  = io.open(minetest.get_worldpath() .. "/jails.data","w")
  26.         savefile:write(prepare4save)
  27.         savefile:close()
  28.     end
  29. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement