mirror of
https://github.com/minetest-mods/towercrane.git
synced 2024-11-22 15:23:51 +01:00
reset from fly mode improved
This commit is contained in:
parent
61f51db8c3
commit
0ef44f7342
22
init.lua
22
init.lua
@ -111,18 +111,15 @@ local function fly_privs(player, enable)
|
|||||||
local physics = player:get_physics_override()
|
local physics = player:get_physics_override()
|
||||||
if privs then
|
if privs then
|
||||||
if enable == true then
|
if enable == true then
|
||||||
player:set_attribute("store_fast", minetest.serialize(privs["fast"]))
|
player:set_attribute("tower_crane_active", "true")
|
||||||
player:set_attribute("store_fly", minetest.serialize(privs["fly"]))
|
|
||||||
player:set_attribute("store_speed", minetest.serialize(physics.speed))
|
|
||||||
player:set_attribute("crane_active", "true")
|
|
||||||
privs["fly"] = true
|
privs["fly"] = true
|
||||||
privs["fast"] = nil
|
privs["fast"] = nil
|
||||||
physics.speed = 0.7
|
physics.speed = 0.7
|
||||||
else
|
else
|
||||||
privs["fast"] = minetest.deserialize(player:get_attribute("store_fast"))
|
privs["fast"] = minetest.deserialize(player:get_attribute("tower_crane_store_fast"))
|
||||||
privs["fly"] = minetest.deserialize(player:get_attribute("store_fly"))
|
privs["fly"] = minetest.deserialize(player:get_attribute("tower_crane_store_fly"))
|
||||||
physics.speed = minetest.deserialize(player:get_attribute("store_speed"))
|
physics.speed = minetest.deserialize(player:get_attribute("tower_crane_store_speed"))
|
||||||
player:set_attribute("crane_active", nil)
|
player:set_attribute("tower_crane_active", nil)
|
||||||
end
|
end
|
||||||
player:set_physics_override(physics)
|
player:set_physics_override(physics)
|
||||||
minetest.set_player_privs(player:get_player_name(), privs)
|
minetest.set_player_privs(player:get_player_name(), privs)
|
||||||
@ -724,6 +721,15 @@ if towercrane.recipe then
|
|||||||
})
|
})
|
||||||
end
|
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
|
-- switch back to normal player privs
|
||||||
minetest.register_on_leaveplayer(function(player, timed_out)
|
minetest.register_on_leaveplayer(function(player, timed_out)
|
||||||
remove_hook(nil, player)
|
remove_hook(nil, player)
|
||||||
|
Loading…
Reference in New Issue
Block a user