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:
mckaygerhard 2022-02-28 17:38:15 -04:00
parent 71ccf3d71b
commit b49abcc9a4

View File

@ -4,6 +4,9 @@ local abs, cos, floor, sin, sqrt, pi =
math.abs, math.cos, math.floor, math.sin, math.sqrt, math.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 -- Helper functions
-- --
@ -85,9 +88,15 @@ local function force_detach(player)
end end
player:set_detach() player:set_detach()
player_api.player_attached[player:get_player_name()] = false if is_50 then
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0}) player_api.player_attached[player:get_player_name()] = false
player_api.set_animation(player, "stand", 30) 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}}) player:set_properties({visual_size = {x = 1, y = 1}})
end end
@ -170,7 +179,11 @@ function mobs.attach(entity, player)
force_detach(player) force_detach(player)
player:set_attach(entity.object, "", attach_at, entity.player_rotation) player:set_attach(entity.object, "", attach_at, entity.player_rotation)
player_api.player_attached[player:get_player_name()] = true 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_eye_offset(eye_offset, {x = 0, y = 0, z = 0})
player:set_properties({ player:set_properties({
@ -183,7 +196,11 @@ function mobs.attach(entity, player)
minetest.after(0.2, function() minetest.after(0.2, function()
if player and player:is_player() then if player and player:is_player() then
player_api.set_animation(player, "sit", 30) if is_50 then
player_api.set_animation(player, "sit", 30)
else
default.player_set_animation(player, "sit", 30)
end
end end
end) end)