adding features for testing
This commit is contained in:
parent
81c4d0dc49
commit
40bc301e54
53
init.lua
53
init.lua
@ -1,3 +1,29 @@
|
||||
staff = {}
|
||||
|
||||
local f, err = io.open(minetest.get_worldpath() .. "/staff", "r")
|
||||
if f == nil then
|
||||
local f, err = io.open(minetest.get_worldpath() .. "/staff", "w")
|
||||
f:write(minetest.serialize(staff))
|
||||
f:close()
|
||||
end
|
||||
|
||||
function save_table_data()
|
||||
local data = staff
|
||||
local f, err = io.open(minetest.get_worldpath() .. "/staff", "w")
|
||||
if err then
|
||||
return err
|
||||
end
|
||||
f:write(minetest.serialize(data))
|
||||
f:close()
|
||||
end
|
||||
|
||||
function read_table_data()
|
||||
local f, err = io.open(minetest.get_worldpath() .. "/staff", "r")
|
||||
local data = minetest.deserialize(f:read("*a"))
|
||||
f:close()
|
||||
return data
|
||||
end
|
||||
|
||||
-- Shows a message in chat when a player kills another player.
|
||||
minetest.register_on_punchplayer(function(player, hitter, tool_capabilities, damage)
|
||||
local player_hit = player:get_player_name()
|
||||
@ -64,3 +90,30 @@ minetest.register_chatcommand("manipulate", {
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("set_staff", {
|
||||
func = function(name, param)
|
||||
minetest.show_formspec(name, "chat_enhancements:staff_sheet",
|
||||
"size[8,8]" ..
|
||||
"field[1,1;5,1;host;Host:;]" ..
|
||||
"field[1,2.5;5,1;headadmin;Head Admin:;]" ..
|
||||
"field[1,4;5,1;admins;Admins:;]" ..
|
||||
"field[1,5.5;5,1;mods;Moderators:;]" ..
|
||||
"button_exit[1,7;2,1;exit;Close]")
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname == "chat_enhancements:staff_sheet" then
|
||||
table.insert(staff, {host=fields.host,headadmin=fields.headadmin,admins=fields.admins,moderators=fields.mods})
|
||||
save_table_data()
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
staff = read_table_data()
|
||||
local playername = player:get_player_name()
|
||||
if staff.host == playername then
|
||||
player:set_nametag_attributes("color=red")
|
||||
end
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user