From 7194800898bfc85ed57ee31f0a69f3aa0ccec6cc Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Tue, 1 Nov 2022 23:10:47 -0400 Subject: [PATCH] Add checks for player_api mod --- README.md | 2 ++ api.lua | 5 +++-- init.lua | 4 ++-- mod.conf | 2 +- types/xbows.type.lua | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cdc3f2a..4ab91ae 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,8 @@ There are few indications on how to know when the bow shot arrow from quiver: - u_skins - wardrobe - sfinv +- skinsdb +- player_api (shows 3d quiver) ## License: diff --git a/api.lua b/api.lua index e5af107..3f2efdd 100644 --- a/api.lua +++ b/api.lua @@ -38,6 +38,7 @@ XBows = { wardrobe = minetest.get_modpath('wardrobe'), _3d_armor = minetest.get_modpath('3d_armor'), skinsdb = minetest.get_modpath('skinsdb'), + player_api = minetest.get_modpath('player_api'), registered_bows = {}, registered_arrows = {}, registered_quivers = {}, @@ -2261,7 +2262,7 @@ function XBowsQuiver.ui_register_page(self) end function XBowsQuiver.show_3d_quiver(self, player, props) - if not XBows.settings.x_bows_show_3d_quiver then + if not XBows.settings.x_bows_show_3d_quiver or not XBows.player_api then return end @@ -2361,7 +2362,7 @@ function XBowsQuiver.show_3d_quiver(self, player, props) end function XBowsQuiver.hide_3d_quiver(self, player) - if not XBows.settings.x_bows_show_3d_quiver then + if not XBows.settings.x_bows_show_3d_quiver or not XBows.player_api then return end diff --git a/init.lua b/init.lua index 7d793e6..49de82a 100644 --- a/init.lua +++ b/init.lua @@ -33,7 +33,7 @@ minetest.register_on_joinplayer(function(player) local inv_quiver = player:get_inventory()--[[@as InvRef]] local inv_arrow = player:get_inventory()--[[@as InvRef]] - if XBows.settings.x_bows_show_3d_quiver then + if XBows.settings.x_bows_show_3d_quiver and XBows.player_api then ---Order matters here if XBows.skinsdb then player_api.set_model(player, 'skinsdb_3d_armor_character_5.b3d') @@ -77,7 +77,7 @@ minetest.register_on_joinplayer(function(player) XBowsQuiver:close_quiver(player) end) -if XBows.settings.x_bows_show_3d_quiver then +if XBows.settings.x_bows_show_3d_quiver and XBows.player_api then local model_name = 'x_bows_character.b3d' if XBows.skinsdb then diff --git a/mod.conf b/mod.conf index 6a838e5..2963336 100644 --- a/mod.conf +++ b/mod.conf @@ -1,6 +1,6 @@ name = x_bows description = Adds bow and arrows to Minetest. depends = -optional_depends = default, farming, 3d_armor, mesecons, playerphysics, player_monoids, wool, i3, unified_inventory, simple_skins, u_skins, wardrobe, sfinv, skinsdb +optional_depends = default, farming, 3d_armor, mesecons, playerphysics, player_monoids, wool, i3, unified_inventory, simple_skins, u_skins, wardrobe, sfinv, skinsdb, player_api supported_games = minetest_game min_minetest_version = 5.4 diff --git a/types/xbows.type.lua b/types/xbows.type.lua index d1306c3..a813263 100644 --- a/types/xbows.type.lua +++ b/types/xbows.type.lua @@ -9,6 +9,7 @@ ---@field wardrobe string|nil ---@field _3d_armor string|nil ---@field skinsdb string|nil +---@field player_api string|nil ---@field registered_bows table ---@field registered_arrows table ---@field registered_quivers table