backguard compatibility for mount.lua
* close https://notabug.org/TenPlus1/mobs_redo/issues/112 * close https://codeberg.org/minenux/minetest-mod-mobs_redo/issues/106
This commit is contained in:
parent
71ccf3d71b
commit
b49abcc9a4
17
mount.lua
17
mount.lua
@ -4,6 +4,9 @@ local abs, cos, floor, sin, sqrt, pi =
|
||||
math.abs, math.cos, math.floor, math.sin, math.sqrt, math.pi
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
-- check for minetest 5.x compatibility
|
||||
local is_50 = minetest.get_translator or nil
|
||||
|
||||
--
|
||||
-- Helper functions
|
||||
--
|
||||
@ -85,9 +88,15 @@ local function force_detach(player)
|
||||
end
|
||||
|
||||
player:set_detach()
|
||||
if is_50 then
|
||||
player_api.player_attached[player:get_player_name()] = false
|
||||
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||
player_api.set_animation(player, "stand", 30)
|
||||
else
|
||||
default.player_attached[player:get_player_name()] = false
|
||||
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||
default.player_set_animation(player, "stand", 30)
|
||||
end
|
||||
player:set_properties({visual_size = {x = 1, y = 1}})
|
||||
|
||||
end
|
||||
@ -170,7 +179,11 @@ function mobs.attach(entity, player)
|
||||
force_detach(player)
|
||||
|
||||
player:set_attach(entity.object, "", attach_at, entity.player_rotation)
|
||||
if is_50 then
|
||||
player_api.player_attached[player:get_player_name()] = true
|
||||
else
|
||||
default.player_attached[player:get_player_name()] = true
|
||||
end
|
||||
player:set_eye_offset(eye_offset, {x = 0, y = 0, z = 0})
|
||||
|
||||
player:set_properties({
|
||||
@ -183,7 +196,11 @@ function mobs.attach(entity, player)
|
||||
minetest.after(0.2, function()
|
||||
|
||||
if player and player:is_player() then
|
||||
if is_50 then
|
||||
player_api.set_animation(player, "sit", 30)
|
||||
else
|
||||
default.player_set_animation(player, "sit", 30)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user