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,11 +33,13 @@ 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.settings.x_bows_show_3d_quiver then
if XBows._3d_armor then if XBows._3d_armor then
player_api.set_model(player, 'x_bows_3d_armor_character.b3d') player_api.set_model(player, 'x_bows_3d_armor_character.b3d')
else else
player_api.set_model(player, 'x_bows_character.b3d') 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)
inv_arrow:set_size('x_bows:arrow_inv', 1 * 1) inv_arrow:set_size('x_bows:arrow_inv', 1 * 1)
@ -78,6 +80,7 @@ if XBows._3d_armor then
model_name = 'x_bows_3d_armor_character.b3d' model_name = 'x_bows_3d_armor_character.b3d'
end end
if XBows.settings.x_bows_show_3d_quiver then
player_api.register_model(model_name, { player_api.register_model(model_name, {
animation_speed = 30, animation_speed = 30,
textures = {'character.png'}, textures = {'character.png'},
@ -96,6 +99,7 @@ player_api.register_model(model_name, {
stepheight = 0.6, stepheight = 0.6,
eye_height = 1.47 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