mirror of
https://github.com/minetest-mods/towercrane.git
synced 2024-11-22 15:23:51 +01:00
common player physics lockout mechanism added
This commit is contained in:
parent
1e4f161738
commit
a5cfe4302d
10
control.lua
10
control.lua
@ -71,6 +71,8 @@ local function set_operator_privs(player, pos)
|
|||||||
local privs = minetest.get_player_privs(player:get_player_name())
|
local privs = minetest.get_player_privs(player:get_player_name())
|
||||||
local physics = player:get_physics_override()
|
local physics = player:get_physics_override()
|
||||||
local meta = player:get_meta()
|
local meta = player:get_meta()
|
||||||
|
-- Check access conflicts with other mods
|
||||||
|
if meta:get_int("player_physics_locked") == 0 then
|
||||||
if pos and meta and privs and physics then
|
if pos and meta and privs and physics then
|
||||||
meta:set_string("towercrane_pos", P2S(pos))
|
meta:set_string("towercrane_pos", P2S(pos))
|
||||||
-- store the player privs default values
|
-- store the player privs default values
|
||||||
@ -79,14 +81,18 @@ local function set_operator_privs(player, pos)
|
|||||||
meta:set_int("towercrane_speed", physics.speed)
|
meta:set_int("towercrane_speed", physics.speed)
|
||||||
-- set operator privs
|
-- set operator privs
|
||||||
meta:set_int("towercrane_isoperator", 1)
|
meta:set_int("towercrane_isoperator", 1)
|
||||||
|
meta:set_int("player_physics_locked", 1)
|
||||||
privs["fly"] = true
|
privs["fly"] = true
|
||||||
privs["fast"] = nil
|
privs["fast"] = nil
|
||||||
physics.speed = 0.7
|
physics.speed = 0.7
|
||||||
-- write back
|
-- write back
|
||||||
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)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local function reset_operator_privs(player)
|
local function reset_operator_privs(player)
|
||||||
local privs = minetest.get_player_privs(player:get_player_name())
|
local privs = minetest.get_player_privs(player:get_player_name())
|
||||||
@ -96,6 +102,7 @@ local function reset_operator_privs(player)
|
|||||||
meta:set_string("towercrane_pos", "")
|
meta:set_string("towercrane_pos", "")
|
||||||
-- restore the player privs default values
|
-- restore the player privs default values
|
||||||
meta:set_int("towercrane_isoperator", 0)
|
meta:set_int("towercrane_isoperator", 0)
|
||||||
|
meta:set_int("player_physics_locked", 0)
|
||||||
privs["fast"] = meta:get_string("towercrane_fast") == "true" or nil
|
privs["fast"] = meta:get_string("towercrane_fast") == "true" or nil
|
||||||
privs["fly"] = meta:get_string("towercrane_fly") == "true" or nil
|
privs["fly"] = meta:get_string("towercrane_fly") == "true" or nil
|
||||||
physics.speed = meta:get_int("towercrane_speed")
|
physics.speed = meta:get_int("towercrane_speed")
|
||||||
@ -275,11 +282,12 @@ minetest.register_node("towercrane:mast_ctrl_off", {
|
|||||||
on_rightclick = function (pos, node, clicker)
|
on_rightclick = function (pos, node, clicker)
|
||||||
if is_my_crane(pos, clicker) and not is_operator(clicker) then
|
if is_my_crane(pos, clicker) and not is_operator(clicker) then
|
||||||
start_crane(pos, clicker)
|
start_crane(pos, clicker)
|
||||||
set_operator_privs(clicker, pos)
|
if set_operator_privs(clicker, pos) then
|
||||||
local pos1, pos2 = calc_construction_area(pos)
|
local pos1, pos2 = calc_construction_area(pos)
|
||||||
-- control player every second
|
-- control player every second
|
||||||
minetest.after(1, control_player, pos, pos1, pos2, clicker:get_player_name())
|
minetest.after(1, control_player, pos, pos1, pos2, clicker:get_player_name())
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user