add 3d quiver support for skinsdb and bugfix for quiver on_take
This commit is contained in:
parent
1e6a206b18
commit
160fb29d34
|
@ -67,5 +67,7 @@ read_globals = {
|
|||
"player_api",
|
||||
"u_skins",
|
||||
"wardrobe",
|
||||
"3d_armor"
|
||||
"3d_armor",
|
||||
"skinsdb",
|
||||
"skins"
|
||||
}
|
||||
|
|
53
api.lua
53
api.lua
|
@ -37,6 +37,7 @@ XBows = {
|
|||
u_skins = minetest.get_modpath('u_skins'),
|
||||
wardrobe = minetest.get_modpath('wardrobe'),
|
||||
_3d_armor = minetest.get_modpath('3d_armor'),
|
||||
skinsdb = minetest.get_modpath('skinsdb'),
|
||||
registered_bows = {},
|
||||
registered_arrows = {},
|
||||
registered_quivers = {},
|
||||
|
@ -2273,7 +2274,34 @@ function XBowsQuiver.show_3d_quiver(self, player, props)
|
|||
quiver_texture = 'x_bows_quiver_empty_mesh.png'
|
||||
end
|
||||
|
||||
if self._3d_armor then
|
||||
if self.skinsdb then
|
||||
minetest.after(1, function()
|
||||
local textures = player_api.get_textures(player)
|
||||
|
||||
---cleanup
|
||||
for index, value in ipairs(textures) do
|
||||
if value == 'x_bows_quiver_blank_mesh.png' or value == 'x_bows_quiver_mesh.png' or value == 'x_bows_quiver_empty_mesh.png' then
|
||||
table.remove(textures, index)
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(textures, quiver_texture)
|
||||
|
||||
player_textures = textures
|
||||
|
||||
if player_textures then
|
||||
if _props.is_empty and not self.quiver_empty_state[player:get_player_name()] then
|
||||
self.quiver_empty_state[player:get_player_name()] = true
|
||||
player_api.set_textures(player, player_textures)
|
||||
elseif not _props.is_empty and self.quiver_empty_state[player:get_player_name()] then
|
||||
self.quiver_empty_state[player:get_player_name()] = false
|
||||
player_api.set_textures(player, player_textures)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
return
|
||||
elseif self._3d_armor then
|
||||
minetest.after(0.1, function()
|
||||
player_textures = {
|
||||
armor.textures[p_name].skin,
|
||||
|
@ -2340,7 +2368,28 @@ function XBowsQuiver.hide_3d_quiver(self, player)
|
|||
local p_name = player:get_player_name()
|
||||
local player_textures
|
||||
|
||||
if self._3d_armor then
|
||||
if self.skinsdb then
|
||||
minetest.after(1, function()
|
||||
local textures = player_api.get_textures(player)
|
||||
|
||||
---cleanup
|
||||
for index, value in ipairs(textures) do
|
||||
if value == 'x_bows_quiver_mesh.png' or value == 'x_bows_quiver_blank_mesh.png' or value == 'x_bows_quiver_empty_mesh.png' then
|
||||
table.remove(textures, index)
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(textures, 'x_bows_quiver_blank_mesh.png')
|
||||
|
||||
player_textures = textures
|
||||
|
||||
if player_textures then
|
||||
player_api.set_textures(player, player_textures)
|
||||
end
|
||||
end)
|
||||
|
||||
return
|
||||
elseif self._3d_armor then
|
||||
minetest.after(0.1, function()
|
||||
player_textures = {
|
||||
armor.textures[p_name].skin,
|
||||
|
|
32
init.lua
32
init.lua
|
@ -1,13 +1,13 @@
|
|||
-- X Bows
|
||||
-- by SaKeL
|
||||
|
||||
minetest = minetest--[[@as Minetest]]
|
||||
ItemStack = ItemStack--[[@as ItemStack]]
|
||||
vector = vector--[[@as Vector]]
|
||||
default = default--[[@as MtgDefault]]
|
||||
sfinv = sfinv--[[@as Sfinv]]
|
||||
unified_inventory = unified_inventory--[[@as UnifiedInventory]]
|
||||
player_api = player_api--[[@as MtgPlayerApi]]
|
||||
minetest = minetest.global_exists('minetest') and minetest--[[@as Minetest]]
|
||||
ItemStack = minetest.global_exists('ItemStack') and ItemStack--[[@as ItemStack]]
|
||||
vector = minetest.global_exists('vector') and vector--[[@as Vector]]
|
||||
default = minetest.global_exists('default') and default--[[@as MtgDefault]]
|
||||
sfinv = minetest.global_exists('sfinv') and sfinv--[[@as Sfinv]]
|
||||
unified_inventory = minetest.global_exists('unified_inventory') and unified_inventory--[[@as UnifiedInventory]]
|
||||
player_api = minetest.global_exists('player_api') and player_api--[[@as MtgPlayerApi]]
|
||||
|
||||
math.randomseed(tonumber(tostring(os.time()):reverse():sub(1, 9))--[[@as number]])
|
||||
|
||||
|
@ -34,7 +34,10 @@ minetest.register_on_joinplayer(function(player)
|
|||
local inv_arrow = player:get_inventory()--[[@as InvRef]]
|
||||
|
||||
if XBows.settings.x_bows_show_3d_quiver then
|
||||
if XBows._3d_armor then
|
||||
---Order matters here
|
||||
if XBows.skinsdb then
|
||||
player_api.set_model(player, 'skinsdb_3d_armor_character_5.b3d')
|
||||
elseif XBows._3d_armor then
|
||||
player_api.set_model(player, 'x_bows_3d_armor_character.b3d')
|
||||
else
|
||||
player_api.set_model(player, 'x_bows_character.b3d')
|
||||
|
@ -74,13 +77,17 @@ minetest.register_on_joinplayer(function(player)
|
|||
XBowsQuiver:close_quiver(player)
|
||||
end)
|
||||
|
||||
if XBows.settings.x_bows_show_3d_quiver then
|
||||
local model_name = 'x_bows_character.b3d'
|
||||
if XBows._3d_armor then
|
||||
|
||||
if XBows.skinsdb then
|
||||
---skinsdb
|
||||
model_name = 'skinsdb_3d_armor_character_5.b3d'
|
||||
elseif XBows._3d_armor then
|
||||
---3d armor
|
||||
model_name = 'x_bows_3d_armor_character.b3d'
|
||||
end
|
||||
|
||||
if XBows.settings.x_bows_show_3d_quiver then
|
||||
player_api.register_model(model_name, {
|
||||
animation_speed = 30,
|
||||
textures = {'character.png'},
|
||||
|
@ -269,6 +276,11 @@ minetest.register_on_player_inventory_action(function(player, action, inventory,
|
|||
else
|
||||
sfinv.set_player_inventory_formspec(player)
|
||||
end
|
||||
|
||||
---set player visual
|
||||
if inventory:is_empty(inventory_info.listname) then
|
||||
XBowsQuiver:hide_3d_quiver(player)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
2
mod.conf
2
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
|
||||
optional_depends = default, farming, 3d_armor, mesecons, playerphysics, player_monoids, wool, i3, unified_inventory, simple_skins, u_skins, wardrobe, sfinv, skinsdb
|
||||
supported_games = minetest_game
|
||||
min_minetest_version = 5.4
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -8,6 +8,7 @@
|
|||
---@field u_skins string|nil
|
||||
---@field wardrobe string|nil
|
||||
---@field _3d_armor string|nil
|
||||
---@field skinsdb string|nil
|
||||
---@field registered_bows table<string, ItemDef|BowItemDefCustom>
|
||||
---@field registered_arrows table<string, ItemDef|ArrowItemDefCustom>
|
||||
---@field registered_quivers table<string, ItemDef|QuiverItemDefCustom>
|
||||
|
|
Ŝarĝante…
Reference in New Issue