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,10 +33,12 @@ minetest.register_on_joinplayer(function(player)
local inv_quiver = player:get_inventory()--[[@as InvRef]]
local inv_arrow = player:get_inventory()--[[@as InvRef]]
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')
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)
@ -78,24 +80,26 @@ if XBows._3d_armor then
model_name = 'x_bows_3d_armor_character.b3d'
end
player_api.register_model(model_name, {
animation_speed = 30,
textures = {'character.png'},
animations = {
-- Standard animations.
stand = {x = 0, y = 79},
lay = {x = 162, y = 166, eye_height = 0.3, override_local = true,
collisionbox = {-0.6, 0.0, -0.6, 0.6, 0.3, 0.6}},
walk = {x = 168, y = 187},
mine = {x = 189, y = 198},
walk_mine = {x = 200, y = 219},
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,
eye_height = 1.47
})
if XBows.settings.x_bows_show_3d_quiver then
player_api.register_model(model_name, {
animation_speed = 30,
textures = {'character.png'},
animations = {
-- Standard animations.
stand = {x = 0, y = 79},
lay = {x = 162, y = 166, eye_height = 0.3, override_local = true,
collisionbox = {-0.6, 0.0, -0.6, 0.6, 0.3, 0.6}},
walk = {x = 168, y = 187},
mine = {x = 189, y = 198},
walk_mine = {x = 200, y = 219},
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,
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