Make default sneak mode settable

This commit is contained in:
ezhh 2017-10-22 21:00:08 +01:00
parent 4afd183f47
commit e287b9e245

View File

@ -1,6 +1,7 @@
minetest.register_privilege("secret", "Wouldn't you like to know?")
minetest.register_privilege("hidden_one", {description = "Can hide from players.", give_to_singleplayer=false})
local default_sneak_mode = "old" -- change this to "new" if you want new movement.
-- Admin Curses
@ -102,19 +103,23 @@ minetest.register_on_joinplayer(function(player)
if player:get_attribute("slowed") == "true" then
slowmo(name,name)
end
if player:get_attribute("unglitched") == "true" then
noglitch(name,name)
end
if player:get_attribute("frozen") == "true" then
freeze(name,name)
end
if player:get_attribute("lost") == "true" then
getlost(name,name)
end
-- set sneak mode if unassigned
if player:get_attribute("sneak_mode") == nil then
player:set_attribute("sneak_mode", default_sneak_mode)
end
-- set movement physics based on sneak_mode
if player:get_attribute("sneak_mode") == "old" then
player:set_physics_override({new_move = false, sneak_glitch = true})
player:set_physics_override({new_move = false, sneak_glitch = true, sneak = true})
elseif player:get_attribute("sneak_mode") == "new" then
player:set_physics_override({new_move = true, sneak_glitch = false})
player:set_physics_override({new_move = true, sneak_glitch = false, sneak = true})
elseif player:get_attribute("sneak_mode") == "none" then
player:set_physics_override({sneak = false})
end
end)
@ -274,8 +279,7 @@ minetest.register_chatcommand("uncage", {
priv_table[target_name] = nil
table_save()
-- restore sneak and move target to release point
local mode = "old" -- TODO: need to check conf here
sneak_mode(target, mode)
sneak_mode(target, default_sneak_mode)
target:set_attribute("caged", "")
target:setpos(releasepos)
end