add setting to disable 3d quiver

This commit is contained in:
Juraj Vajda 2022-10-31 20:49:08 -04:00
parent 4b761b2388
commit 1e6a206b18
4 changed files with 41 additions and 24 deletions

11
api.lua
View File

@ -45,7 +45,8 @@ XBows = {
player_bow_sneak = {}, player_bow_sneak = {},
settings = { settings = {
x_bows_attach_arrows_to_entities = minetest.settings:get_bool('x_bows_attach_arrows_to_entities', false), x_bows_attach_arrows_to_entities = minetest.settings:get_bool('x_bows_attach_arrows_to_entities', false),
x_bows_show_damage_numbers = minetest.settings:get_bool('x_bows_show_damage_numbers', false) x_bows_show_damage_numbers = minetest.settings:get_bool('x_bows_show_damage_numbers', false),
x_bows_show_3d_quiver = minetest.settings:get_bool('x_bows_show_3d_quiver', true)
}, },
charge_sound_after_job = {}, charge_sound_after_job = {},
fallback_quiver = not minetest.global_exists('sfinv') and not minetest.global_exists('unified_inventory') and not minetest.global_exists('i3') fallback_quiver = not minetest.global_exists('sfinv') and not minetest.global_exists('unified_inventory') and not minetest.global_exists('i3')
@ -2259,6 +2260,10 @@ function XBowsQuiver.ui_register_page(self)
end end
function XBowsQuiver.show_3d_quiver(self, player, props) function XBowsQuiver.show_3d_quiver(self, player, props)
if not XBows.settings.x_bows_show_3d_quiver then
return
end
local _props = props or {} local _props = props or {}
local p_name = player:get_player_name() local p_name = player:get_player_name()
local quiver_texture = 'x_bows_quiver_mesh.png' local quiver_texture = 'x_bows_quiver_mesh.png'
@ -2328,6 +2333,10 @@ function XBowsQuiver.show_3d_quiver(self, player, props)
end end
function XBowsQuiver.hide_3d_quiver(self, player) function XBowsQuiver.hide_3d_quiver(self, player)
if not XBows.settings.x_bows_show_3d_quiver then
return
end
local p_name = player:get_player_name() local p_name = player:get_player_name()
local player_textures local player_textures

View File

@ -33,10 +33,12 @@ minetest.register_on_joinplayer(function(player)
local inv_quiver = player:get_inventory()--[[@as InvRef]] local inv_quiver = player:get_inventory()--[[@as InvRef]]
local inv_arrow = player:get_inventory()--[[@as InvRef]] local inv_arrow = player:get_inventory()--[[@as InvRef]]
if XBows._3d_armor then if XBows.settings.x_bows_show_3d_quiver then
player_api.set_model(player, 'x_bows_3d_armor_character.b3d') if XBows._3d_armor then
else player_api.set_model(player, 'x_bows_3d_armor_character.b3d')
player_api.set_model(player, 'x_bows_character.b3d') else
player_api.set_model(player, 'x_bows_character.b3d')
end
end end
inv_quiver:set_size('x_bows:quiver_inv', 1 * 1) inv_quiver:set_size('x_bows:quiver_inv', 1 * 1)
@ -78,24 +80,26 @@ if XBows._3d_armor then
model_name = 'x_bows_3d_armor_character.b3d' model_name = 'x_bows_3d_armor_character.b3d'
end end
player_api.register_model(model_name, { if XBows.settings.x_bows_show_3d_quiver then
animation_speed = 30, player_api.register_model(model_name, {
textures = {'character.png'}, animation_speed = 30,
animations = { textures = {'character.png'},
-- Standard animations. animations = {
stand = {x = 0, y = 79}, -- Standard animations.
lay = {x = 162, y = 166, eye_height = 0.3, override_local = true, stand = {x = 0, y = 79},
collisionbox = {-0.6, 0.0, -0.6, 0.6, 0.3, 0.6}}, lay = {x = 162, y = 166, eye_height = 0.3, override_local = true,
walk = {x = 168, y = 187}, collisionbox = {-0.6, 0.0, -0.6, 0.6, 0.3, 0.6}},
mine = {x = 189, y = 198}, walk = {x = 168, y = 187},
walk_mine = {x = 200, y = 219}, mine = {x = 189, y = 198},
sit = {x = 81, y = 160, eye_height = 0.8, override_local = true, walk_mine = {x = 200, y = 219},
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.0, 0.3}} sit = {x = 81, y = 160, eye_height = 0.8, override_local = true,
}, collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.0, 0.3}}
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}, },
stepheight = 0.6, collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
eye_height = 1.47 stepheight = 0.6,
}) eye_height = 1.47
})
end
---formspec callbacks ---formspec callbacks
minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info) minetest.register_allow_player_inventory_action(function(player, action, inventory, inventory_info)

View File

@ -3,3 +3,7 @@ x_bows_attach_arrows_to_entities (Attach arrows to entities) bool false
# Shows caused damage number flying out from the hit object/player. # Shows caused damage number flying out from the hit object/player.
x_bows_show_damage_numbers (Show damage caused) bool false x_bows_show_damage_numbers (Show damage caused) bool false
# Shows 3d quiver in 3rd person view (3d armor, and some skins MODs supported - see optional dependencies)
x_bows_show_3d_quiver (Show 3D Quiver) bool true

View File

@ -14,7 +14,7 @@
---@field registered_particle_spawners table<string, ParticlespawnerDef|ParticlespawnerDefCustom> ---@field registered_particle_spawners table<string, ParticlespawnerDef|ParticlespawnerDefCustom>
---@field registered_entities table<string, XBowsEntityDef> ---@field registered_entities table<string, XBowsEntityDef>
---@field player_bow_sneak table<string, table<string, boolean>> ---@field player_bow_sneak table<string, table<string, boolean>>
---@field settings table ---@field settings {["x_bows_attach_arrows_to_entities"]: boolean, ["x_bows_show_damage_numbers"]: boolean, ["x_bows_show_3d_quiver"]: boolean}
---@field quiver table Quiver class ---@field quiver table Quiver class
---@field charge_sound_after_job table<string, JobTable> ---@field charge_sound_after_job table<string, JobTable>
---@field is_allowed_ammunition fun(self: XBows, weapon_name: string, ammo_name: string): boolean Check if ammunition is allowed to charge this weapon ---@field is_allowed_ammunition fun(self: XBows, weapon_name: string, ammo_name: string): boolean Check if ammunition is allowed to charge this weapon