mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-05-21 06:43:17 -04:00
Redo backwards compatibility hack
This commit is contained in:
parent
e03266dd4f
commit
ec9c227062
2 changed files with 9 additions and 17 deletions
|
@ -73,7 +73,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
||||||
|
|
||||||
player:set_look_horizontal(math.random(1, 180) / 100)
|
player:set_look_horizontal(math.random(1, 180) / 100)
|
||||||
player_api.player_attached[name] = false
|
player_api.player_attached[name] = false
|
||||||
player:set_physics_override(1, 1, 1)
|
--player:set_physics_override(1, 1, 1)
|
||||||
hud_flags.wielditem = true
|
hud_flags.wielditem = true
|
||||||
player_api.set_animation(player, "stand" , 30)
|
player_api.set_animation(player, "stand" , 30)
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
||||||
y = bed_pos.y + 0.07,
|
y = bed_pos.y + 0.07,
|
||||||
z = bed_pos.z + dir.z / 2
|
z = bed_pos.z + dir.z / 2
|
||||||
}
|
}
|
||||||
player:set_physics_override(0, 0, 0)
|
--player:set_physics_override(0, 0, 0)
|
||||||
player:set_pos(p)
|
player:set_pos(p)
|
||||||
player_api.player_attached[name] = true
|
player_api.player_attached[name] = true
|
||||||
hud_flags.wielditem = false
|
hud_flags.wielditem = false
|
||||||
|
|
|
@ -49,7 +49,7 @@ local players = {}
|
||||||
player_api.player_attached = {}
|
player_api.player_attached = {}
|
||||||
|
|
||||||
local function get_player_data(player)
|
local function get_player_data(player)
|
||||||
return assert(players[player:get_player_name()], "offline_player")
|
return assert(players[player:get_player_name()])
|
||||||
end
|
end
|
||||||
|
|
||||||
function player_api.get_animation(player)
|
function player_api.get_animation(player)
|
||||||
|
@ -183,22 +183,14 @@ minetest.register_globalstep(function()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- HACK for keeping backwards compatibility
|
|
||||||
for _, api_function in pairs({"get_animation", "set_animation", "set_model", "set_textures"}) do
|
for _, api_function in pairs({"get_animation", "set_animation", "set_model", "set_textures"}) do
|
||||||
local original_function = player_api[api_function]
|
local original_function = player_api[api_function]
|
||||||
player_api[api_function] = function(...)
|
player_api[api_function] = function(player, ...)
|
||||||
local arguments = {...}
|
if not players[player:get_player_name()] then
|
||||||
local ret -- single value works because get_animation returns only one value
|
-- HACK for keeping backwards compatibility
|
||||||
local status, err = pcall(function()
|
minetest.log("warning", api_function .. " called on offline player")
|
||||||
ret = original_function(unpack(arguments))
|
return
|
||||||
end)
|
|
||||||
if not status then
|
|
||||||
if err == "offline_player" then
|
|
||||||
minetest.log("warning", api_function .. " called on offline player")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
error(err)
|
|
||||||
end
|
end
|
||||||
return ret
|
original_function(player, ...)
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Add table
Reference in a new issue