Compare commits

..

10 Enmetoj

Author SHA1 Message Date
Jaidyn Ann 0b758cbca4 Add Esperanto translation 2024-05-20 12:54:46 -05:00
Jaidyn Ann ec1fecdf36 Make X Bows tab-name translatable 2024-05-20 12:53:15 -05:00
Juraj Vajda 6948bc2a94 add physical check from initial properties 2024-02-27 08:53:07 -05:00
Juraj Vajda e57d6352c0 disable check for physical entities 2024-02-26 22:50:15 -05:00
Juraj Vajda dadca4d319 Add nil check for player when changing skinsdb textures 2024-01-13 14:38:00 -05:00
Juraj Vajda 20e11b7711 add sfinv to luacheck globals 2024-01-04 18:57:06 -05:00
Juraj Vajda e5023d35b4 Add extra check to prevent skinsdb ServerError: AsyncErr: Lua: Runtime error 2024-01-04 18:48:19 -05:00
Juraj Vajda 39a37540f0 Update license year 2024-01-04 18:11:46 -05:00
Juraj Vajda 56c3b843d1 Cleanup global variable 2024-01-04 18:11:06 -05:00
Juraj Vajda bc28f617ca Do not allow arrows where quiver should be (inventory) and create fake quiver with arrow 2024-01-04 18:09:44 -05:00
11 changed files with 62 additions and 28 deletions

View File

@ -19,7 +19,8 @@ globals = {
'XBows', 'XBows',
'XBowsQuiver', 'XBowsQuiver',
'XBowsEntityDefBase', 'XBowsEntityDefBase',
'XBowsEntityDefCustom' 'XBowsEntityDefCustom',
'sfinv'
} }
read_globals = { read_globals = {

49
api.lua
View File

@ -1,6 +1,6 @@
--[[ --[[
X Bows. Adds bow and arrows with API. X Bows. Adds bow and arrows with API.
Copyright (C) 2023 SaKeL <juraj.vajda@gmail.com> Copyright (C) 2024 SaKeL
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
@ -18,8 +18,6 @@
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname())
sfinv = sfinv --[[@as Sfinv]]
---Check if table contains value ---Check if table contains value
---@param table table ---@param table table
---@param value string|number ---@param value string|number
@ -1154,7 +1152,10 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
) )
or ( or (
pointed_thing.ref:get_luaentity() pointed_thing.ref:get_luaentity()
and pointed_thing.ref:get_luaentity().physical and (
pointed_thing.ref:get_luaentity().physical
or pointed_thing.ref:get_properties().physical
)
and pointed_thing.ref:get_luaentity().name ~= '__builtin:item' and pointed_thing.ref:get_luaentity().name ~= '__builtin:item'
) )
) )
@ -2242,7 +2243,7 @@ end
---@param self XBowsQuiver ---@param self XBowsQuiver
function XBowsQuiver.sfinv_register_page(self) function XBowsQuiver.sfinv_register_page(self)
sfinv.register_page('x_bows:quiver_page', { sfinv.register_page('x_bows:quiver_page', {
title = 'X Bows', title = S('X Bows'),
get = function(this, player, context) get = function(this, player, context)
local formspec = { local formspec = {
---arrow ---arrow
@ -2299,7 +2300,7 @@ end
---Register i3 page ---Register i3 page
function XBowsQuiver.i3_register_page(self) function XBowsQuiver.i3_register_page(self)
i3.new_tab('x_bows_quiver_page', { i3.new_tab('x_bows_quiver_page', {
description = 'X Bows', description = S('X Bows'),
slots = true, slots = true,
formspec = function(player, data, fs) formspec = function(player, data, fs)
local formspec = { local formspec = {
@ -2409,7 +2410,7 @@ function XBowsQuiver.ui_register_page(self)
unified_inventory.register_button('x_bows:quiver_page', { unified_inventory.register_button('x_bows:quiver_page', {
type = 'image', type = 'image',
image = "x_bows_bow_wood_charged.png", image = "x_bows_bow_wood_charged.png",
tooltip = 'X Bows', tooltip = S('X Bows'),
}) })
end end
@ -2428,8 +2429,12 @@ function XBowsQuiver.show_3d_quiver(self, player, props)
end end
if self.skinsdb then if self.skinsdb then
minetest.after(1, function() minetest.after(1, function(v_player)
local textures = player_api.get_textures(player) if not v_player then
return
end
local textures = player_api.get_textures(v_player)
---cleanup ---cleanup
for index, value in ipairs(textures) do for index, value in ipairs(textures) do
@ -2445,15 +2450,15 @@ function XBowsQuiver.show_3d_quiver(self, player, props)
player_textures = textures player_textures = textures
if player_textures then if player_textures then
if _props.is_empty and not self.quiver_empty_state[player:get_player_name()] then if _props.is_empty and not self.quiver_empty_state[v_player:get_player_name()] then
self.quiver_empty_state[player:get_player_name()] = true self.quiver_empty_state[v_player:get_player_name()] = true
player_api.set_textures(player, player_textures) player_api.set_textures(v_player, player_textures)
elseif not _props.is_empty and self.quiver_empty_state[player:get_player_name()] then elseif not _props.is_empty and self.quiver_empty_state[v_player:get_player_name()] then
self.quiver_empty_state[player:get_player_name()] = false self.quiver_empty_state[v_player:get_player_name()] = false
player_api.set_textures(player, player_textures) player_api.set_textures(v_player, player_textures)
end end
end end
end) end, player)
return return
elseif self._3d_armor then elseif self._3d_armor then
@ -2526,8 +2531,12 @@ function XBowsQuiver.hide_3d_quiver(self, player)
local player_textures local player_textures
if self.skinsdb then if self.skinsdb then
minetest.after(1, function() minetest.after(1, function(v_player)
local textures = player_api.get_textures(player) if not v_player then
return
end
local textures = player_api.get_textures(v_player)
---cleanup ---cleanup
for index, value in ipairs(textures) do for index, value in ipairs(textures) do
@ -2543,9 +2552,9 @@ function XBowsQuiver.hide_3d_quiver(self, player)
player_textures = textures player_textures = textures
if player_textures then if player_textures then
player_api.set_textures(player, player_textures) player_api.set_textures(v_player, player_textures)
end end
end) end, player)
return return
elseif self._3d_armor then elseif self._3d_armor then

View File

@ -1,6 +1,6 @@
--[[ --[[
X Bows. Adds bow and arrows with API. X Bows. Adds bow and arrows with API.
Copyright (C) 2023 SaKeL <juraj.vajda@gmail.com> Copyright (C) 2024 SaKeL
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
--[[ --[[
X Bows. Adds bow and arrows with API. X Bows. Adds bow and arrows with API.
Copyright (C) 2023 SaKeL <juraj.vajda@gmail.com> Copyright (C) 2024 SaKeL
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
@ -126,7 +126,7 @@ minetest.register_allow_player_inventory_action(function(player, action, invento
else else
return 0 return 0
end end
elseif action == 'move' and inventory_info.from_list == 'x_bows:arrow_inv' then elseif action == 'move' and inventory_info.from_list == 'x_bows:arrow_inv' and inventory_info.to_list ~= 'x_bows:quiver_inv' then
local stack = inventory:get_stack(inventory_info.from_list, inventory_info.from_index) local stack = inventory:get_stack(inventory_info.from_list, inventory_info.from_index)
if minetest.get_item_group(stack:get_name(), 'arrow') ~= 0 then if minetest.get_item_group(stack:get_name(), 'arrow') ~= 0 then

View File

@ -1,6 +1,6 @@
--[[ --[[
X Bows. Adds bow and arrows with API. X Bows. Adds bow and arrows with API.
Copyright (C) 2023 SaKeL <juraj.vajda@gmail.com> Copyright (C) 2024 SaKeL
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public

View File

@ -8,6 +8,7 @@ Charge Time=
Faster Arrows= Faster Arrows=
Arrow Damage= Arrow Damage=
No Ammo= No Ammo=
X Bows=
Arrows= Arrows=
Quiver= Quiver=
Empty= Empty=

22
locale/x_bows.eo.tr Normal file
View File

@ -0,0 +1,22 @@
# textdomain: x_bows
Critical Arrow Chance=Ŝanco de profunda trafo
Strength=Forteco
Allowed ammunition=Uzeblaj pafaĵoj
none=neniu
Damage=Forteco
Charge Time=Tirprokrasto
Faster Arrows=Plirapidaj sagoj
Arrow Damage=Forteco de sago
No Ammo=Neniu pafaĵo
X Bows=X Pafarkoj
Arrows=Sagoj
Quiver=Sagujo
Empty=Malplena
Wooden Bow=Ligna pafarko
Arrow Wood=Ligna sago
Arrow Stone=Ŝtona sago
Arrow Bronze=Bronza sago
Arrow Steel=Ŝtala sago
Arrow Mese=Mesea sago
Arrow Diamond=Diamanta sago
Target=Pafcelo

View File

@ -8,6 +8,7 @@ Charge Time=Doba nabíjania
Faster Arrows=Rýchlejšie šípy Faster Arrows=Rýchlejšie šípy
Arrow Damage=Poškodenie šípom Arrow Damage=Poškodenie šípom
No Ammo=Žiadne strelivo No Ammo=Žiadne strelivo
X Bows=
Arrows=Šípy Arrows=Šípy
Quiver=Púzdro Quiver=Púzdro
Empty=Prázdne Empty=Prázdne

View File

@ -1,6 +1,6 @@
--[[ --[[
X Bows. Adds bow and arrows with API. X Bows. Adds bow and arrows with API.
Copyright (C) 2023 SaKeL <juraj.vajda@gmail.com> Copyright (C) 2024 SaKeL
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
--[[ --[[
X Bows. Adds bow and arrows with API. X Bows. Adds bow and arrows with API.
Copyright (C) 2023 SaKeL <juraj.vajda@gmail.com> Copyright (C) 2024 SaKeL
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public

View File

@ -1,6 +1,6 @@
/** /**
* Deploy code to CDB * Deploy code to CDB
* Copyright (C) 2023 SaKeL <juraj.vajda@gmail.com> * Copyright (C) 2024 SaKeL
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public