summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Stolberg <joe.stolberg@gmx.de>2018-02-16 23:15:01 +0100
committerJoachim Stolberg <joe.stolberg@gmx.de>2018-02-16 23:15:01 +0100
commit0ef44f7342f9c18df5af9c1b942089a3953f0f54 (patch)
tree99f3368e947f3b7e1482b010d097d67164c159c0
parent61f51db8c3f962cb3223680fa06944c27865acd1 (diff)
reset from fly mode improved
-rw-r--r--init.lua22
1 files changed, 14 insertions, 8 deletions
diff --git a/init.lua b/init.lua
index 2c0620e..f2f9cce 100644
--- a/init.lua
+++ b/init.lua
@@ -111,18 +111,15 @@ local function fly_privs(player, enable)
local physics = player:get_physics_override()
if privs then
if enable == true then
- player:set_attribute("store_fast", minetest.serialize(privs["fast"]))
- player:set_attribute("store_fly", minetest.serialize(privs["fly"]))
- player:set_attribute("store_speed", minetest.serialize(physics.speed))
- player:set_attribute("crane_active", "true")
+ player:set_attribute("tower_crane_active", "true")
privs["fly"] = true
privs["fast"] = nil
physics.speed = 0.7
else
- privs["fast"] = minetest.deserialize(player:get_attribute("store_fast"))
- privs["fly"] = minetest.deserialize(player:get_attribute("store_fly"))
- physics.speed = minetest.deserialize(player:get_attribute("store_speed"))
- player:set_attribute("crane_active", nil)
+ privs["fast"] = minetest.deserialize(player:get_attribute("tower_crane_store_fast"))
+ privs["fly"] = minetest.deserialize(player:get_attribute("tower_crane_store_fly"))
+ physics.speed = minetest.deserialize(player:get_attribute("tower_crane_store_speed"))
+ player:set_attribute("tower_crane_active", nil)
end
player:set_physics_override(physics)
minetest.set_player_privs(player:get_player_name(), privs)
@@ -724,6 +721,15 @@ if towercrane.recipe then
})
end
+-- store standard player privs
+minetest.register_on_joinplayer(function(player)
+ local privs = minetest.get_player_privs(player:get_player_name())
+ local physics = player:get_physics_override()
+ player:set_attribute("tower_crane_store_fast", minetest.serialize(privs["fast"]))
+ player:set_attribute("tower_crane_store_fly", minetest.serialize(privs["fly"]))
+ player:set_attribute("tower_crane_store_speed", minetest.serialize(physics.speed))
+end)
+
-- switch back to normal player privs
minetest.register_on_leaveplayer(function(player, timed_out)
remove_hook(nil, player)