Switch caged from privs to player attributes

This commit is contained in:
ezhh 2017-10-16 14:41:06 +01:00
parent 4dbe4fa590
commit 3ebd63f4b4

View File

@ -1,5 +1,4 @@
minetest.register_privilege("secret", "Wouldn't you like to know?") minetest.register_privilege("secret", "Wouldn't you like to know?")
minetest.register_privilege("caged", {description = "Not going anywhere...", give_to_singleplayer=false})
minetest.register_privilege("hidden_one", {description = "Can hide from players.", give_to_singleplayer=false}) minetest.register_privilege("hidden_one", {description = "Can hide from players.", give_to_singleplayer=false})
@ -220,9 +219,8 @@ minetest.register_chatcommand("cage", {
minetest.chat_send_player(warden_name,"Player does not exist") minetest.chat_send_player(warden_name,"Player does not exist")
return return
end end
-- get target player's privs or return -- return if already caged
local privs = minetest.get_player_privs(target_name) if target:get_attribute("caged") == "true" then
if privs.caged == true then
minetest.chat_send_player(warden_name,"This player is already caged") minetest.chat_send_player(warden_name,"This player is already caged")
return return
end end
@ -233,10 +231,12 @@ minetest.register_chatcommand("cage", {
return return
end end
-- add current target privs to table and save to file -- add current target privs to table and save to file
local privs = minetest.get_player_privs(target_name)
priv_table[target_name] = privs priv_table[target_name] = privs
table_save() table_save()
-- remove all privs but shout and add caged and unglitched -- remove all privs but shout and add caged and unglitched
minetest.set_player_privs(target_name,{shout = true, caged = true}) minetest.set_player_privs(target_name,{shout = true})
target:set_attribute("caged", "true")
noglitch(warden_name, target_name) noglitch(warden_name, target_name)
-- move target to cage location -- move target to cage location
target:setpos(cagepos) target:setpos(cagepos)
@ -255,9 +255,8 @@ minetest.register_chatcommand("uncage", {
minetest.chat_send_player(warden_name,"Player does not exist") minetest.chat_send_player(warden_name,"Player does not exist")
return return
end end
-- get target player's privs or return -- return if not caged
local privs = minetest.get_player_privs(target_name) if target:get_attribute("caged") ~= "true" then
if privs.caged ~= true then
minetest.chat_send_player(warden_name,"This player is not caged") minetest.chat_send_player(warden_name,"This player is not caged")
return return
end end
@ -275,6 +274,8 @@ minetest.register_chatcommand("uncage", {
table_save() table_save()
-- restore sneak and move target to release point -- restore sneak and move target to release point
target:set_physics_override({sneak = true}) target:set_physics_override({sneak = true})
target:set_attribute("unglitched", "")
target:set_attribute("caged", "")
target:setpos(releasepos) target:setpos(releasepos)
end end
}) })