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 = {},
settings = {
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 = {},
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
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 p_name = player:get_player_name()
local quiver_texture = 'x_bows_quiver_mesh.png'
@ -2328,6 +2333,10 @@ 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
return
end
local p_name = player:get_player_name()
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_arrow = player:get_inventory()--[[@as InvRef]]
if XBows.settings.x_bows_show_3d_quiver then
if 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')
end
end
inv_quiver:set_size('x_bows:quiver_inv', 1 * 1)
inv_arrow:set_size('x_bows:arrow_inv', 1 * 1)
@ -78,7 +80,8 @@ if XBows._3d_armor then
model_name = 'x_bows_3d_armor_character.b3d'
end
player_api.register_model(model_name, {
if XBows.settings.x_bows_show_3d_quiver then
player_api.register_model(model_name, {
animation_speed = 30,
textures = {'character.png'},
animations = {
@ -95,7 +98,8 @@ player_api.register_model(model_name, {
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
stepheight = 0.6,
eye_height = 1.47
})
})
end
---formspec callbacks
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.
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_entities table<string, XBowsEntityDef>
---@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 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