improved mcl compatibility

This commit is contained in:
Alexsandro Percy 2023-08-08 21:19:49 -03:00
parent f058f30be2
commit 3a5244c721
4 changed files with 18 additions and 14 deletions

View file

@ -20,6 +20,9 @@ airutils.colors ={
yellow='#ffe400',
}
airutils.is_minetest = minetest.get_modpath("player_api")
airutils.is_mcl = minetest.get_modpath("mcl_player")
airutils.fuel = {['biofuel:biofuel'] = 1,['biofuel:bottle_fuel'] = 1,
['biofuel:phial_fuel'] = 0.25, ['biofuel:fuel_can'] = 10}

View file

@ -3,7 +3,7 @@ airutils.modname = minetest.get_current_modname()
--function to format formspec for mineclone. In case of minetest, just returns an empty string
local function get_itemslot_bg(a, b, c, d)
if not minetest.get_modpath("player_api") then
if airutils.is_mcl then
return mcl_formspec.get_itemslot_bg(a,b,c,d)
end
return ""
@ -12,7 +12,7 @@ end
local function get_formspec_by_size(self, size)
local background = ""
local hotbar = ""
local is_minetest_game = minetest.get_modpath("player_api") or false
local is_minetest_game = airutils.is_minetest or false
if is_minetest_game then
background = background .. default.gui_bg .. default.gui_bg_img .. default.gui_slots
hotbar = default.get_hotbar_bg(0,4.85)

View file

@ -654,6 +654,7 @@ function airutils.on_punch(self, puncher, ttime, toolcaps, dir, damage)
-- deal with painting or destroying
if itmstck then
if airutils.set_param_paint(self, puncher, itmstck, 1) == false then
if not self.driver and toolcaps and toolcaps.damage_groups
and toolcaps.groupcaps and toolcaps.groupcaps.choppy and item_name ~= airutils.fuel then
--airutils.hurt(self,toolcaps.damage_groups.fleshy - 1)

View file

@ -56,10 +56,10 @@ function airutils.attach(self, player, instructor_mode)
end
player:set_eye_offset({x = 0, y = eye_y, z = 2}, {x = 0, y = 1, z = -30})
if minetest.get_modpath("player_api") then
if airutils.is_minetest then
player_api.player_attached[name] = true
player_api.set_animation(player, "sit")
elseif minetest.get_modpath("mcl_player") then
elseif airutils.is_mcl then
airutils.sit(player)
end
@ -90,10 +90,10 @@ function airutils.dettachPlayer(self, player)
if player then
player:set_detach()
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
if minetest.get_modpath("player_api") then
if airutils.is_minetest then
player_api.player_attached[name] = nil
player_api.set_animation(player, "stand")
elseif minetest.get_modpath("mcl_player") then
elseif airutils.is_mcl then
mcl_player.player_attached[name] = nil
mcl_player.player_set_animation(player, "stand")
end
@ -124,10 +124,10 @@ local function attach_copilot(self, name, player, eye_y)
-- attach the driver
player:set_attach(self.co_pilot_seat_base, "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
player:set_eye_offset({x = 0, y = eye_y, z = 2}, {x = 0, y = 3, z = -30})
if minetest.get_modpath("player_api") then
if airutils.is_minetest then
player_api.player_attached[name] = true
player_api.set_animation(player, "sit")
elseif minetest.get_modpath("mcl_player") then
elseif airutils.is_mcl then
mcl_player.player_attached[name] = true
airutils.sit(player)
end
@ -186,10 +186,10 @@ function airutils.attach_pax(self, player, is_copilot)
player:set_attach(self._passengers_base[i], "", {x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
player:set_eye_offset({x = 0, y = eye_y, z = 0}, {x = 0, y = 3, z = -30})
if minetest.get_modpath("player_api") then
if airutils.is_minetest then
player_api.player_attached[name] = true
player_api.set_animation(player, "sit")
elseif minetest.get_modpath("mcl_player") then
elseif airutils.is_mcl then
mcl_player.player_attached[name] = true
airutils.sit(player)
end
@ -231,10 +231,10 @@ function airutils.dettach_pax(self, player)
if player then
player:set_detach()
if minetest.get_modpath("player_api") then
if airutils.is_minetest then
player_api.player_attached[name] = nil
player_api.set_animation(player, "stand")
elseif minetest.get_modpath("mcl_player") then
elseif airutils.is_mcl then
mcl_player.player_attached[name] = nil
mcl_player.player_set_animation(player, "stand")
end
@ -914,10 +914,10 @@ local function do_attach(self, player, slot)
end
player:set_eye_offset({x = 0, y = eye_y, z = 2}, {x = 0, y = 3, z = -30})
if minetest.get_modpath("player_api") then
if airutils.is_minetest then
player_api.player_attached[name] = true
player_api.set_animation(player, "sit")
elseif minetest.get_modpath("mcl_player") then
elseif airutils.is_mcl then
mcl_player.player_attached[name] = true
airutils.sit(player)
end