Add lua language server checks
This commit is contained in:
commit
f7e0ec6b33
|
@ -4,3 +4,5 @@ docs/build
|
||||||
*.blend2
|
*.blend2
|
||||||
*.old
|
*.old
|
||||||
node_modules
|
node_modules
|
||||||
|
*.log
|
||||||
|
logs
|
||||||
|
|
13
.luacheckrc
13
.luacheckrc
|
@ -2,6 +2,19 @@ unused_args = false
|
||||||
allow_defined_top = true
|
allow_defined_top = true
|
||||||
max_line_length = false
|
max_line_length = false
|
||||||
|
|
||||||
|
exclude_files = {
|
||||||
|
'./scripts',
|
||||||
|
'./bin',
|
||||||
|
'./logs',
|
||||||
|
'./node_modules',
|
||||||
|
'./sounds',
|
||||||
|
'./textures',
|
||||||
|
'./models',
|
||||||
|
'./docs',
|
||||||
|
'./locale',
|
||||||
|
'./types',
|
||||||
|
}
|
||||||
|
|
||||||
globals = {
|
globals = {
|
||||||
'XBows',
|
'XBows',
|
||||||
'XBowsQuiver',
|
'XBowsQuiver',
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
|
||||||
|
"runtime": {
|
||||||
|
"version": "Lua 5.1",
|
||||||
|
"path": [
|
||||||
|
"?.lua",
|
||||||
|
"?/init.lua"
|
||||||
|
],
|
||||||
|
"pathStrict": true
|
||||||
|
},
|
||||||
|
"workspace": {
|
||||||
|
"maxPreload": 1600,
|
||||||
|
"preloadFileSize": 1000,
|
||||||
|
"ignoreDir": [
|
||||||
|
"/locale/",
|
||||||
|
"/libs/",
|
||||||
|
"/3rd",
|
||||||
|
"/.vscode",
|
||||||
|
"/meta",
|
||||||
|
"/.git",
|
||||||
|
"/docs",
|
||||||
|
"/bin"
|
||||||
|
],
|
||||||
|
"checkThirdParty": false
|
||||||
|
},
|
||||||
|
"typeFormat": {
|
||||||
|
"config": {
|
||||||
|
"format_line": "false"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"castNumberToInteger": true
|
||||||
|
},
|
||||||
|
"doc": {
|
||||||
|
"privateName": [
|
||||||
|
"_*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"diagnostics": {
|
||||||
|
"disable": [
|
||||||
|
"close-non-object"
|
||||||
|
],
|
||||||
|
"groupFileStatus": {
|
||||||
|
"ambiguity": "Any",
|
||||||
|
"await": "Any",
|
||||||
|
"duplicate": "Any",
|
||||||
|
"global": "Any",
|
||||||
|
"luadoc": "Any",
|
||||||
|
"redefined": "Any",
|
||||||
|
"strict": "Any",
|
||||||
|
"type-check": "Any",
|
||||||
|
"unbalanced": "Any",
|
||||||
|
"unused": "Any"
|
||||||
|
},
|
||||||
|
"ignoredFiles": "Disable",
|
||||||
|
"libraryFiles": "Disable",
|
||||||
|
"neededFileStatus": {
|
||||||
|
"codestyle-check": "Any"
|
||||||
|
},
|
||||||
|
"disableScheme": [
|
||||||
|
"git",
|
||||||
|
"type"
|
||||||
|
],
|
||||||
|
"globals": [
|
||||||
|
"DIR_DELIM",
|
||||||
|
"INIT",
|
||||||
|
"minetest",
|
||||||
|
"core",
|
||||||
|
"dump",
|
||||||
|
"dump2",
|
||||||
|
"Raycast",
|
||||||
|
"Settings",
|
||||||
|
"PseudoRandom",
|
||||||
|
"PerlinNoise",
|
||||||
|
"VoxelManip",
|
||||||
|
"SecureRandom",
|
||||||
|
"VoxelArea",
|
||||||
|
"PerlinNoiseMap",
|
||||||
|
"PcgRandom",
|
||||||
|
"ItemStack",
|
||||||
|
"AreaStore",
|
||||||
|
"unpack",
|
||||||
|
"vector",
|
||||||
|
"player_monoids",
|
||||||
|
"playerphysics",
|
||||||
|
"hb",
|
||||||
|
"mesecon",
|
||||||
|
"armor",
|
||||||
|
"default",
|
||||||
|
"i3",
|
||||||
|
"unified_inventory",
|
||||||
|
"player_api",
|
||||||
|
"u_skins",
|
||||||
|
"wardrobe",
|
||||||
|
"3d_armor",
|
||||||
|
"skinsdb",
|
||||||
|
"skins"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
387
api.lua
387
api.lua
|
@ -1,6 +1,6 @@
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
|
|
||||||
sfinv = sfinv--[[@as Sfinv]]
|
sfinv = sfinv --[[@as Sfinv]]
|
||||||
|
|
||||||
---Check if table contains value
|
---Check if table contains value
|
||||||
---@param table table
|
---@param table table
|
||||||
|
@ -21,7 +21,7 @@ end
|
||||||
---@param t2 table
|
---@param t2 table
|
||||||
---@return table
|
---@return table
|
||||||
local function mergeTables(t1, t2)
|
local function mergeTables(t1, t2)
|
||||||
for k,v in pairs(t2) do t1[k] = v end
|
for k, v in pairs(t2) do t1[k] = v end
|
||||||
return t1
|
return t1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,7 +51,9 @@ XBows = {
|
||||||
x_bows_show_3d_quiver = minetest.settings:get_bool('x_bows_show_3d_quiver', true)
|
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')
|
||||||
}
|
}
|
||||||
|
|
||||||
XBows.__index = XBows
|
XBows.__index = XBows
|
||||||
|
@ -74,10 +76,10 @@ setmetatable(XBowsEntityDef, XBows)
|
||||||
---create UUID
|
---create UUID
|
||||||
---@return string
|
---@return string
|
||||||
function XBows.uuid()
|
function XBows.uuid()
|
||||||
local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
local template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
||||||
|
|
||||||
---@diagnostic disable-next-line: redundant-return-value
|
---@diagnostic disable-next-line: redundant-return-value
|
||||||
return string.gsub(template, '[xy]', function (c)
|
return string.gsub(template, '[xy]', function(c)
|
||||||
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
|
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
|
||||||
return string.format('%x', v)
|
return string.format('%x', v)
|
||||||
end)
|
end)
|
||||||
|
@ -88,7 +90,7 @@ end
|
||||||
---@param name string
|
---@param name string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function XBows.is_creative(self, name)
|
function XBows.is_creative(self, name)
|
||||||
return self.creative or minetest.check_player_privs(name, {creative = true})
|
return self.creative or minetest.check_player_privs(name, { creative = true })
|
||||||
end
|
end
|
||||||
|
|
||||||
---Updates `allowed_ammunition` definition on already registered item, so MODs can add new ammunitions to this list.
|
---Updates `allowed_ammunition` definition on already registered item, so MODs can add new ammunitions to this list.
|
||||||
|
@ -97,7 +99,7 @@ end
|
||||||
---@param allowed_ammunition string[]
|
---@param allowed_ammunition string[]
|
||||||
---@return nil
|
---@return nil
|
||||||
function XBows.update_bow_allowed_ammunition(self, name, allowed_ammunition)
|
function XBows.update_bow_allowed_ammunition(self, name, allowed_ammunition)
|
||||||
local _name = 'x_bows:'..name
|
local _name = 'x_bows:' .. name
|
||||||
local def = self.registered_bows[_name]
|
local def = self.registered_bows[_name]
|
||||||
|
|
||||||
if not def then
|
if not def then
|
||||||
|
@ -135,16 +137,24 @@ function XBows.reset_charged_bow(self, player, includeWielded)
|
||||||
local x_bows_registered_bow_def = self.registered_bows[st_name]
|
local x_bows_registered_bow_def = self.registered_bows[st_name]
|
||||||
local reset = _includeWielded or player:get_wield_index() ~= i
|
local reset = _includeWielded or player:get_wield_index() ~= i
|
||||||
|
|
||||||
if not st:is_empty() and x_bows_registered_bow_def and reset and minetest.get_item_group(st_name, 'bow_charged') ~= 0 then
|
if not st:is_empty()
|
||||||
|
and x_bows_registered_bow_def
|
||||||
|
and reset
|
||||||
|
and minetest.get_item_group(st_name, 'bow_charged') ~= 0
|
||||||
|
then
|
||||||
local item_meta = st:get_meta()
|
local item_meta = st:get_meta()
|
||||||
local arrow_itemstack = ItemStack(minetest.deserialize(item_meta:get_string('arrow_itemstack_string')))
|
local arrow_itemstack = ItemStack(minetest.deserialize(item_meta:get_string('arrow_itemstack_string')))
|
||||||
|
|
||||||
--return arrow
|
--return arrow
|
||||||
if arrow_itemstack and not self:is_creative(player:get_player_name()) then
|
if arrow_itemstack and not self:is_creative(player:get_player_name()) then
|
||||||
if inv:room_for_item('main', {name=arrow_itemstack:get_name()}) then
|
if inv:room_for_item('main', { name = arrow_itemstack:get_name() }) then
|
||||||
inv:add_item('main', arrow_itemstack:get_name())
|
inv:add_item('main', arrow_itemstack:get_name())
|
||||||
else
|
else
|
||||||
minetest.item_drop(ItemStack({name=arrow_itemstack:get_name(), count=1}), player, player:get_pos())
|
minetest.item_drop(
|
||||||
|
ItemStack({ name = arrow_itemstack:get_name(), count = 1 }),
|
||||||
|
player,
|
||||||
|
player:get_pos()
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -175,8 +185,11 @@ function XBows.register_bow(self, name, def, override)
|
||||||
def.short_description = def.short_description
|
def.short_description = def.short_description
|
||||||
def.description = override and def.short_description or (def.description or name)
|
def.description = override and def.short_description or (def.description or name)
|
||||||
def.custom.uses = def.custom.uses or 150
|
def.custom.uses = def.custom.uses or 150
|
||||||
def.groups = mergeTables({bow = 1, flammable = 1}, def.groups or {})
|
def.groups = mergeTables({ bow = 1, flammable = 1 }, def.groups or {})
|
||||||
def.custom.groups_charged = mergeTables({bow_charged = 1, flammable = 1, not_in_creative_inventory = 1}, def.groups or {})
|
def.custom.groups_charged = mergeTables(
|
||||||
|
{ bow_charged = 1, flammable = 1, not_in_creative_inventory = 1 },
|
||||||
|
def.groups or {}
|
||||||
|
)
|
||||||
def.custom.strength = def.custom.strength or 30
|
def.custom.strength = def.custom.strength or 30
|
||||||
def.custom.allowed_ammunition = def.custom.allowed_ammunition or nil
|
def.custom.allowed_ammunition = def.custom.allowed_ammunition or nil
|
||||||
def.custom.sound_load = def.custom.sound_load or 'x_bows_bow_load'
|
def.custom.sound_load = def.custom.sound_load or 'x_bows_bow_load'
|
||||||
|
@ -186,7 +199,7 @@ function XBows.register_bow(self, name, def, override)
|
||||||
def.custom.gravity = def.custom.gravity or -10
|
def.custom.gravity = def.custom.gravity or -10
|
||||||
|
|
||||||
if def.custom.crit_chance then
|
if def.custom.crit_chance then
|
||||||
def.description = def.description .. '\n' .. minetest.colorize('#00FF00', S('Critical Arrow Chance') ..': '
|
def.description = def.description .. '\n' .. minetest.colorize('#00FF00', S('Critical Arrow Chance') .. ': '
|
||||||
.. (1 / def.custom.crit_chance) * 100 .. '%')
|
.. (1 / def.custom.crit_chance) * 100 .. '%')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -212,7 +225,7 @@ function XBows.register_bow(self, name, def, override)
|
||||||
inventory_image = def.inventory_image or 'x_bows_bow_wood.png',
|
inventory_image = def.inventory_image or 'x_bows_bow_wood.png',
|
||||||
wield_image = def.wield_image or def.inventory_image,
|
wield_image = def.wield_image or def.inventory_image,
|
||||||
groups = def.groups,
|
groups = def.groups,
|
||||||
wield_scale = {x = 2, y = 2, z = 1.5},
|
wield_scale = { x = 2, y = 2, z = 1.5 },
|
||||||
---@param itemstack ItemStack
|
---@param itemstack ItemStack
|
||||||
---@param placer ObjectRef|nil
|
---@param placer ObjectRef|nil
|
||||||
---@param pointed_thing PointedThingDef
|
---@param pointed_thing PointedThingDef
|
||||||
|
@ -239,7 +252,7 @@ function XBows.register_bow(self, name, def, override)
|
||||||
inventory_image = def.custom.inventory_image_charged or 'x_bows_bow_wood_charged.png',
|
inventory_image = def.custom.inventory_image_charged or 'x_bows_bow_wood_charged.png',
|
||||||
wield_image = def.custom.wield_image_charged or def.custom.inventory_image_charged,
|
wield_image = def.custom.wield_image_charged or def.custom.inventory_image_charged,
|
||||||
groups = def.custom.groups_charged,
|
groups = def.custom.groups_charged,
|
||||||
wield_scale = {x = 2, y = 2, z = 1.5},
|
wield_scale = { x = 2, y = 2, z = 1.5 },
|
||||||
range = 0,
|
range = 0,
|
||||||
---@param itemstack ItemStack
|
---@param itemstack ItemStack
|
||||||
---@param user ObjectRef|nil
|
---@param user ObjectRef|nil
|
||||||
|
@ -261,7 +274,11 @@ function XBows.register_bow(self, name, def, override)
|
||||||
|
|
||||||
---return arrow
|
---return arrow
|
||||||
if arrow_itemstack and not self:is_creative(dropper:get_player_name()) then
|
if arrow_itemstack and not self:is_creative(dropper:get_player_name()) then
|
||||||
minetest.item_drop(ItemStack({name=arrow_itemstack:get_name(), count=1}), dropper, {x=pos.x + 0.5, y=pos.y + 0.5, z=pos.z + 0.5})
|
minetest.item_drop(
|
||||||
|
ItemStack({ name = arrow_itemstack:get_name(), count = 1 }),
|
||||||
|
dropper,
|
||||||
|
{ x = pos.x + 0.5, y = pos.y + 0.5, z = pos.z + 0.5 }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
itemstack:set_name(def.custom.name)
|
itemstack:set_name(def.custom.name)
|
||||||
|
@ -306,12 +323,12 @@ function XBows.register_arrow(self, name, def)
|
||||||
def.custom.tool_capabilities = def.custom.tool_capabilities or {
|
def.custom.tool_capabilities = def.custom.tool_capabilities or {
|
||||||
full_punch_interval = 1,
|
full_punch_interval = 1,
|
||||||
max_drop_level = 0,
|
max_drop_level = 0,
|
||||||
damage_groups = {fleshy=2}
|
damage_groups = { fleshy = 2 }
|
||||||
}
|
}
|
||||||
def.custom.description_abilities = minetest.colorize('#00FF00', S('Damage') .. ': '
|
def.custom.description_abilities = minetest.colorize('#00FF00', S('Damage') .. ': '
|
||||||
.. def.custom.tool_capabilities.damage_groups.fleshy) .. '\n' .. minetest.colorize('#00BFFF', S('Charge Time') .. ': '
|
.. def.custom.tool_capabilities.damage_groups.fleshy) .. '\n' .. minetest.colorize('#00BFFF', S('Charge Time') .. ': '
|
||||||
.. def.custom.tool_capabilities.full_punch_interval .. 's')
|
.. def.custom.tool_capabilities.full_punch_interval .. 's')
|
||||||
def.groups = mergeTables({arrow = 1, flammable = 1}, def.groups or {})
|
def.groups = mergeTables({ arrow = 1, flammable = 1 }, def.groups or {})
|
||||||
def.custom.particle_effect = def.custom.particle_effect or 'arrow'
|
def.custom.particle_effect = def.custom.particle_effect or 'arrow'
|
||||||
def.custom.particle_effect_crit = def.custom.particle_effect_crit or 'arrow_crit'
|
def.custom.particle_effect_crit = def.custom.particle_effect_crit or 'arrow_crit'
|
||||||
def.custom.particle_effect_fast = def.custom.particle_effect_fast or 'arrow_fast'
|
def.custom.particle_effect_fast = def.custom.particle_effect_fast or 'arrow_fast'
|
||||||
|
@ -333,7 +350,7 @@ function XBows.register_arrow(self, name, def)
|
||||||
---recipes
|
---recipes
|
||||||
if def.custom.recipe then
|
if def.custom.recipe then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = def.custom.name ..' ' .. (def.custom.craft_count or 4),
|
output = def.custom.name .. ' ' .. (def.custom.craft_count or 4),
|
||||||
recipe = def.custom.recipe
|
recipe = def.custom.recipe
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -362,17 +379,25 @@ function XBows.register_quiver(self, name, def)
|
||||||
def.custom.name_open = 'x_bows:' .. name .. '_open'
|
def.custom.name_open = 'x_bows:' .. name .. '_open'
|
||||||
def.description = def.description or name
|
def.description = def.description or name
|
||||||
def.short_description = def.short_description or name
|
def.short_description = def.short_description or name
|
||||||
def.groups = mergeTables({quiver = 1, flammable = 1}, def.groups or {})
|
def.groups = mergeTables({ quiver = 1, flammable = 1 }, def.groups or {})
|
||||||
def.custom.groups_charged = mergeTables({quiver = 1, quiver_open = 1, flammable = 1, not_in_creative_inventory = 1}, def.groups or {})
|
def.custom.groups_charged = mergeTables({
|
||||||
|
quiver = 1, quiver_open = 1, flammable = 1, not_in_creative_inventory = 1
|
||||||
|
},
|
||||||
|
def.groups or {}
|
||||||
|
)
|
||||||
|
|
||||||
if def.custom.faster_arrows then
|
if def.custom.faster_arrows then
|
||||||
def.description = def.description .. '\n' .. minetest.colorize('#00FF00', S('Faster Arrows') .. ': ' .. (1 / def.custom.faster_arrows) * 100 .. '%')
|
def.description = def.description .. '\n' .. minetest.colorize('#00FF00', S('Faster Arrows') ..
|
||||||
def.short_description = def.short_description .. '\n' .. minetest.colorize('#00FF00', S('Faster Arrows') .. ': ' .. (1 / def.custom.faster_arrows) * 100 .. '%')
|
': ' .. (1 / def.custom.faster_arrows) * 100 .. '%')
|
||||||
|
def.short_description = def.short_description .. '\n' .. minetest.colorize('#00FF00', S('Faster Arrows') ..
|
||||||
|
': ' .. (1 / def.custom.faster_arrows) * 100 .. '%')
|
||||||
end
|
end
|
||||||
|
|
||||||
if def.custom.add_damage then
|
if def.custom.add_damage then
|
||||||
def.description = def.description .. '\n' .. minetest.colorize('#FF8080', S('Arrow Damage') .. ': +' .. def.custom.add_damage)
|
def.description = def.description .. '\n' .. minetest.colorize('#FF8080', S('Arrow Damage') ..
|
||||||
def.short_description = def.short_description .. '\n' .. minetest.colorize('#FF8080', S('Arrow Damage') .. ': +' .. def.custom.add_damage)
|
': +' .. def.custom.add_damage)
|
||||||
|
def.short_description = def.short_description .. '\n' .. minetest.colorize('#FF8080', S('Arrow Damage') ..
|
||||||
|
': +' .. def.custom.add_damage)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.registered_quivers[def.custom.name] = def
|
self.registered_quivers[def.custom.name] = def
|
||||||
|
@ -423,7 +448,11 @@ function XBows.register_quiver(self, name, def)
|
||||||
---@param dropper ObjectRef|nil
|
---@param dropper ObjectRef|nil
|
||||||
---@param pos Vector
|
---@param pos Vector
|
||||||
---@return ItemStack
|
---@return ItemStack
|
||||||
on_drop = function (itemstack, dropper, pos)
|
on_drop = function(itemstack, dropper, pos)
|
||||||
|
if not dropper then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
local replace_item = XBowsQuiver:get_replacement_item(itemstack, 'x_bows:quiver')
|
local replace_item = XBowsQuiver:get_replacement_item(itemstack, 'x_bows:quiver')
|
||||||
return minetest.item_drop(replace_item, dropper, pos)
|
return minetest.item_drop(replace_item, dropper, pos)
|
||||||
end
|
end
|
||||||
|
@ -455,7 +484,7 @@ end
|
||||||
---@return ItemStack
|
---@return ItemStack
|
||||||
function XBows.load(self, itemstack, user, pointed_thing)
|
function XBows.load(self, itemstack, user, pointed_thing)
|
||||||
local player_name = user:get_player_name()
|
local player_name = user:get_player_name()
|
||||||
local inv = user:get_inventory()--[[@as InvRef]]
|
local inv = user:get_inventory() --[[@as InvRef]]
|
||||||
local bow_name = itemstack:get_name()
|
local bow_name = itemstack:get_name()
|
||||||
local bow_def = self.registered_bows[bow_name]
|
local bow_def = self.registered_bows[bow_name]
|
||||||
---@alias ItemStackArrows {["stack"]: ItemStack, ["idx"]: number|integer}[]
|
---@alias ItemStackArrows {["stack"]: ItemStack, ["idx"]: number|integer}[]
|
||||||
|
@ -489,9 +518,9 @@ function XBows.load(self, itemstack, user, pointed_thing)
|
||||||
XBowsQuiver:udate_or_create_hud(user, inv:get_list('x_bows:arrow_inv'))
|
XBowsQuiver:udate_or_create_hud(user, inv:get_list('x_bows:arrow_inv'))
|
||||||
else
|
else
|
||||||
---no ammo (fake stack)
|
---no ammo (fake stack)
|
||||||
XBowsQuiver:udate_or_create_hud(user, {ItemStack({
|
XBowsQuiver:udate_or_create_hud(user, {
|
||||||
name = 'x_bows:no_ammo'
|
ItemStack({ name = 'x_bows:no_ammo' })
|
||||||
})})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
---find itemstack arrow in players inventory
|
---find itemstack arrow in players inventory
|
||||||
|
@ -499,7 +528,7 @@ function XBows.load(self, itemstack, user, pointed_thing)
|
||||||
local is_allowed_ammunition = self:is_allowed_ammunition(bow_name, arrow_stack:get_name())
|
local is_allowed_ammunition = self:is_allowed_ammunition(bow_name, arrow_stack:get_name())
|
||||||
|
|
||||||
if self.registered_arrows[arrow_stack:get_name()] and is_allowed_ammunition then
|
if self.registered_arrows[arrow_stack:get_name()] and is_allowed_ammunition then
|
||||||
table.insert(itemstack_arrows, {stack = arrow_stack, idx = 1})
|
table.insert(itemstack_arrows, { stack = arrow_stack, idx = 1 })
|
||||||
end
|
end
|
||||||
|
|
||||||
---if everything else fails
|
---if everything else fails
|
||||||
|
@ -513,7 +542,7 @@ function XBows.load(self, itemstack, user, pointed_thing)
|
||||||
local _is_allowed_ammunition = self:is_allowed_ammunition(bow_name, st_name)
|
local _is_allowed_ammunition = self:is_allowed_ammunition(bow_name, st_name)
|
||||||
|
|
||||||
if self.registered_arrows[st_name] and _is_allowed_ammunition then
|
if self.registered_arrows[st_name] and _is_allowed_ammunition then
|
||||||
table.insert(itemstack_arrows, {stack = st, idx = i})
|
table.insert(itemstack_arrows, { stack = st, idx = i })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -544,7 +573,9 @@ function XBows.load(self, itemstack, user, pointed_thing)
|
||||||
wielded_item:set_name(v_bow_name .. '_charged')
|
wielded_item:set_name(v_bow_name .. '_charged')
|
||||||
v_user:set_wielded_item(wielded_item)
|
v_user:set_wielded_item(wielded_item)
|
||||||
|
|
||||||
if not self:is_creative(v_user:get_player_name()) and v_itemstack_arrow_meta:get_int('is_arrow_from_quiver') ~= 1 then
|
if not self:is_creative(v_user:get_player_name())
|
||||||
|
and v_itemstack_arrow_meta:get_int('is_arrow_from_quiver') ~= 1
|
||||||
|
then
|
||||||
v_itemstack_arrow:take_item()
|
v_itemstack_arrow:take_item()
|
||||||
v_inv:set_stack('x_bows:arrow_inv', v_itemstack_arrows[1].idx, v_itemstack_arrow)
|
v_inv:set_stack('x_bows:arrow_inv', v_itemstack_arrows[1].idx, v_itemstack_arrow)
|
||||||
end
|
end
|
||||||
|
@ -563,17 +594,18 @@ function XBows.load(self, itemstack, user, pointed_thing)
|
||||||
end
|
end
|
||||||
|
|
||||||
---sound plays when charge time reaches full punch interval time
|
---sound plays when charge time reaches full punch interval time
|
||||||
table.insert(self.charge_sound_after_job[player_name], minetest.after(_tool_capabilities.full_punch_interval, function(v_user, v_bow_name)
|
table.insert(self.charge_sound_after_job[player_name], minetest.after(_tool_capabilities.full_punch_interval,
|
||||||
local wielded_item = v_user:get_wielded_item()
|
function(v_user, v_bow_name)
|
||||||
local wielded_item_name = wielded_item:get_name()
|
local wielded_item = v_user:get_wielded_item()
|
||||||
|
local wielded_item_name = wielded_item:get_name()
|
||||||
|
|
||||||
if wielded_item_name == v_bow_name .. '_charged' then
|
if wielded_item_name == v_bow_name .. '_charged' then
|
||||||
minetest.sound_play('x_bows_bow_loaded', {
|
minetest.sound_play('x_bows_bow_loaded', {
|
||||||
to_player = v_user:get_player_name(),
|
to_player = v_user:get_player_name(),
|
||||||
gain = 0.6
|
gain = 0.6
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end, user, bow_name))
|
end, user, bow_name))
|
||||||
|
|
||||||
minetest.sound_play(bow_def.custom.sound_load, {
|
minetest.sound_play(bow_def.custom.sound_load, {
|
||||||
to_player = player_name,
|
to_player = player_name,
|
||||||
|
@ -615,19 +647,19 @@ function XBows.shoot(self, itemstack, user, pointed_thing)
|
||||||
XBowsQuiver:udate_or_create_hud(user, detached_inv:get_list('main'), found_arrow_stack_idx)
|
XBowsQuiver:udate_or_create_hud(user, detached_inv:get_list('main'), found_arrow_stack_idx)
|
||||||
|
|
||||||
if detached_inv:is_empty('main') then
|
if detached_inv:is_empty('main') then
|
||||||
XBowsQuiver:show_3d_quiver(user, {is_empty = true})
|
XBowsQuiver:show_3d_quiver(user, { is_empty = true })
|
||||||
else
|
else
|
||||||
XBowsQuiver:show_3d_quiver(user)
|
XBowsQuiver:show_3d_quiver(user)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local inv = user:get_inventory()--[[@as InvRef]]
|
local inv = user:get_inventory() --[[@as InvRef]]
|
||||||
if not inv:is_empty('x_bows:arrow_inv') then
|
if not inv:is_empty('x_bows:arrow_inv') then
|
||||||
XBowsQuiver:udate_or_create_hud(user, inv:get_list('x_bows:arrow_inv'))
|
XBowsQuiver:udate_or_create_hud(user, inv:get_list('x_bows:arrow_inv'))
|
||||||
else
|
else
|
||||||
---no ammo (fake stack just for the HUD)
|
---no ammo (fake stack just for the HUD)
|
||||||
XBowsQuiver:udate_or_create_hud(user, {ItemStack({
|
XBowsQuiver:udate_or_create_hud(user, {
|
||||||
name = 'x_bows:no_ammo'
|
ItemStack({ name = 'x_bows:no_ammo' })
|
||||||
})})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -690,7 +722,7 @@ function XBows.shoot(self, itemstack, user, pointed_thing)
|
||||||
local wield_item = user:get_wielded_item()
|
local wield_item = user:get_wielded_item()
|
||||||
|
|
||||||
if wield_item:get_count() > 0 and wield_item:get_name() == itemstack:get_name() then
|
if wield_item:get_count() > 0 and wield_item:get_name() == itemstack:get_name() then
|
||||||
user:set_wielded_item(ItemStack({name = bow_name, wear = itemstack:get_wear()}))
|
user:set_wielded_item(ItemStack({ name = bow_name, wear = itemstack:get_wear() }))
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -761,7 +793,7 @@ function XBows.get_particle_effect_for_arrow(self, name, pos)
|
||||||
def.minpos = def.custom.minpos and vector.add(pos, def.custom.minpos) or pos
|
def.minpos = def.custom.minpos and vector.add(pos, def.custom.minpos) or pos
|
||||||
def.maxpos = def.custom.maxpos and vector.add(pos, def.custom.maxpos) or pos
|
def.maxpos = def.custom.maxpos and vector.add(pos, def.custom.maxpos) or pos
|
||||||
|
|
||||||
return minetest.add_particlespawner(def--[[@as ParticlespawnerDef]])
|
return minetest.add_particlespawner(def--[[@as ParticlespawnerDef]] )
|
||||||
end
|
end
|
||||||
|
|
||||||
---Check if ammunition is allowed to charge this weapon
|
---Check if ammunition is allowed to charge this weapon
|
||||||
|
@ -827,10 +859,10 @@ function XBowsEntityDef.on_activate(self, selfObj, staticdata, dtime_s)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local _staticdata = minetest.deserialize(staticdata)--[[@as EnityStaticDataAttrDef]]
|
local _staticdata = minetest.deserialize(staticdata) --[[@as EnityStaticDataAttrDef]]
|
||||||
|
|
||||||
-- set/reset - do not inherit from previous entity table
|
-- set/reset - do not inherit from previous entity table
|
||||||
selfObj._velocity = {x = 0, y = 0, z = 0}
|
selfObj._velocity = { x = 0, y = 0, z = 0 }
|
||||||
selfObj._old_pos = nil
|
selfObj._old_pos = nil
|
||||||
selfObj._attached = false
|
selfObj._attached = false
|
||||||
selfObj._attached_to = {
|
selfObj._attached_to = {
|
||||||
|
@ -954,7 +986,8 @@ function XBowsEntityDef.on_death(self, selfObj, killer)
|
||||||
minetest.item_drop(ItemStack(selfObj._arrow_name), nil, vector.round(selfObj._old_pos))
|
minetest.item_drop(ItemStack(selfObj._arrow_name), nil, vector.round(selfObj._old_pos))
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Function receive a "luaentity" table as `self`. Called on every server tick, after movement and collision processing. `dtime`: elapsed time since last call. `moveresult`: table with collision info (only available if physical=true).
|
--- Function receive a "luaentity" table as `self`. Called on every server tick, after movement and collision processing.
|
||||||
|
---`dtime`: elapsed time since last call. `moveresult`: table with collision info (only available if physical=true).
|
||||||
---@param self XBows
|
---@param self XBows
|
||||||
---@param selfObj EnityCustomAttrDef
|
---@param selfObj EnityCustomAttrDef
|
||||||
---@param dtime number
|
---@param dtime number
|
||||||
|
@ -966,7 +999,7 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
---initialize
|
---initialize
|
||||||
---this has to be done here for raycast to kick-in asap
|
---this has to be done here for raycast to kick-in asap
|
||||||
selfObj.object:set_velocity(vector.multiply(selfObj._player_look_dir, selfObj._strength))
|
selfObj.object:set_velocity(vector.multiply(selfObj._player_look_dir, selfObj._strength))
|
||||||
selfObj.object:set_acceleration({x = selfObj._acc_x, y = selfObj._acc_y, z = selfObj._acc_z})
|
selfObj.object:set_acceleration({ x = selfObj._acc_x, y = selfObj._acc_y, z = selfObj._acc_z })
|
||||||
selfObj.object:set_yaw(minetest.dir_to_yaw(selfObj._player_look_dir))
|
selfObj.object:set_yaw(minetest.dir_to_yaw(selfObj._player_look_dir))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -982,7 +1015,7 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
if not selfObj._attached then
|
if not selfObj._attached then
|
||||||
local velocity = selfObj.object:get_velocity()
|
local velocity = selfObj.object:get_velocity()
|
||||||
local v_rotation = selfObj.object:get_rotation()
|
local v_rotation = selfObj.object:get_rotation()
|
||||||
local pitch = math.atan2(velocity.y, math.sqrt(velocity.x^2 + velocity.z^2))
|
local pitch = math.atan2(velocity.y, math.sqrt(velocity.x ^ 2 + velocity.z ^ 2))
|
||||||
|
|
||||||
selfObj.object:set_rotation({
|
selfObj.object:set_rotation({
|
||||||
x = pitch,
|
x = pitch,
|
||||||
|
@ -1028,13 +1061,13 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
if node.name == 'air' then
|
if node.name == 'air' then
|
||||||
selfObj.object:set_velocity({x = 0, y = -3, z = 0})
|
selfObj.object:set_velocity({ x = 0, y = -3, z = 0 })
|
||||||
selfObj.object:set_acceleration({x = 0, y = -3, z = 0})
|
selfObj.object:set_acceleration({ x = 0, y = -3, z = 0 })
|
||||||
-- reset values
|
-- reset values
|
||||||
selfObj._attached = false
|
selfObj._attached = false
|
||||||
selfObj._attached_to.type = ''
|
selfObj._attached_to.type = ''
|
||||||
selfObj._attached_to.pos = nil
|
selfObj._attached_to.pos = nil
|
||||||
selfObj.object:set_properties({collisionbox = {0, 0, 0, 0, 0, 0}})
|
selfObj.object:set_properties({ collisionbox = { 0, 0, 0, 0, 0, 0 } })
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -1049,7 +1082,10 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
and pointed_thing.ref ~= selfObj.object
|
and pointed_thing.ref ~= selfObj.object
|
||||||
and pointed_thing.ref:get_hp() > 0
|
and pointed_thing.ref:get_hp() > 0
|
||||||
and (
|
and (
|
||||||
(pointed_thing.ref:is_player() and pointed_thing.ref:get_player_name() ~= selfObj._user:get_player_name())
|
(
|
||||||
|
pointed_thing.ref:is_player()
|
||||||
|
and pointed_thing.ref:get_player_name() ~= selfObj._user:get_player_name()
|
||||||
|
)
|
||||||
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
|
||||||
|
@ -1071,8 +1107,8 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
selfObj.object:set_velocity({x = 0, y = 0, z = 0})
|
selfObj.object:set_velocity({ x = 0, y = 0, z = 0 })
|
||||||
selfObj.object:set_acceleration({x = 0, y = 0, z = 0})
|
selfObj.object:set_acceleration({ x = 0, y = 0, z = 0 })
|
||||||
|
|
||||||
-- calculate damage
|
-- calculate damage
|
||||||
local target_armor_groups = pointed_thing.ref:get_armor_groups()
|
local target_armor_groups = pointed_thing.ref:get_armor_groups()
|
||||||
|
@ -1103,7 +1139,7 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
selfObj._tflp,
|
selfObj._tflp,
|
||||||
{
|
{
|
||||||
full_punch_interval = selfObj._tool_capabilities.full_punch_interval,
|
full_punch_interval = selfObj._tool_capabilities.full_punch_interval,
|
||||||
damage_groups = {fleshy = _damage},
|
damage_groups = { fleshy = _damage },
|
||||||
},
|
},
|
||||||
dir,
|
dir,
|
||||||
distance,
|
distance,
|
||||||
|
@ -1121,7 +1157,7 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
selfObj._tflp,
|
selfObj._tflp,
|
||||||
{
|
{
|
||||||
full_punch_interval = selfObj._tool_capabilities.full_punch_interval,
|
full_punch_interval = selfObj._tool_capabilities.full_punch_interval,
|
||||||
damage_groups = {fleshy = _damage, knockback = knockback}
|
damage_groups = { fleshy = _damage, knockback = knockback }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
x = dir.x * -1,
|
x = dir.x * -1,
|
||||||
|
@ -1148,7 +1184,7 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- attach arrow prepare
|
-- attach arrow prepare
|
||||||
local rotation = {x = 0, y = 0, z = 0}
|
local rotation = { x = 0, y = 0, z = 0 }
|
||||||
|
|
||||||
if in_pos.x == 1 then
|
if in_pos.x == 1 then
|
||||||
-- x = 0
|
-- x = 0
|
||||||
|
@ -1199,12 +1235,13 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
---normalize arrow scale when attached to scaled entity (prevents huge arrows when attached to scaled up entity models)
|
---normalize arrow scale when attached to scaled entity
|
||||||
|
---(prevents huge arrows when attached to scaled up entity models)
|
||||||
local obj_props = selfObj.object:get_properties()
|
local obj_props = selfObj.object:get_properties()
|
||||||
local obj_to_props = pointed_thing.ref:get_properties()
|
local obj_to_props = pointed_thing.ref:get_properties()
|
||||||
local vs = vector.divide(obj_props.visual_size, obj_to_props.visual_size)
|
local vs = vector.divide(obj_props.visual_size, obj_to_props.visual_size)
|
||||||
|
|
||||||
selfObj.object:set_properties({visual_size = vs})
|
selfObj.object:set_properties({ visual_size = vs })
|
||||||
|
|
||||||
-- attach arrow
|
-- attach arrow
|
||||||
local position = vector.subtract(
|
local position = vector.subtract(
|
||||||
|
@ -1277,7 +1314,7 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
selfObj._in_liquid = true
|
selfObj._in_liquid = true
|
||||||
local drag = 1 / (node_def.liquid_viscosity * 6)
|
local drag = 1 / (node_def.liquid_viscosity * 6)
|
||||||
selfObj.object:set_velocity(vector.multiply(selfObj._velocity, drag))
|
selfObj.object:set_velocity(vector.multiply(selfObj._velocity, drag))
|
||||||
selfObj.object:set_acceleration({x = 0, y = -1.0, z = 0})
|
selfObj.object:set_acceleration({ x = 0, y = -1.0, z = 0 })
|
||||||
|
|
||||||
XBows:get_particle_effect_for_arrow('bubble', selfObj._old_pos)
|
XBows:get_particle_effect_for_arrow('bubble', selfObj._old_pos)
|
||||||
elseif selfObj._is_drowning then
|
elseif selfObj._is_drowning then
|
||||||
|
@ -1287,7 +1324,7 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
selfObj.object:set_velocity(selfObj._velocity)
|
selfObj.object:set_velocity(selfObj._velocity)
|
||||||
end
|
end
|
||||||
|
|
||||||
selfObj.object:set_acceleration({x = 0, y = -9.81, z = 0})
|
selfObj.object:set_acceleration({ x = 0, y = -9.81, z = 0 })
|
||||||
end
|
end
|
||||||
|
|
||||||
if XBows.mesecons and node.name == 'x_bows:target' then
|
if XBows.mesecons and node.name == 'x_bows:target' then
|
||||||
|
@ -1302,21 +1339,24 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
if node_def.walkable then
|
if node_def.walkable then
|
||||||
selfObj.object:set_velocity({x=0, y=0, z=0})
|
selfObj.object:set_velocity({ x = 0, y = 0, z = 0 })
|
||||||
selfObj.object:set_acceleration({x=0, y=0, z=0})
|
selfObj.object:set_acceleration({ x = 0, y = 0, z = 0 })
|
||||||
selfObj.object:set_pos(ip_pos)
|
selfObj.object:set_pos(ip_pos)
|
||||||
selfObj.object:set_rotation(selfObj.object:get_rotation())
|
selfObj.object:set_rotation(selfObj.object:get_rotation())
|
||||||
selfObj._attached = true
|
selfObj._attached = true
|
||||||
selfObj._attached_to.type = pointed_thing.type
|
selfObj._attached_to.type = pointed_thing.type
|
||||||
selfObj._attached_to.pos = pointed_thing.under
|
selfObj._attached_to.pos = pointed_thing.under
|
||||||
selfObj.object:set_properties({collisionbox = {-0.2, -0.2, -0.2, 0.2, 0.2, 0.2}})
|
selfObj.object:set_properties({ collisionbox = { -0.2, -0.2, -0.2, 0.2, 0.2, 0.2 } })
|
||||||
|
|
||||||
-- remove last arrow when too many already attached
|
-- remove last arrow when too many already attached
|
||||||
local children = {}
|
local children = {}
|
||||||
local projectile_entity = self.registered_arrows[selfObj._arrow_name].custom.projectile_entity
|
local projectile_entity = self.registered_arrows[selfObj._arrow_name].custom.projectile_entity
|
||||||
|
|
||||||
for _, object in ipairs(minetest.get_objects_inside_radius(pointed_thing.under, 1)) do
|
for _, object in ipairs(minetest.get_objects_inside_radius(pointed_thing.under, 1)) do
|
||||||
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == projectile_entity then
|
if not object:is_player()
|
||||||
|
and object:get_luaentity()
|
||||||
|
and object:get_luaentity().name == projectile_entity
|
||||||
|
then
|
||||||
table.insert(children, object)
|
table.insert(children, object)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1344,15 +1384,15 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
minetest.add_particlespawner({
|
minetest.add_particlespawner({
|
||||||
amount = 5,
|
amount = 5,
|
||||||
time = 0.25,
|
time = 0.25,
|
||||||
minpos = {x = new_pos.x - 0.4, y = new_pos.y + 0.2, z = new_pos.z - 0.4},
|
minpos = { x = new_pos.x - 0.4, y = new_pos.y + 0.2, z = new_pos.z - 0.4 },
|
||||||
maxpos = {x = new_pos.x + 0.4, y = new_pos.y + 0.3, z = new_pos.z + 0.4},
|
maxpos = { x = new_pos.x + 0.4, y = new_pos.y + 0.3, z = new_pos.z + 0.4 },
|
||||||
minvel = {x = 0, y = 3, z = 0},
|
minvel = { x = 0, y = 3, z = 0 },
|
||||||
maxvel = {x = 0, y = 4, z = 0},
|
maxvel = { x = 0, y = 4, z = 0 },
|
||||||
minacc = {x = 0, y = -28, z = 0},
|
minacc = { x = 0, y = -28, z = 0 },
|
||||||
maxacc = {x = 0, y = -32, z = 0},
|
maxacc = { x = 0, y = -32, z = 0 },
|
||||||
minexptime = 1,
|
minexptime = 1,
|
||||||
maxexptime = 1.5,
|
maxexptime = 1.5,
|
||||||
node = {name = node_def.name},
|
node = { name = node_def.name },
|
||||||
collisiondetection = true,
|
collisiondetection = true,
|
||||||
object_collision = true,
|
object_collision = true,
|
||||||
})
|
})
|
||||||
|
@ -1373,7 +1413,9 @@ function XBowsEntityDef.on_step(self, selfObj, dtime)
|
||||||
selfObj._old_pos = pos
|
selfObj._old_pos = pos
|
||||||
end
|
end
|
||||||
|
|
||||||
---Function receive a "luaentity" table as `self`. Called when somebody punches the object. Note that you probably want to handle most punches using the automatic armor group system. Can return `true` to prevent the default damage mechanism.
|
---Function receive a "luaentity" table as `self`. Called when somebody punches the object.
|
||||||
|
---Note that you probably want to handle most punches using the automatic armor group system.
|
||||||
|
---Can return `true` to prevent the default damage mechanism.
|
||||||
---@param self XBows
|
---@param self XBows
|
||||||
---@param selfObj EnityCustomAttrDef
|
---@param selfObj EnityCustomAttrDef
|
||||||
---@param puncher ObjectRef|nil
|
---@param puncher ObjectRef|nil
|
||||||
|
@ -1408,12 +1450,12 @@ function XBows.register_entity(self, name, def)
|
||||||
def.initial_properties = mergeTables({
|
def.initial_properties = mergeTables({
|
||||||
---defaults
|
---defaults
|
||||||
visual = 'wielditem',
|
visual = 'wielditem',
|
||||||
collisionbox = {0, 0, 0, 0, 0, 0},
|
collisionbox = { 0, 0, 0, 0, 0, 0 },
|
||||||
selectionbox = {0, 0, 0, 0, 0, 0},
|
selectionbox = { 0, 0, 0, 0, 0, 0 },
|
||||||
physical = false,
|
physical = false,
|
||||||
textures = {'air'},
|
textures = { 'air' },
|
||||||
hp_max = 1,
|
hp_max = 1,
|
||||||
visual_size = {x = 1, y = 1, z = 1},
|
visual_size = { x = 1, y = 1, z = 1 },
|
||||||
glow = 1
|
glow = 1
|
||||||
}, def.initial_properties or {})
|
}, def.initial_properties or {})
|
||||||
|
|
||||||
|
@ -1510,6 +1552,7 @@ end
|
||||||
---Gets arrow from quiver
|
---Gets arrow from quiver
|
||||||
---@param self XBowsQuiver
|
---@param self XBowsQuiver
|
||||||
---@param player ObjectRef
|
---@param player ObjectRef
|
||||||
|
---@diagnostic disable-next-line: codestyle-check
|
||||||
---@return {["found_arrow_stack"]: ItemStack|nil, ["quiver_id"]: string|nil, ["quiver_name"]: string|nil, ["found_arrow_stack_idx"]: number}
|
---@return {["found_arrow_stack"]: ItemStack|nil, ["quiver_id"]: string|nil, ["quiver_name"]: string|nil, ["found_arrow_stack_idx"]: number}
|
||||||
function XBowsQuiver.get_itemstack_arrow_from_quiver(self, player)
|
function XBowsQuiver.get_itemstack_arrow_from_quiver(self, player)
|
||||||
local player_inv = player:get_inventory()
|
local player_inv = player:get_inventory()
|
||||||
|
@ -1591,7 +1634,10 @@ function XBowsQuiver.get_itemstack_arrow_from_quiver(self, player)
|
||||||
table.insert(prev_detached_inv_list, detached_inv:get_stack('main', j))
|
table.insert(prev_detached_inv_list, detached_inv:get_stack('main', j))
|
||||||
|
|
||||||
if not qst:is_empty() and not found_arrow_stack then
|
if not qst:is_empty() and not found_arrow_stack then
|
||||||
local is_allowed_ammunition = self:is_allowed_ammunition(wielded_stack:get_name(), qst:get_name())
|
local is_allowed_ammunition = self:is_allowed_ammunition(
|
||||||
|
wielded_stack:get_name(),
|
||||||
|
qst:get_name()
|
||||||
|
)
|
||||||
|
|
||||||
if is_allowed_ammunition then
|
if is_allowed_ammunition then
|
||||||
quiver_name = st:get_name()
|
quiver_name = st:get_name()
|
||||||
|
@ -1703,32 +1749,32 @@ function XBowsQuiver.udate_or_create_hud(self, player, inv_list, idx)
|
||||||
---title image
|
---title image
|
||||||
self.hud_item_ids[player_name].title_image = player:hud_add({
|
self.hud_item_ids[player_name].title_image = player:hud_add({
|
||||||
hud_elem_type = 'image',
|
hud_elem_type = 'image',
|
||||||
position = {x = 1, y = 0.5},
|
position = { x = 1, y = 0.5 },
|
||||||
offset = {x = -120, y = -140},
|
offset = { x = -120, y = -140 },
|
||||||
text = item_def.inventory_image,
|
text = item_def.inventory_image,
|
||||||
scale = {x = 4, y = 4},
|
scale = { x = 4, y = 4 },
|
||||||
alignment = 0,
|
alignment = 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
---title copy
|
---title copy
|
||||||
self.hud_item_ids[player_name].title_copy = player:hud_add({
|
self.hud_item_ids[player_name].title_copy = player:hud_add({
|
||||||
hud_elem_type = 'text',
|
hud_elem_type = 'text',
|
||||||
position = {x = 1, y = 0.5},
|
position = { x = 1, y = 0.5 },
|
||||||
offset = {x = -120, y = -75},
|
offset = { x = -120, y = -75 },
|
||||||
text = item_def.short_description,
|
text = item_def.short_description,
|
||||||
alignment = 0,
|
alignment = 0,
|
||||||
scale = {x = 100, y = 30},
|
scale = { x = 100, y = 30 },
|
||||||
number = 0xFFFFFF,
|
number = 0xFFFFFF,
|
||||||
})
|
})
|
||||||
|
|
||||||
---hotbar bg
|
---hotbar bg
|
||||||
self.hud_item_ids[player_name].hotbar_bg = player:hud_add({
|
self.hud_item_ids[player_name].hotbar_bg = player:hud_add({
|
||||||
hud_elem_type = 'image',
|
hud_elem_type = 'image',
|
||||||
position = {x = 1, y = 0.5},
|
position = { x = 1, y = 0.5 },
|
||||||
offset = {x = -238, y = 0},
|
offset = { x = -238, y = 0 },
|
||||||
text = is_arrow and 'x_bows_single_hotbar.png' or 'x_bows_quiver_hotbar.png',
|
text = is_arrow and 'x_bows_single_hotbar.png' or 'x_bows_quiver_hotbar.png',
|
||||||
scale = {x = 1, y = 1},
|
scale = { x = 1, y = 1 },
|
||||||
alignment = {x = 1, y = 0 },
|
alignment = { x = 1, y = 0 },
|
||||||
})
|
})
|
||||||
|
|
||||||
for j, qst in ipairs(inv_list) do
|
for j, qst in ipairs(inv_list) do
|
||||||
|
@ -1745,11 +1791,11 @@ function XBowsQuiver.udate_or_create_hud(self, player, inv_list, idx)
|
||||||
---ui selected bg
|
---ui selected bg
|
||||||
self.hud_item_ids[player_name].hotbar_selected = player:hud_add({
|
self.hud_item_ids[player_name].hotbar_selected = player:hud_add({
|
||||||
hud_elem_type = 'image',
|
hud_elem_type = 'image',
|
||||||
position = {x = 1, y = 0.5},
|
position = { x = 1, y = 0.5 },
|
||||||
offset = {x = -308 + (j * 74), y = 2},
|
offset = { x = -308 + (j * 74), y = 2 },
|
||||||
text = 'x_bows_hotbar_selected.png',
|
text = 'x_bows_hotbar_selected.png',
|
||||||
scale = {x = 1, y = 1},
|
scale = { x = 1, y = 1 },
|
||||||
alignment = {x = 1, y = 0 },
|
alignment = { x = 1, y = 0 },
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1757,21 +1803,21 @@ function XBowsQuiver.udate_or_create_hud(self, player, inv_list, idx)
|
||||||
---arrow inventory image
|
---arrow inventory image
|
||||||
table.insert(self.hud_item_ids[player_name].arrow_inv_img, player:hud_add({
|
table.insert(self.hud_item_ids[player_name].arrow_inv_img, player:hud_add({
|
||||||
hud_elem_type = 'image',
|
hud_elem_type = 'image',
|
||||||
position = {x = 1, y = 0.5},
|
position = { x = 1, y = 0.5 },
|
||||||
offset = {x = -300 + (j * 74), y = 0},
|
offset = { x = -300 + (j * 74), y = 0 },
|
||||||
text = found_arrow_stack_def.inventory_image,
|
text = found_arrow_stack_def.inventory_image,
|
||||||
scale = {x = 4, y = 4},
|
scale = { x = 4, y = 4 },
|
||||||
alignment = {x = 1, y = 0 },
|
alignment = { x = 1, y = 0 },
|
||||||
}))
|
}))
|
||||||
|
|
||||||
---stack count
|
---stack count
|
||||||
table.insert(self.hud_item_ids[player_name].stack_count, player:hud_add({
|
table.insert(self.hud_item_ids[player_name].stack_count, player:hud_add({
|
||||||
hud_elem_type = 'text',
|
hud_elem_type = 'text',
|
||||||
position = {x = 1, y = 0.5},
|
position = { x = 1, y = 0.5 },
|
||||||
offset = {x = -244 + (j * 74), y = 23},
|
offset = { x = -244 + (j * 74), y = 23 },
|
||||||
text = is_no_ammo and 0 or qst:get_count(),
|
text = is_no_ammo and 0 or qst:get_count(),
|
||||||
alignment = -1,
|
alignment = -1,
|
||||||
scale = {x = 50, y = 10},
|
scale = { x = 50, y = 10 },
|
||||||
number = 0xFFFFFF,
|
number = 0xFFFFFF,
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
|
@ -1794,7 +1840,7 @@ function XBowsQuiver.get_or_create_detached_inv(self, quiver_id, player_name, qu
|
||||||
local detached_inv
|
local detached_inv
|
||||||
|
|
||||||
if quiver_id ~= '' then
|
if quiver_id ~= '' then
|
||||||
detached_inv = minetest.get_inventory({type='detached', name=quiver_id})
|
detached_inv = minetest.get_inventory({ type = 'detached', name = quiver_id })
|
||||||
end
|
end
|
||||||
|
|
||||||
if not detached_inv then
|
if not detached_inv then
|
||||||
|
@ -1857,7 +1903,7 @@ function XBowsQuiver.get_or_create_detached_inv(self, quiver_id, player_name, qu
|
||||||
|
|
||||||
if quiver_inv_st and quiver_inv_st:get_meta():get_string('quiver_id') == inv:get_location().name then
|
if quiver_inv_st and quiver_inv_st:get_meta():get_string('quiver_id') == inv:get_location().name then
|
||||||
if inv:is_empty('main') then
|
if inv:is_empty('main') then
|
||||||
self:show_3d_quiver(player, {is_empty = true})
|
self:show_3d_quiver(player, { is_empty = true })
|
||||||
else
|
else
|
||||||
self:show_3d_quiver(player)
|
self:show_3d_quiver(player)
|
||||||
end
|
end
|
||||||
|
@ -1875,7 +1921,7 @@ function XBowsQuiver.get_or_create_detached_inv(self, quiver_id, player_name, qu
|
||||||
|
|
||||||
if quiver_inv_st and quiver_inv_st:get_meta():get_string('quiver_id') == inv:get_location().name then
|
if quiver_inv_st and quiver_inv_st:get_meta():get_string('quiver_id') == inv:get_location().name then
|
||||||
if inv:is_empty('main') then
|
if inv:is_empty('main') then
|
||||||
self:show_3d_quiver(player, {is_empty = true})
|
self:show_3d_quiver(player, { is_empty = true })
|
||||||
else
|
else
|
||||||
self:show_3d_quiver(player)
|
self:show_3d_quiver(player)
|
||||||
end
|
end
|
||||||
|
@ -1883,9 +1929,9 @@ function XBowsQuiver.get_or_create_detached_inv(self, quiver_id, player_name, qu
|
||||||
|
|
||||||
self:save(inv, player)
|
self:save(inv, player)
|
||||||
end,
|
end,
|
||||||
}, player_name)
|
}, player_name)
|
||||||
|
|
||||||
detached_inv:set_size('main', 3 * 1)
|
detached_inv:set_size('main', 3 * 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
---populate items in inventory
|
---populate items in inventory
|
||||||
|
@ -1907,11 +1953,11 @@ function XBowsQuiver.get_formspec(self, name)
|
||||||
local list_pos_x = (list_w - width) / 2
|
local list_pos_x = (list_w - width) / 2
|
||||||
|
|
||||||
local formspec = {
|
local formspec = {
|
||||||
'size['..list_w..',6]' ,
|
'size[' .. list_w .. ',6]',
|
||||||
'list[detached:'..name..';main;'..list_pos_x..',0.3;'..width..',1;]',
|
'list[detached:' .. name .. ';main;' .. list_pos_x .. ',0.3;' .. width .. ',1;]',
|
||||||
'list[current_player;main;0,'..(height + 0.85)..';'..list_w..',1;]',
|
'list[current_player;main;0,' .. (height + 0.85) .. ';' .. list_w .. ',1;]',
|
||||||
'list[current_player;main;0,'..(height + 2.08)..';'..list_w..',3;8]',
|
'list[current_player;main;0,' .. (height + 2.08) .. ';' .. list_w .. ',3;8]',
|
||||||
'listring[detached:'..name..';main]',
|
'listring[detached:' .. name .. ';main]',
|
||||||
'listring[current_player;main]'
|
'listring[current_player;main]'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1920,7 +1966,7 @@ function XBowsQuiver.get_formspec(self, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
--update formspec
|
--update formspec
|
||||||
local inv = minetest.get_inventory({type='detached', name=name})
|
local inv = minetest.get_inventory({ type = 'detached', name = name })
|
||||||
local invlist = inv:get_list(name)
|
local invlist = inv:get_list(name)
|
||||||
|
|
||||||
---inventory slots overlay
|
---inventory slots overlay
|
||||||
|
@ -1951,9 +1997,9 @@ function XBowsQuiver.get_string_from_inv(self, inv)
|
||||||
for i, st in ipairs(inv_list) do
|
for i, st in ipairs(inv_list) do
|
||||||
if not st:is_empty() then
|
if not st:is_empty() then
|
||||||
table.insert(t, st:to_table())
|
table.insert(t, st:to_table())
|
||||||
content_description = content_description .. '\n' ..st:get_short_description()..' '..st:get_count()
|
content_description = content_description .. '\n' .. st:get_short_description() .. ' ' .. st:get_count()
|
||||||
else
|
else
|
||||||
table.insert(t, {is_empty = true})
|
table.insert(t, { is_empty = true })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1985,12 +2031,14 @@ end
|
||||||
---@param quiver_is_closed? boolean
|
---@param quiver_is_closed? boolean
|
||||||
---@return nil
|
---@return nil
|
||||||
function XBowsQuiver.save(self, inv, player, quiver_is_closed)
|
function XBowsQuiver.save(self, inv, player, quiver_is_closed)
|
||||||
local player_inv = player:get_inventory()--[[@as InvRef]]
|
local player_inv = player:get_inventory() --[[@as InvRef]]
|
||||||
local inv_loc = inv:get_location()
|
local inv_loc = inv:get_location()
|
||||||
local quiver_item_name = quiver_is_closed and 'x_bows:quiver' or 'x_bows:quiver_open'
|
local quiver_item_name = quiver_is_closed and 'x_bows:quiver' or 'x_bows:quiver_open'
|
||||||
local player_quiver_inv_stack = player_inv:get_stack('x_bows:quiver_inv', 1)
|
local player_quiver_inv_stack = player_inv:get_stack('x_bows:quiver_inv', 1)
|
||||||
|
|
||||||
if not player_quiver_inv_stack:is_empty() and player_quiver_inv_stack:get_meta():get_string('quiver_id') == inv_loc.name then
|
if not player_quiver_inv_stack:is_empty()
|
||||||
|
and player_quiver_inv_stack:get_meta():get_string('quiver_id') == inv_loc.name
|
||||||
|
then
|
||||||
local st_meta = player_quiver_inv_stack:get_meta()
|
local st_meta = player_quiver_inv_stack:get_meta()
|
||||||
---save inventory items in quiver item meta
|
---save inventory items in quiver item meta
|
||||||
local string_from_inventory_result = self:get_string_from_inv(inv)
|
local string_from_inventory_result = self:get_string_from_inv(inv)
|
||||||
|
@ -1998,7 +2046,8 @@ function XBowsQuiver.save(self, inv, player, quiver_is_closed)
|
||||||
st_meta:set_string('quiver_items', string_from_inventory_result.inv_string)
|
st_meta:set_string('quiver_items', string_from_inventory_result.inv_string)
|
||||||
|
|
||||||
---update description
|
---update description
|
||||||
local new_description = player_quiver_inv_stack:get_short_description()..'\n'..string_from_inventory_result.content_description..'\n'
|
local new_description = player_quiver_inv_stack:get_short_description() .. '\n' ..
|
||||||
|
string_from_inventory_result.content_description .. '\n'
|
||||||
|
|
||||||
st_meta:set_string('description', new_description)
|
st_meta:set_string('description', new_description)
|
||||||
player_inv:set_stack('x_bows:quiver_inv', 1, player_quiver_inv_stack)
|
player_inv:set_stack('x_bows:quiver_inv', 1, player_quiver_inv_stack)
|
||||||
|
@ -2009,14 +2058,17 @@ function XBowsQuiver.save(self, inv, player, quiver_is_closed)
|
||||||
for i, st in ipairs(inv_list) do
|
for i, st in ipairs(inv_list) do
|
||||||
local st_meta = st:get_meta()
|
local st_meta = st:get_meta()
|
||||||
|
|
||||||
if not st:is_empty() and st:get_name() == quiver_item_name and st_meta:get_string('quiver_id') == inv_loc.name then
|
if not st:is_empty() and st:get_name() == quiver_item_name
|
||||||
|
and st_meta:get_string('quiver_id') == inv_loc.name
|
||||||
|
then
|
||||||
---save inventory items in quiver item meta
|
---save inventory items in quiver item meta
|
||||||
local string_from_inventory_result = self:get_string_from_inv(inv)
|
local string_from_inventory_result = self:get_string_from_inv(inv)
|
||||||
|
|
||||||
st_meta:set_string('quiver_items', string_from_inventory_result.inv_string)
|
st_meta:set_string('quiver_items', string_from_inventory_result.inv_string)
|
||||||
|
|
||||||
---update description
|
---update description
|
||||||
local new_description = st:get_short_description()..'\n'..string_from_inventory_result.content_description..'\n'
|
local new_description = st:get_short_description() .. '\n' ..
|
||||||
|
string_from_inventory_result.content_description .. '\n'
|
||||||
|
|
||||||
st_meta:set_string('description', new_description)
|
st_meta:set_string('description', new_description)
|
||||||
player_inv:set_stack('main', i, st)
|
player_inv:set_stack('main', i, st)
|
||||||
|
@ -2033,11 +2085,13 @@ end
|
||||||
---@param player ObjectRef
|
---@param player ObjectRef
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function XBowsQuiver.quiver_can_allow(self, inv, player)
|
function XBowsQuiver.quiver_can_allow(self, inv, player)
|
||||||
local player_inv = player:get_inventory()--[[@as InvRef]]
|
local player_inv = player:get_inventory() --[[@as InvRef]]
|
||||||
local inv_loc = inv:get_location()
|
local inv_loc = inv:get_location()
|
||||||
local player_quiver_inv_stack = player_inv:get_stack('x_bows:quiver_inv', 1)
|
local player_quiver_inv_stack = player_inv:get_stack('x_bows:quiver_inv', 1)
|
||||||
|
|
||||||
if not player_quiver_inv_stack:is_empty() and player_quiver_inv_stack:get_meta():get_string('quiver_id') == inv_loc.name then
|
if not player_quiver_inv_stack:is_empty()
|
||||||
|
and player_quiver_inv_stack:get_meta():get_string('quiver_id') == inv_loc.name
|
||||||
|
then
|
||||||
---find quiver in player `quiver_inv` inv list
|
---find quiver in player `quiver_inv` inv list
|
||||||
return true
|
return true
|
||||||
elseif player_inv and player_inv:contains_item('main', 'x_bows:quiver_open') then
|
elseif player_inv and player_inv:contains_item('main', 'x_bows:quiver_open') then
|
||||||
|
@ -2048,7 +2102,9 @@ function XBowsQuiver.quiver_can_allow(self, inv, player)
|
||||||
for i, st in ipairs(inv_list) do
|
for i, st in ipairs(inv_list) do
|
||||||
local st_meta = st:get_meta()
|
local st_meta = st:get_meta()
|
||||||
|
|
||||||
if not st:is_empty() and st:get_name() == 'x_bows:quiver_open' and st_meta:get_string('quiver_id') == inv_loc.name then
|
if not st:is_empty() and st:get_name() == 'x_bows:quiver_open'
|
||||||
|
and st_meta:get_string('quiver_id') == inv_loc.name
|
||||||
|
then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2069,7 +2125,7 @@ function XBows.open_quiver(self, itemstack, user)
|
||||||
|
|
||||||
---create inventory id and save it
|
---create inventory id and save it
|
||||||
if quiver_id == '' then
|
if quiver_id == '' then
|
||||||
quiver_id = itemstack:get_name()..'_'..self.uuid()
|
quiver_id = itemstack:get_name() .. '_' .. self.uuid()
|
||||||
itemstack_meta:set_string('quiver_id', quiver_id)
|
itemstack_meta:set_string('quiver_id', quiver_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2120,7 +2176,9 @@ function XBowsQuiver.sfinv_register_page(self)
|
||||||
local x_bows_registered_arrow_def = self.registered_arrows[context._itemstack_arrow:get_name()]
|
local x_bows_registered_arrow_def = self.registered_arrows[context._itemstack_arrow:get_name()]
|
||||||
|
|
||||||
if x_bows_registered_arrow_def then
|
if x_bows_registered_arrow_def then
|
||||||
formspec[#formspec + 1] = 'label[0,1.5;' .. minetest.formspec_escape(context._itemstack_arrow:get_short_description()) .. '\n'.. minetest.formspec_escape(x_bows_registered_arrow_def.custom.description_abilities) ..']'
|
formspec[#formspec + 1] = 'label[0,1.5;' ..
|
||||||
|
minetest.formspec_escape(context._itemstack_arrow:get_short_description()) .. '\n' ..
|
||||||
|
minetest.formspec_escape(x_bows_registered_arrow_def.custom.description_abilities) .. ']'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2130,9 +2188,10 @@ function XBowsQuiver.sfinv_register_page(self)
|
||||||
local quiver_id = st_meta:get_string('quiver_id')
|
local quiver_id = st_meta:get_string('quiver_id')
|
||||||
|
|
||||||
---description
|
---description
|
||||||
formspec[#formspec + 1] = 'label[3.5,1.5;' .. minetest.formspec_escape(context._itemstack_quiver:get_short_description()) .. ']'
|
formspec[#formspec + 1] = 'label[3.5,1.5;' ..
|
||||||
formspec[#formspec + 1] = 'list[detached:'..quiver_id..';main;4.5,0.5;3,1;]'
|
minetest.formspec_escape(context._itemstack_quiver:get_short_description()) .. ']'
|
||||||
formspec[#formspec + 1] = 'listring[detached:'..quiver_id..';main]'
|
formspec[#formspec + 1] = 'list[detached:' .. quiver_id .. ';main;4.5,0.5;3,1;]'
|
||||||
|
formspec[#formspec + 1] = 'listring[detached:' .. quiver_id .. ';main]'
|
||||||
formspec[#formspec + 1] = 'listring[current_player;main]'
|
formspec[#formspec + 1] = 'listring[current_player;main]'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2187,7 +2246,9 @@ function XBowsQuiver.i3_register_page(self)
|
||||||
local x_bows_registered_arrow_def = self.registered_arrows[context._itemstack_arrow:get_name()]
|
local x_bows_registered_arrow_def = self.registered_arrows[context._itemstack_arrow:get_name()]
|
||||||
|
|
||||||
if x_bows_registered_arrow_def then
|
if x_bows_registered_arrow_def then
|
||||||
formspec[#formspec + 1] = 'label[0.5,3;' .. minetest.formspec_escape(context._itemstack_arrow:get_short_description()) .. '\n'.. minetest.formspec_escape(x_bows_registered_arrow_def.custom.description_abilities) ..']'
|
formspec[#formspec + 1] = 'label[0.5,3;' ..
|
||||||
|
minetest.formspec_escape(context._itemstack_arrow:get_short_description()) .. '\n' ..
|
||||||
|
minetest.formspec_escape(x_bows_registered_arrow_def.custom.description_abilities) .. ']'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2197,9 +2258,10 @@ function XBowsQuiver.i3_register_page(self)
|
||||||
local quiver_id = st_meta:get_string('quiver_id')
|
local quiver_id = st_meta:get_string('quiver_id')
|
||||||
|
|
||||||
---description
|
---description
|
||||||
formspec[#formspec + 1] = 'label[5,3;' .. minetest.formspec_escape(context._itemstack_quiver:get_short_description()) .. ']'
|
formspec[#formspec + 1] = 'label[5,3;' ..
|
||||||
formspec[#formspec + 1] = 'list[detached:'..quiver_id..';main;6.3,1.5;3,1;]'
|
minetest.formspec_escape(context._itemstack_quiver:get_short_description()) .. ']'
|
||||||
formspec[#formspec + 1] = 'listring[detached:'..quiver_id..';main]'
|
formspec[#formspec + 1] = 'list[detached:' .. quiver_id .. ';main;6.3,1.5;3,1;]'
|
||||||
|
formspec[#formspec + 1] = 'listring[detached:' .. quiver_id .. ';main]'
|
||||||
formspec[#formspec + 1] = 'listring[current_player;main]'
|
formspec[#formspec + 1] = 'listring[current_player;main]'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2219,13 +2281,13 @@ function XBowsQuiver.ui_register_page(self)
|
||||||
'listcolors[#00000000;#00000000]',
|
'listcolors[#00000000;#00000000]',
|
||||||
---arrow
|
---arrow
|
||||||
'label[0.5,0.5;' .. minetest.formspec_escape(S('Arrows')) .. ':]',
|
'label[0.5,0.5;' .. minetest.formspec_escape(S('Arrows')) .. ':]',
|
||||||
unified_inventory.single_slot(0.4,0.9),
|
unified_inventory.single_slot(0.4, 0.9),
|
||||||
'list[current_player;x_bows:arrow_inv;0.5,1;1,1;]',
|
'list[current_player;x_bows:arrow_inv;0.5,1;1,1;]',
|
||||||
'listring[current_player;x_bows:arrow_inv]',
|
'listring[current_player;x_bows:arrow_inv]',
|
||||||
'listring[current_player;main]',
|
'listring[current_player;main]',
|
||||||
---quiver
|
---quiver
|
||||||
'label[5,0.5;' .. minetest.formspec_escape(S('Quiver')) .. ':]',
|
'label[5,0.5;' .. minetest.formspec_escape(S('Quiver')) .. ':]',
|
||||||
unified_inventory.single_slot(4.9,0.9),
|
unified_inventory.single_slot(4.9, 0.9),
|
||||||
'list[current_player;x_bows:quiver_inv;5,1;1,1;]',
|
'list[current_player;x_bows:quiver_inv;5,1;1,1;]',
|
||||||
'listring[current_player;x_bows:quiver_inv]',
|
'listring[current_player;x_bows:quiver_inv]',
|
||||||
'listring[current_player;main]',
|
'listring[current_player;main]',
|
||||||
|
@ -2239,7 +2301,9 @@ function XBowsQuiver.ui_register_page(self)
|
||||||
local x_bows_registered_arrow_def = self.registered_arrows[context._itemstack_arrow:get_name()]
|
local x_bows_registered_arrow_def = self.registered_arrows[context._itemstack_arrow:get_name()]
|
||||||
|
|
||||||
if x_bows_registered_arrow_def then
|
if x_bows_registered_arrow_def then
|
||||||
formspec[#formspec + 1] = 'label[0.5,2.5;' .. minetest.formspec_escape(context._itemstack_arrow:get_short_description()) .. '\n'.. minetest.formspec_escape(x_bows_registered_arrow_def.custom.description_abilities) ..']'
|
formspec[#formspec + 1] = 'label[0.5,2.5;' ..
|
||||||
|
minetest.formspec_escape(context._itemstack_arrow:get_short_description()) .. '\n' ..
|
||||||
|
minetest.formspec_escape(x_bows_registered_arrow_def.custom.description_abilities) .. ']'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2249,12 +2313,13 @@ function XBowsQuiver.ui_register_page(self)
|
||||||
local quiver_id = st_meta:get_string('quiver_id')
|
local quiver_id = st_meta:get_string('quiver_id')
|
||||||
|
|
||||||
---description
|
---description
|
||||||
formspec[#formspec + 1] = 'label[5,2.5;' .. minetest.formspec_escape(context._itemstack_quiver:get_short_description()) .. ']'
|
formspec[#formspec + 1] = 'label[5,2.5;' ..
|
||||||
formspec[#formspec + 1] = unified_inventory.single_slot(6.4,0.9)
|
minetest.formspec_escape(context._itemstack_quiver:get_short_description()) .. ']'
|
||||||
formspec[#formspec + 1] = unified_inventory.single_slot(7.65,0.9)
|
formspec[#formspec + 1] = unified_inventory.single_slot(6.4, 0.9)
|
||||||
formspec[#formspec + 1] = unified_inventory.single_slot(8.9,0.9)
|
formspec[#formspec + 1] = unified_inventory.single_slot(7.65, 0.9)
|
||||||
formspec[#formspec + 1] = 'list[detached:'..quiver_id..';main;6.5,1;3,1;]'
|
formspec[#formspec + 1] = unified_inventory.single_slot(8.9, 0.9)
|
||||||
formspec[#formspec + 1] = 'listring[detached:'..quiver_id..';main]'
|
formspec[#formspec + 1] = 'list[detached:' .. quiver_id .. ';main;6.5,1;3,1;]'
|
||||||
|
formspec[#formspec + 1] = 'listring[detached:' .. quiver_id .. ';main]'
|
||||||
formspec[#formspec + 1] = 'listring[current_player;main]'
|
formspec[#formspec + 1] = 'listring[current_player;main]'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2291,7 +2356,9 @@ function XBowsQuiver.show_3d_quiver(self, player, props)
|
||||||
|
|
||||||
---cleanup
|
---cleanup
|
||||||
for index, value in ipairs(textures) do
|
for index, value in ipairs(textures) do
|
||||||
if value == 'x_bows_quiver_blank_mesh.png' or value == 'x_bows_quiver_mesh.png' or value == 'x_bows_quiver_empty_mesh.png' then
|
if value == 'x_bows_quiver_blank_mesh.png' or value == 'x_bows_quiver_mesh.png'
|
||||||
|
or value == 'x_bows_quiver_empty_mesh.png'
|
||||||
|
then
|
||||||
table.remove(textures, index)
|
table.remove(textures, index)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2350,7 +2417,9 @@ function XBowsQuiver.show_3d_quiver(self, player, props)
|
||||||
|
|
||||||
---cleanup
|
---cleanup
|
||||||
for index, value in ipairs(textures) do
|
for index, value in ipairs(textures) do
|
||||||
if value == 'x_bows_quiver_blank_mesh.png' or value == 'x_bows_quiver_mesh.png' or value == 'x_bows_quiver_empty_mesh.png' then
|
if value == 'x_bows_quiver_blank_mesh.png' or value == 'x_bows_quiver_mesh.png'
|
||||||
|
or value == 'x_bows_quiver_empty_mesh.png'
|
||||||
|
then
|
||||||
table.remove(textures, index)
|
table.remove(textures, index)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2385,7 +2454,9 @@ function XBowsQuiver.hide_3d_quiver(self, player)
|
||||||
|
|
||||||
---cleanup
|
---cleanup
|
||||||
for index, value in ipairs(textures) do
|
for index, value in ipairs(textures) do
|
||||||
if value == 'x_bows_quiver_mesh.png' or value == 'x_bows_quiver_blank_mesh.png' or value == 'x_bows_quiver_empty_mesh.png' then
|
if value == 'x_bows_quiver_mesh.png' or value == 'x_bows_quiver_blank_mesh.png'
|
||||||
|
or value == 'x_bows_quiver_empty_mesh.png'
|
||||||
|
then
|
||||||
table.remove(textures, index)
|
table.remove(textures, index)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2433,7 +2504,9 @@ function XBowsQuiver.hide_3d_quiver(self, player)
|
||||||
|
|
||||||
---cleanup
|
---cleanup
|
||||||
for index, value in ipairs(textures) do
|
for index, value in ipairs(textures) do
|
||||||
if value == 'x_bows_quiver_mesh.png' or value == 'x_bows_quiver_blank_mesh.png' or value == 'x_bows_quiver_empty_mesh.png' then
|
if value == 'x_bows_quiver_mesh.png' or value == 'x_bows_quiver_blank_mesh.png'
|
||||||
|
or value == 'x_bows_quiver_empty_mesh.png'
|
||||||
|
then
|
||||||
table.remove(textures, index)
|
table.remove(textures, index)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2453,7 +2526,7 @@ end
|
||||||
---@return string[] | nil
|
---@return string[] | nil
|
||||||
local function split(str)
|
local function split(str)
|
||||||
if #str > 0 then
|
if #str > 0 then
|
||||||
return str:sub(1,1), split(str:sub(2))
|
return str:sub(1, 1), split(str:sub(2))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2464,7 +2537,7 @@ function XBows.show_damage_numbers(self, pos, damage, is_crit)
|
||||||
|
|
||||||
---get damage texture
|
---get damage texture
|
||||||
local dmgstr = tostring(math.round(damage))
|
local dmgstr = tostring(math.round(damage))
|
||||||
local results = {split(dmgstr)}
|
local results = { split(dmgstr) }
|
||||||
local texture = ''
|
local texture = ''
|
||||||
local dmg_nr_offset = 0
|
local dmg_nr_offset = 0
|
||||||
|
|
||||||
|
@ -2492,12 +2565,12 @@ function XBows.show_damage_numbers(self, pos, damage, is_crit)
|
||||||
minetest.add_particlespawner({
|
minetest.add_particlespawner({
|
||||||
amount = 1,
|
amount = 1,
|
||||||
time = 0.01,
|
time = 0.01,
|
||||||
minpos = {x = pos.x, y = pos.y + 1, z = pos.z},
|
minpos = { x = pos.x, y = pos.y + 1, z = pos.z },
|
||||||
maxpos = {x = pos.x, y = pos.y + 2, z = pos.z},
|
maxpos = { x = pos.x, y = pos.y + 2, z = pos.z },
|
||||||
minvel = {x = math.random(-1, 1), y = 5, z = math.random(-1, 1)},
|
minvel = { x = math.random(-1, 1), y = 5, z = math.random(-1, 1) },
|
||||||
maxvel = {x = math.random(-1, 1), y = 5, z = math.random(-1, 1)},
|
maxvel = { x = math.random(-1, 1), y = 5, z = math.random(-1, 1) },
|
||||||
minacc = {x = math.random(-1, 1), y = -7, z = math.random(-1, 1)},
|
minacc = { x = math.random(-1, 1), y = -7, z = math.random(-1, 1) },
|
||||||
maxacc = {x = math.random(-1, 1), y = -7, z = math.random(-1, 1)},
|
maxacc = { x = math.random(-1, 1), y = -7, z = math.random(-1, 1) },
|
||||||
minexptime = 2,
|
minexptime = 2,
|
||||||
maxexptime = 2,
|
maxexptime = 2,
|
||||||
minsize = size,
|
minsize = size,
|
||||||
|
|
|
@ -2,12 +2,12 @@ XBows:register_entity('arrow_entity', {
|
||||||
initial_properties = {
|
initial_properties = {
|
||||||
visual = 'mesh',
|
visual = 'mesh',
|
||||||
mesh = 'x_bows_arrow.b3d',
|
mesh = 'x_bows_arrow.b3d',
|
||||||
textures = {'x_bows_arrow_mesh.png'},
|
textures = { 'x_bows_arrow_mesh.png' },
|
||||||
},
|
},
|
||||||
_custom = {
|
_custom = {
|
||||||
animations = {
|
animations = {
|
||||||
idle = {{x = 41, y = 42}, 0, 0, false},
|
idle = { { x = 41, y = 42 }, 0, 0, false },
|
||||||
on_hit_node = {{x = 1, y = 40}, 40, 0, false}
|
on_hit_node = { { x = 1, y = 40 }, 40, 0, false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Binary file not shown.
|
@ -3,34 +3,6 @@ image: atlassian/default-image:3
|
||||||
pipelines:
|
pipelines:
|
||||||
pull-requests:
|
pull-requests:
|
||||||
"**":
|
"**":
|
||||||
- step:
|
|
||||||
name: Lint code
|
|
||||||
script:
|
|
||||||
- apt-get update
|
|
||||||
- apt-get -y install lua5.1
|
|
||||||
- apt-get -y install luarocks
|
|
||||||
- luarocks install luacheck
|
|
||||||
- luacheck .
|
|
||||||
branches:
|
|
||||||
master:
|
|
||||||
- step:
|
|
||||||
name: Lint code
|
|
||||||
script:
|
|
||||||
- apt-get update
|
|
||||||
- apt-get -y install lua5.1
|
|
||||||
- apt-get -y install luarocks
|
|
||||||
- luarocks install luacheck
|
|
||||||
- luacheck .
|
|
||||||
tags:
|
|
||||||
"*":
|
|
||||||
- step:
|
|
||||||
name: Lint code
|
|
||||||
script:
|
|
||||||
- apt-get update
|
|
||||||
- apt-get -y install lua5.1
|
|
||||||
- apt-get -y install luarocks
|
|
||||||
- luarocks install luacheck
|
|
||||||
- luacheck .
|
|
||||||
- step:
|
- step:
|
||||||
name: Install Node Dependencies
|
name: Install Node Dependencies
|
||||||
caches:
|
caches:
|
||||||
|
@ -41,6 +13,84 @@ pipelines:
|
||||||
- nvm install v17.2.0
|
- nvm install v17.2.0
|
||||||
- npm i -g npm@8
|
- npm i -g npm@8
|
||||||
- npm ci
|
- npm ci
|
||||||
|
- parallel:
|
||||||
|
- step:
|
||||||
|
name: Lua Check
|
||||||
|
script:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get -y install lua5.1
|
||||||
|
- apt-get -y install luarocks
|
||||||
|
- luarocks install luacheck
|
||||||
|
- luacheck .
|
||||||
|
- step:
|
||||||
|
name: Lua Diagnostics
|
||||||
|
caches:
|
||||||
|
- node-modules
|
||||||
|
- npm
|
||||||
|
- nvm
|
||||||
|
script:
|
||||||
|
- nvm use v17.2.0
|
||||||
|
- npm run lua-diagnostics
|
||||||
|
branches:
|
||||||
|
master:
|
||||||
|
- step:
|
||||||
|
name: Install Node Dependencies
|
||||||
|
caches:
|
||||||
|
- node-modules
|
||||||
|
- npm
|
||||||
|
- nvm
|
||||||
|
script:
|
||||||
|
- nvm install v17.2.0
|
||||||
|
- npm i -g npm@8
|
||||||
|
- npm ci
|
||||||
|
- parallel:
|
||||||
|
- step:
|
||||||
|
name: Lua Check
|
||||||
|
script:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get -y install lua5.1
|
||||||
|
- apt-get -y install luarocks
|
||||||
|
- luarocks install luacheck
|
||||||
|
- luacheck .
|
||||||
|
- step:
|
||||||
|
name: Lua Diagnostics
|
||||||
|
caches:
|
||||||
|
- node-modules
|
||||||
|
- npm
|
||||||
|
- nvm
|
||||||
|
script:
|
||||||
|
- nvm use v17.2.0
|
||||||
|
- npm run lua-diagnostics
|
||||||
|
tags:
|
||||||
|
"*":
|
||||||
|
- step:
|
||||||
|
name: Install Node Dependencies
|
||||||
|
caches:
|
||||||
|
- node-modules
|
||||||
|
- npm
|
||||||
|
- nvm
|
||||||
|
script:
|
||||||
|
- nvm install v17.2.0
|
||||||
|
- npm i -g npm@8
|
||||||
|
- npm ci
|
||||||
|
- parallel:
|
||||||
|
- step:
|
||||||
|
name: Lua Check
|
||||||
|
script:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get -y install lua5.1
|
||||||
|
- apt-get -y install luarocks
|
||||||
|
- luarocks install luacheck
|
||||||
|
- luacheck .
|
||||||
|
- step:
|
||||||
|
name: Lua Diagnostics
|
||||||
|
caches:
|
||||||
|
- node-modules
|
||||||
|
- npm
|
||||||
|
- nvm
|
||||||
|
script:
|
||||||
|
- nvm use v17.2.0
|
||||||
|
- npm run lua-diagnostics
|
||||||
- step:
|
- step:
|
||||||
name: Deploy to ContentDB
|
name: Deploy to ContentDB
|
||||||
caches:
|
caches:
|
||||||
|
|
56
init.lua
56
init.lua
|
@ -1,15 +1,15 @@
|
||||||
-- X Bows
|
-- X Bows
|
||||||
-- by SaKeL
|
-- by SaKeL
|
||||||
|
|
||||||
minetest = minetest.global_exists('minetest') and minetest--[[@as Minetest]]
|
minetest = minetest.global_exists('minetest') and minetest --[[@as Minetest]]
|
||||||
ItemStack = minetest.global_exists('ItemStack') and ItemStack--[[@as ItemStack]]
|
ItemStack = minetest.global_exists('ItemStack') and ItemStack --[[@as ItemStack]]
|
||||||
vector = minetest.global_exists('vector') and vector--[[@as Vector]]
|
vector = minetest.global_exists('vector') and vector --[[@as Vector]]
|
||||||
default = minetest.global_exists('default') and default--[[@as MtgDefault]]
|
default = minetest.global_exists('default') and default --[[@as MtgDefault]]
|
||||||
sfinv = minetest.global_exists('sfinv') and sfinv--[[@as Sfinv]]
|
sfinv = minetest.global_exists('sfinv') and sfinv --[[@as Sfinv]]
|
||||||
unified_inventory = minetest.global_exists('unified_inventory') and unified_inventory--[[@as UnifiedInventory]]
|
unified_inventory = minetest.global_exists('unified_inventory') and unified_inventory --[[@as UnifiedInventory]]
|
||||||
player_api = minetest.global_exists('player_api') and player_api--[[@as MtgPlayerApi]]
|
player_api = minetest.global_exists('player_api') and player_api --[[@as MtgPlayerApi]]
|
||||||
|
|
||||||
math.randomseed(tonumber(tostring(os.time()):reverse():sub(1, 9))--[[@as number]])
|
math.randomseed(tonumber(tostring(os.time()):reverse():sub(1, 9))--[[@as number]] )
|
||||||
|
|
||||||
local path = minetest.get_modpath('x_bows')
|
local path = minetest.get_modpath('x_bows')
|
||||||
local mod_start_time = minetest.get_us_time()
|
local mod_start_time = minetest.get_us_time()
|
||||||
|
@ -30,8 +30,8 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
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 and XBows.player_api then
|
if XBows.settings.x_bows_show_3d_quiver and XBows.player_api then
|
||||||
---Order matters here
|
---Order matters here
|
||||||
|
@ -63,7 +63,7 @@ minetest.register_on_joinplayer(function(player)
|
||||||
---set model textures
|
---set model textures
|
||||||
if detached_inv:is_empty('main') then
|
if detached_inv:is_empty('main') then
|
||||||
XBowsQuiver.quiver_empty_state[player:get_player_name()] = false
|
XBowsQuiver.quiver_empty_state[player:get_player_name()] = false
|
||||||
XBowsQuiver:show_3d_quiver(player, {is_empty = true})
|
XBowsQuiver:show_3d_quiver(player, { is_empty = true })
|
||||||
else
|
else
|
||||||
XBowsQuiver.quiver_empty_state[player:get_player_name()] = true
|
XBowsQuiver.quiver_empty_state[player:get_player_name()] = true
|
||||||
XBowsQuiver:show_3d_quiver(player)
|
XBowsQuiver:show_3d_quiver(player)
|
||||||
|
@ -90,19 +90,19 @@ if XBows.settings.x_bows_show_3d_quiver and XBows.player_api 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' },
|
||||||
animations = {
|
animations = {
|
||||||
-- Standard animations.
|
-- Standard animations.
|
||||||
stand = {x = 0, y = 79},
|
stand = { x = 0, y = 79 },
|
||||||
lay = {x = 162, y = 166, eye_height = 0.3, override_local = true,
|
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}},
|
collisionbox = { -0.6, 0.0, -0.6, 0.6, 0.3, 0.6 } },
|
||||||
walk = {x = 168, y = 187},
|
walk = { x = 168, y = 187 },
|
||||||
mine = {x = 189, y = 198},
|
mine = { x = 189, y = 198 },
|
||||||
walk_mine = {x = 200, y = 219},
|
walk_mine = { x = 200, y = 219 },
|
||||||
sit = {x = 81, y = 160, eye_height = 0.8, override_local = true,
|
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.0, 0.3 } }
|
||||||
},
|
},
|
||||||
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
|
collisionbox = { -0.3, 0.0, -0.3, 0.3, 1.7, 0.3 },
|
||||||
stepheight = 0.6,
|
stepheight = 0.6,
|
||||||
eye_height = 1.47
|
eye_height = 1.47
|
||||||
})
|
})
|
||||||
|
@ -218,7 +218,7 @@ minetest.register_on_player_inventory_action(function(player, action, inventory,
|
||||||
local quiver_id = st_meta:get_string('quiver_id')
|
local quiver_id = st_meta:get_string('quiver_id')
|
||||||
|
|
||||||
if quiver_id == '' then
|
if quiver_id == '' then
|
||||||
quiver_id = stack:get_name()..'_'..XBows.uuid()
|
quiver_id = stack:get_name() .. '_' .. XBows.uuid()
|
||||||
st_meta:set_string('quiver_id', quiver_id)
|
st_meta:set_string('quiver_id', quiver_id)
|
||||||
inventory:set_stack(inventory_info.to_list, inventory_info.to_index, stack)
|
inventory:set_stack(inventory_info.to_list, inventory_info.to_index, stack)
|
||||||
end
|
end
|
||||||
|
@ -240,7 +240,7 @@ minetest.register_on_player_inventory_action(function(player, action, inventory,
|
||||||
---set player visual
|
---set player visual
|
||||||
if detached_inv:is_empty('main') then
|
if detached_inv:is_empty('main') then
|
||||||
XBowsQuiver.quiver_empty_state[player:get_player_name()] = false
|
XBowsQuiver.quiver_empty_state[player:get_player_name()] = false
|
||||||
XBowsQuiver:show_3d_quiver(player, {is_empty = true})
|
XBowsQuiver:show_3d_quiver(player, { is_empty = true })
|
||||||
else
|
else
|
||||||
XBowsQuiver.quiver_empty_state[player:get_player_name()] = true
|
XBowsQuiver.quiver_empty_state[player:get_player_name()] = true
|
||||||
XBowsQuiver:show_3d_quiver(player)
|
XBowsQuiver:show_3d_quiver(player)
|
||||||
|
@ -311,7 +311,9 @@ minetest.register_globalstep(function(dtime)
|
||||||
XBows.player_bow_sneak[player_name] = {}
|
XBows.player_bow_sneak[player_name] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_item_group(wielded_stack_name, 'bow_charged') ~= 0 and not XBows.player_bow_sneak[player_name].sneak then
|
if minetest.get_item_group(wielded_stack_name, 'bow_charged') ~= 0
|
||||||
|
and not XBows.player_bow_sneak[player_name].sneak
|
||||||
|
then
|
||||||
--charged weapon
|
--charged weapon
|
||||||
if XBows.playerphysics then
|
if XBows.playerphysics then
|
||||||
playerphysics.add_physics_factor(player, 'speed', 'x_bows:bow_charged_speed', 0.25)
|
playerphysics.add_physics_factor(player, 'speed', 'x_bows:bow_charged_speed', 0.25)
|
||||||
|
@ -321,7 +323,9 @@ minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
XBows.player_bow_sneak[player_name].sneak = true
|
XBows.player_bow_sneak[player_name].sneak = true
|
||||||
player:set_fov(0.9, true, 0.4)
|
player:set_fov(0.9, true, 0.4)
|
||||||
elseif minetest.get_item_group(wielded_stack_name, 'bow_charged') == 0 and XBows.player_bow_sneak[player_name].sneak then
|
elseif minetest.get_item_group(wielded_stack_name, 'bow_charged') == 0
|
||||||
|
and XBows.player_bow_sneak[player_name].sneak
|
||||||
|
then
|
||||||
if XBows.playerphysics then
|
if XBows.playerphysics then
|
||||||
playerphysics.remove_physics_factor(player, 'speed', 'x_bows:bow_charged_speed')
|
playerphysics.remove_physics_factor(player, 'speed', 'x_bows:bow_charged_speed')
|
||||||
elseif XBows.player_monoids then
|
elseif XBows.player_monoids then
|
||||||
|
@ -341,4 +345,4 @@ end)
|
||||||
|
|
||||||
local mod_end_time = (minetest.get_us_time() - mod_start_time) / 1000000
|
local mod_end_time = (minetest.get_us_time() - mod_start_time) / 1000000
|
||||||
|
|
||||||
print('[Mod] x_bows loaded.. ['.. mod_end_time ..'s]')
|
print('[Mod] x_bows loaded.. [' .. mod_end_time .. 's]')
|
||||||
|
|
64
items.lua
64
items.lua
|
@ -7,9 +7,9 @@ XBows:register_bow('bow_wood', {
|
||||||
uses = 385,
|
uses = 385,
|
||||||
crit_chance = 10,
|
crit_chance = 10,
|
||||||
recipe = {
|
recipe = {
|
||||||
{'', 'default:stick', 'farming:string'},
|
{ '', 'default:stick', 'farming:string' },
|
||||||
{'default:stick', '', 'farming:string'},
|
{ 'default:stick', '', 'farming:string' },
|
||||||
{'', 'default:stick', 'farming:string'}
|
{ '', 'default:stick', 'farming:string' }
|
||||||
},
|
},
|
||||||
fuel_burntime = 3,
|
fuel_burntime = 3,
|
||||||
allowed_ammunition = {
|
allowed_ammunition = {
|
||||||
|
@ -29,14 +29,14 @@ XBows:register_arrow('arrow_wood', {
|
||||||
inventory_image = 'x_bows_arrow_wood.png',
|
inventory_image = 'x_bows_arrow_wood.png',
|
||||||
custom = {
|
custom = {
|
||||||
recipe = {
|
recipe = {
|
||||||
{'default:flint'},
|
{ 'default:flint' },
|
||||||
{'group:stick'},
|
{ 'group:stick' },
|
||||||
{'group:wool'}
|
{ 'group:wool' }
|
||||||
},
|
},
|
||||||
tool_capabilities = {
|
tool_capabilities = {
|
||||||
full_punch_interval = 1,
|
full_punch_interval = 1,
|
||||||
max_drop_level = 0,
|
max_drop_level = 0,
|
||||||
damage_groups = {fleshy=2}
|
damage_groups = { fleshy = 2 }
|
||||||
},
|
},
|
||||||
fuel_burntime = 1
|
fuel_burntime = 1
|
||||||
}
|
}
|
||||||
|
@ -48,14 +48,14 @@ XBows:register_arrow('arrow_stone', {
|
||||||
inventory_image = 'x_bows_arrow_stone.png',
|
inventory_image = 'x_bows_arrow_stone.png',
|
||||||
custom = {
|
custom = {
|
||||||
recipe = {
|
recipe = {
|
||||||
{'default:flint'},
|
{ 'default:flint' },
|
||||||
{'group:stone'},
|
{ 'group:stone' },
|
||||||
{'group:wool'}
|
{ 'group:wool' }
|
||||||
},
|
},
|
||||||
tool_capabilities = {
|
tool_capabilities = {
|
||||||
full_punch_interval = 1.2,
|
full_punch_interval = 1.2,
|
||||||
max_drop_level = 0,
|
max_drop_level = 0,
|
||||||
damage_groups = {fleshy=4}
|
damage_groups = { fleshy = 4 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -66,14 +66,14 @@ XBows:register_arrow('arrow_bronze', {
|
||||||
inventory_image = 'x_bows_arrow_bronze.png',
|
inventory_image = 'x_bows_arrow_bronze.png',
|
||||||
custom = {
|
custom = {
|
||||||
recipe = {
|
recipe = {
|
||||||
{'default:flint'},
|
{ 'default:flint' },
|
||||||
{'default:bronze_ingot'},
|
{ 'default:bronze_ingot' },
|
||||||
{'group:wool'}
|
{ 'group:wool' }
|
||||||
},
|
},
|
||||||
tool_capabilities = {
|
tool_capabilities = {
|
||||||
full_punch_interval = 0.8,
|
full_punch_interval = 0.8,
|
||||||
max_drop_level = 1,
|
max_drop_level = 1,
|
||||||
damage_groups = {fleshy=6}
|
damage_groups = { fleshy = 6 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -84,14 +84,14 @@ XBows:register_arrow('arrow_steel', {
|
||||||
inventory_image = 'x_bows_arrow_steel.png',
|
inventory_image = 'x_bows_arrow_steel.png',
|
||||||
custom = {
|
custom = {
|
||||||
recipe = {
|
recipe = {
|
||||||
{'default:flint'},
|
{ 'default:flint' },
|
||||||
{'default:steel_ingot'},
|
{ 'default:steel_ingot' },
|
||||||
{'group:wool'}
|
{ 'group:wool' }
|
||||||
},
|
},
|
||||||
tool_capabilities = {
|
tool_capabilities = {
|
||||||
full_punch_interval = 0.7,
|
full_punch_interval = 0.7,
|
||||||
max_drop_level = 1,
|
max_drop_level = 1,
|
||||||
damage_groups = {fleshy=6}
|
damage_groups = { fleshy = 6 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -102,14 +102,14 @@ XBows:register_arrow('arrow_mese', {
|
||||||
inventory_image = 'x_bows_arrow_mese.png',
|
inventory_image = 'x_bows_arrow_mese.png',
|
||||||
custom = {
|
custom = {
|
||||||
recipe = {
|
recipe = {
|
||||||
{'default:flint'},
|
{ 'default:flint' },
|
||||||
{'default:mese_crystal'},
|
{ 'default:mese_crystal' },
|
||||||
{'group:wool'}
|
{ 'group:wool' }
|
||||||
},
|
},
|
||||||
tool_capabilities = {
|
tool_capabilities = {
|
||||||
full_punch_interval = 0.7,
|
full_punch_interval = 0.7,
|
||||||
max_drop_level = 1,
|
max_drop_level = 1,
|
||||||
damage_groups = {fleshy=7}
|
damage_groups = { fleshy = 7 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -120,28 +120,28 @@ XBows:register_arrow('arrow_diamond', {
|
||||||
inventory_image = 'x_bows_arrow_diamond.png',
|
inventory_image = 'x_bows_arrow_diamond.png',
|
||||||
custom = {
|
custom = {
|
||||||
recipe = {
|
recipe = {
|
||||||
{'default:flint'},
|
{ 'default:flint' },
|
||||||
{'default:diamond'},
|
{ 'default:diamond' },
|
||||||
{'group:wool'}
|
{ 'group:wool' }
|
||||||
},
|
},
|
||||||
tool_capabilities = {
|
tool_capabilities = {
|
||||||
full_punch_interval = 0.7,
|
full_punch_interval = 0.7,
|
||||||
max_drop_level = 1,
|
max_drop_level = 1,
|
||||||
damage_groups = {fleshy=8}
|
damage_groups = { fleshy = 8 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
XBows:register_quiver('quiver', {
|
XBows:register_quiver('quiver', {
|
||||||
description = S('Quiver') .. '\n\n' .. S('Empty') ..'\n',
|
description = S('Quiver') .. '\n\n' .. S('Empty') .. '\n',
|
||||||
short_description = S('Quiver'),
|
short_description = S('Quiver'),
|
||||||
custom = {
|
custom = {
|
||||||
description = S('Quiver') .. '\n\n' .. S('Empty') ..'\n',
|
description = S('Quiver') .. '\n\n' .. S('Empty') .. '\n',
|
||||||
short_description = S('Quiver'),
|
short_description = S('Quiver'),
|
||||||
recipe = {
|
recipe = {
|
||||||
{'group:arrow', 'group:arrow', 'group:arrow'},
|
{ 'group:arrow', 'group:arrow', 'group:arrow' },
|
||||||
{'group:arrow', 'wool:brown', 'group:arrow'},
|
{ 'group:arrow', 'wool:brown', 'group:arrow' },
|
||||||
{'group:arrow', 'group:arrow', 'group:arrow'}
|
{ 'group:arrow', 'group:arrow', 'group:arrow' }
|
||||||
},
|
},
|
||||||
recipe_count = 1,
|
recipe_count = 1,
|
||||||
faster_arrows = 5,
|
faster_arrows = 5,
|
||||||
|
|
14
nodes.lua
14
nodes.lua
|
@ -3,15 +3,15 @@ local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
minetest.register_node('x_bows:target', {
|
minetest.register_node('x_bows:target', {
|
||||||
description = S('Target'),
|
description = S('Target'),
|
||||||
short_description = S('Target'),
|
short_description = S('Target'),
|
||||||
tiles = {'x_bows_target.png'},
|
tiles = { 'x_bows_target.png' },
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {snappy=3, flammable=4, fall_damage_add_percent = -30},
|
groups = { snappy = 3, flammable = 4, fall_damage_add_percent = -30 },
|
||||||
sounds = minetest.global_exists('default') and default.node_sound_leaves_defaults() or {},
|
sounds = minetest.global_exists('default') and default.node_sound_leaves_defaults() or {},
|
||||||
mesecons = {receptor = {state = 'off'}},
|
mesecons = { receptor = { state = 'off' } },
|
||||||
---@param pos Vector
|
---@param pos Vector
|
||||||
---@param elapsed number
|
---@param elapsed number
|
||||||
---@return boolean
|
---@return boolean
|
||||||
on_timer = function (pos, elapsed)
|
on_timer = function(pos, elapsed)
|
||||||
if XBows.mesecons then
|
if XBows.mesecons then
|
||||||
mesecon.receptor_off(pos)
|
mesecon.receptor_off(pos)
|
||||||
end
|
end
|
||||||
|
@ -29,8 +29,8 @@ minetest.register_craft({
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'x_bows:target',
|
output = 'x_bows:target',
|
||||||
recipe = {
|
recipe = {
|
||||||
{'', 'default:mese_crystal', ''},
|
{ '', 'default:mese_crystal', '' },
|
||||||
{'default:mese_crystal', 'farming:straw', 'default:mese_crystal'},
|
{ 'default:mese_crystal', 'farming:straw', 'default:mese_crystal' },
|
||||||
{'', 'default:mese_crystal', ''},
|
{ '', 'default:mese_crystal', '' },
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,7 +13,8 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"push:ci": "node ./scripts/deploy"
|
"push:ci": "node ./scripts/deploy",
|
||||||
|
"lua-diagnostics": "node ./scripts/lls-check"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://bitbucket.org/minetest_gamers/x_bows#readme",
|
"homepage": "https://bitbucket.org/minetest_gamers/x_bows#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"jaguar": "^6.0.1",
|
||||||
"node-fetch": "^3.2.10",
|
"node-fetch": "^3.2.10",
|
||||||
"yargs": "^17.6.1"
|
"yargs": "^17.6.1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,10 @@ XBows:register_particle_effect('arrow', {
|
||||||
length = 1,
|
length = 1,
|
||||||
},
|
},
|
||||||
glow = 1,
|
glow = 1,
|
||||||
minvel = {x = 0, y = -0.1, z = 0},
|
minvel = { x = 0, y = -0.1, z = 0 },
|
||||||
maxvel = {x = 0, y = -0.1, z = 0},
|
maxvel = { x = 0, y = -0.1, z = 0 },
|
||||||
minacc = {x = 0, y = -0.1, z = 0},
|
minacc = { x = 0, y = -0.1, z = 0 },
|
||||||
maxacc = {x = 0, y = -0.1, z = 0}
|
maxacc = { x = 0, y = -0.1, z = 0 }
|
||||||
})
|
})
|
||||||
|
|
||||||
XBows:register_particle_effect('arrow_crit', {
|
XBows:register_particle_effect('arrow_crit', {
|
||||||
|
@ -34,10 +34,10 @@ XBows:register_particle_effect('arrow_crit', {
|
||||||
length = 1,
|
length = 1,
|
||||||
},
|
},
|
||||||
glow = 1,
|
glow = 1,
|
||||||
minvel = {x = 0, y = -0.1, z = 0},
|
minvel = { x = 0, y = -0.1, z = 0 },
|
||||||
maxvel = {x = 0, y = -0.1, z = 0},
|
maxvel = { x = 0, y = -0.1, z = 0 },
|
||||||
minacc = {x = 0, y = -0.1, z = 0},
|
minacc = { x = 0, y = -0.1, z = 0 },
|
||||||
maxacc = {x = 0, y = -0.1, z = 0}
|
maxacc = { x = 0, y = -0.1, z = 0 }
|
||||||
})
|
})
|
||||||
|
|
||||||
XBows:register_particle_effect('arrow_fast', {
|
XBows:register_particle_effect('arrow_fast', {
|
||||||
|
@ -55,19 +55,19 @@ XBows:register_particle_effect('arrow_fast', {
|
||||||
length = 1,
|
length = 1,
|
||||||
},
|
},
|
||||||
glow = 1,
|
glow = 1,
|
||||||
minvel = {x = 0, y = -0.1, z = 0},
|
minvel = { x = 0, y = -0.1, z = 0 },
|
||||||
maxvel = {x = 0, y = -0.1, z = 0},
|
maxvel = { x = 0, y = -0.1, z = 0 },
|
||||||
minacc = {x = 0, y = -0.1, z = 0},
|
minacc = { x = 0, y = -0.1, z = 0 },
|
||||||
maxacc = {x = 0, y = -0.1, z = 0}
|
maxacc = { x = 0, y = -0.1, z = 0 }
|
||||||
})
|
})
|
||||||
|
|
||||||
XBows:register_particle_effect('bubble', {
|
XBows:register_particle_effect('bubble', {
|
||||||
amount = 1,
|
amount = 1,
|
||||||
time = 1,
|
time = 1,
|
||||||
minvel = {x=1, y=1, z=0},
|
minvel = { x = 1, y = 1, z = 0 },
|
||||||
maxvel = {x=1, y=1, z=0},
|
maxvel = { x = 1, y = 1, z = 0 },
|
||||||
minacc = {x=1, y=1, z=1},
|
minacc = { x = 1, y = 1, z = 1 },
|
||||||
maxacc = {x=1, y=1, z=1},
|
maxacc = { x = 1, y = 1, z = 1 },
|
||||||
minexptime = 0.2,
|
minexptime = 0.2,
|
||||||
maxexptime = 0.5,
|
maxexptime = 0.5,
|
||||||
minsize = 0.5,
|
minsize = 0.5,
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
import * as path from 'node:path'
|
||||||
|
import * as fs from 'node:fs'
|
||||||
|
import {exec} from 'node:child_process'
|
||||||
|
import yargs from 'yargs/yargs'
|
||||||
|
import {hideBin} from 'yargs/helpers'
|
||||||
|
import jaguar from 'jaguar'
|
||||||
|
|
||||||
|
const argv = yargs(hideBin(process.argv)).argv
|
||||||
|
const cwd = process.cwd()
|
||||||
|
const logPath = path.join(cwd, 'logs')
|
||||||
|
|
||||||
|
// Extract lua language server
|
||||||
|
const from = path.join(cwd, 'bin/lua-language-server-3.5.6-linux-x64.tar.gz');
|
||||||
|
const to = path.join(cwd, 'bin', 'lua-language-server-3.5.6-linux-x64');
|
||||||
|
const extract = jaguar.extract(from, to)
|
||||||
|
|
||||||
|
// extract.on('file', (name) => {
|
||||||
|
// console.log(name)
|
||||||
|
// })
|
||||||
|
|
||||||
|
extract.on('start', () => {
|
||||||
|
console.log('Extracting...')
|
||||||
|
})
|
||||||
|
|
||||||
|
// extract.on('progress', (percent) => {
|
||||||
|
// console.log(percent + '%')
|
||||||
|
// })
|
||||||
|
|
||||||
|
extract.on('error', (error) => {
|
||||||
|
console.error(error)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
extract.on('end', () => {
|
||||||
|
console.log('Extracting: Done')
|
||||||
|
|
||||||
|
// Delete directory recursively
|
||||||
|
try {
|
||||||
|
fs.rmSync(logPath, { recursive: true, force: true })
|
||||||
|
console.log(`Removed folder: ${logPath}`)
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Error while deleting ${logPath}.`)
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
let command = './bin/lua-language-server-3.5.6-linux-x64/bin/lua-language-server'
|
||||||
|
|
||||||
|
if (argv.local) {
|
||||||
|
command = 'lua-language-server'
|
||||||
|
}
|
||||||
|
|
||||||
|
exec(`${command} --logpath "${logPath}" --check "${cwd}"`, (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
console.log(`error: ${error.message}`)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stderr) {
|
||||||
|
console.log(`stderr: ${stderr}`)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\n${stdout}`)
|
||||||
|
|
||||||
|
if (fs.existsSync('./logs/check.json')) {
|
||||||
|
const rawdata = fs.readFileSync('./logs/check.json')
|
||||||
|
const diagnosticsJson = JSON.parse(rawdata)
|
||||||
|
|
||||||
|
Object.keys(diagnosticsJson).forEach((key) => {
|
||||||
|
console.log(key)
|
||||||
|
|
||||||
|
diagnosticsJson[key].forEach((errObj) => {
|
||||||
|
console.log(`line: ${errObj.range.start.line} - ${errObj.message}`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
console.error('Fix the errors/warnings above.')
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete directory recursively
|
||||||
|
const llsFolder = path.join(cwd, 'bin', 'lua-language-server-3.5.6-linux-x64')
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.rmSync(llsFolder, { recursive: true, force: true })
|
||||||
|
console.log(`Removed folder: ${llsFolder}`)
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Error while deleting ${llsFolder}.`)
|
||||||
|
console.error(err)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---@alias ColorSpec string|ColorSpecTable A ColorSpec specifies a 32-bit color. It can be written in any of the following forms: `colorspec = {a=255, r=0, g=255, b=0}`, numerical form: The raw integer value of an ARGB8 quad: `colorspec = 0xFF00FF00`, string form: A ColorString (defined above): `colorspec = "green"`
|
---@alias ColorSpec string|ColorSpecTable A ColorSpec specifies a 32-bit color. It can be written in any of the following forms: `colorspec = {a=255, r=0, g=255, b=0}`, numerical form: The raw integer value of an ARGB8 quad: `colorspec = 0xFF00FF00`, string form: A ColorString (defined above): `colorspec = "green"`
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---Crafting recipes
|
---Crafting recipes
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---The varying types of decorations that can be placed.
|
---The varying types of decorations that can be placed.
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---Entity definition
|
---Entity definition
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---@alias Dump fun(obj: any, dumped?: any): string returns a string which makes `obj` human-readable, `obj`: arbitrary variable, `dumped`: table, default: `{}`
|
---@alias Dump fun(obj: any, dumped?: any): string returns a string which makes `obj` human-readable, `obj`: arbitrary variable, `dumped`: table, default: `{}`
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
--An `InvRef` is a reference to an inventory.
|
--An `InvRef` is a reference to an inventory.
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---Minetest item definition. Used by `minetest.register_node`, `minetest.register_craftitem`, and `minetest.register_tool`.
|
---Minetest item definition. Used by `minetest.register_node`, `minetest.register_craftitem`, and `minetest.register_tool`.
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---A native C++ format with many helper methods. Useful for converting between formats.
|
---A native C++ format with many helper methods. Useful for converting between formats.
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
--- In a game, a certain number of these must be set to tell core mapgens which of the game's nodes are to be used for core mapgen generation.
|
--- In a game, a certain number of these must be set to tell core mapgens which of the game's nodes are to be used for core mapgen generation.
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check, duplicate-doc-alias
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---@alias mathlib mathlib|MathAbstract
|
---@alias mathlib mathlib|MathAbstract
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---@alias ItemStackMetaRef MetaDataRef|ItemStackMetaRefAbstract
|
---@alias ItemStackMetaRef MetaDataRef|ItemStackMetaRefAbstract
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---Minetest globals
|
---Minetest globals
|
||||||
|
@ -68,7 +69,7 @@
|
||||||
---@field register_on_player_receive_fields fun(func: fun(player: ObjectRef, formname: string, fields: table)): nil Called when the server received input from `player` in a formspec with the given `formname`. Specifically, this is called on any of the following events: a button was pressed, Enter was pressed while the focus was on a text field, a checkbox was toggled, something was selected in a dropdown list, a different tab was selected, selection was changed in a textlist or table, an entry was double-clicked in a textlist or table, a scrollbar was moved, or the form was actively closed by the player.
|
---@field register_on_player_receive_fields fun(func: fun(player: ObjectRef, formname: string, fields: table)): nil Called when the server received input from `player` in a formspec with the given `formname`. Specifically, this is called on any of the following events: a button was pressed, Enter was pressed while the focus was on a text field, a checkbox was toggled, something was selected in a dropdown list, a different tab was selected, selection was changed in a textlist or table, an entry was double-clicked in a textlist or table, a scrollbar was moved, or the form was actively closed by the player.
|
||||||
---@field get_inventory fun(location: {['"type"']: 'player'|'node'|'detached', ['"name"']: string|nil, ['"pos"']: Vector|nil}): InvRef
|
---@field get_inventory fun(location: {['"type"']: 'player'|'node'|'detached', ['"name"']: string|nil, ['"pos"']: Vector|nil}): InvRef
|
||||||
---@field dir_to_wallmounted fun(dir: Vector): number Convert a vector to a wallmounted value, used for `paramtype2="wallmounted"`
|
---@field dir_to_wallmounted fun(dir: Vector): number Convert a vector to a wallmounted value, used for `paramtype2="wallmounted"`
|
||||||
---@field item_place_node fun(itemstack: ItemStack, placer: ObjectRef, pointed_thing: PointedThingDef, param2?: , prevent_after_place?: boolean): Vector|nil Place item as a node, `param2` overrides `facedir` and wallmounted `param2`, `prevent_after_place`: if set to `true`, `after_place_node` is not called or the newly placed node to prevent a callback and placement loop. returns `itemstack, position`, `position`: the location the node was placed to. `nil` if nothing was placed.
|
---@field item_place_node fun(itemstack: ItemStack, placer: ObjectRef, pointed_thing: PointedThingDef, param2?: string , prevent_after_place?: boolean): Vector|nil Place item as a node, `param2` overrides `facedir` and wallmounted `param2`, `prevent_after_place`: if set to `true`, `after_place_node` is not called or the newly placed node to prevent a callback and placement loop. returns `itemstack, position`, `position`: the location the node was placed to. `nil` if nothing was placed.
|
||||||
---@field unregister_item fun(name: string): nil Unregisters the item from the engine, and deletes the entry with key `name` from `minetest.registered_items` and from the associated item table according to its nature: `minetest.registered_nodes`, etc.
|
---@field unregister_item fun(name: string): nil Unregisters the item from the engine, and deletes the entry with key `name` from `minetest.registered_items` and from the associated item table according to its nature: `minetest.registered_nodes`, etc.
|
||||||
---@field register_allow_player_inventory_action fun(func: fun(player: ObjectRef, action: string, inventory: InvRef, inventory_info: {["from_list"]: string, ["to_list"]: string, ["from_index"]: number, ["to_index"]: number, ["count"]: number} | {["listname"]: string, ["index"]: number, ["stack"]: ItemStack}): number): nil Determines how much of a stack may be taken, put or moved to a player inventory. `player` (type `ObjectRef`) is the player who modified the inventory, `inventory` (type `InvRef`). List of possible `action` (string) values and their `inventory_info` (table) contents: `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`, `put`: `{listname=string, index=number, stack=ItemStack}`, `take`: Same as `put`. Return a numeric value to limit the amount of items to be taken, put or moved. A value of `-1` for `take` will make the source stack infinite.
|
---@field register_allow_player_inventory_action fun(func: fun(player: ObjectRef, action: string, inventory: InvRef, inventory_info: {["from_list"]: string, ["to_list"]: string, ["from_index"]: number, ["to_index"]: number, ["count"]: number} | {["listname"]: string, ["index"]: number, ["stack"]: ItemStack}): number): nil Determines how much of a stack may be taken, put or moved to a player inventory. `player` (type `ObjectRef`) is the player who modified the inventory, `inventory` (type `InvRef`). List of possible `action` (string) values and their `inventory_info` (table) contents: `move`: `{from_list=string, to_list=string, from_index=number, to_index=number, count=number}`, `put`: `{listname=string, index=number, stack=ItemStack}`, `take`: Same as `put`. Return a numeric value to limit the amount of items to be taken, put or moved. A value of `-1` for `take` will make the source stack infinite.
|
||||||
---@field register_on_player_inventory_action fun(func: fun(player: ObjectRef, action: string, inventory: InvRef, inventory_info: {["from_list"]: string, ["to_list"]: string, ["from_index"]: number, ["to_index"]: number, ["count"]: number} | {["listname"]: string, ["index"]: number, ["stack"]: ItemStack}): nil): nil Called after a take, put or move event from/to/in a player inventory. Function arguments: see `minetest.register_allow_player_inventory_action`. Does not accept or handle any return value.
|
---@field register_on_player_inventory_action fun(func: fun(player: ObjectRef, action: string, inventory: InvRef, inventory_info: {["from_list"]: string, ["to_list"]: string, ["from_index"]: number, ["to_index"]: number, ["count"]: number} | {["listname"]: string, ["index"]: number, ["stack"]: ItemStack}): nil): nil Called after a take, put or move event from/to/in a player inventory. Function arguments: see `minetest.register_allow_player_inventory_action`. Does not accept or handle any return value.
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---Minetest game creative mod
|
---Minetest game creative mod
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---Minetest game default mod
|
---Minetest game default mod
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---Minetest game dungeon loot mod API
|
---Minetest game dungeon loot mod API
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---Minetest game farming mod
|
---Minetest game farming mod
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---The player API can register player models and update the player's appearance.
|
---The player API can register player models and update the player's appearance.
|
||||||
---@class MtgPlayerApi
|
---@class MtgPlayerApi
|
||||||
---@field globalstep fun(dtime: number, ...): nil The function called by the globalstep that controls player animations. You can override this to replace the globalstep with your own implementation. Receives all args that minetest.register_globalstep() passes
|
---@field globalstep fun(dtime: number, ...): nil The function called by the globalstep that controls player animations. You can override this to replace the globalstep with your own implementation. Receives all args that minetest.register_globalstep() passes
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---Minetest game screwdriver mod
|
---Minetest game screwdriver mod
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---Sfinv API
|
---Sfinv API
|
||||||
---@class Sfinv
|
---@class Sfinv
|
||||||
---@field register_page fun(name: string, def: SfinvDef): nil Register a page
|
---@field register_page fun(name: string, def: SfinvDef): nil Register a page
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---Minetest game stairs mod
|
---Minetest game stairs mod
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---@alias NodeDef NodeDefAbstract | NodeDefMtgFarming
|
---@alias NodeDef NodeDefAbstract | NodeDefMtgFarming
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---Node Timers: a high resolution persistent per-node timer. Can be gotten via `minetest.get_node_timer(pos)`.
|
---Node Timers: a high resolution persistent per-node timer. Can be gotten via `minetest.get_node_timer(pos)`.
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---@alias ObjectRef ObjectRefAbstract | ObjectRefLuaEntityRef
|
---@alias ObjectRef ObjectRefAbstract | ObjectRefLuaEntityRef
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
--- ParticleSpawner definition
|
--- ParticleSpawner definition
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---Pointed thing definition
|
---Pointed thing definition
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---A raycast on the map. It works with selection boxes. The map is loaded as the ray advances. If the map is modified after the `Raycast` is created, the changes may or may not have an effect on the object.
|
---A raycast on the map. It works with selection boxes. The map is loaded as the ray advances. If the map is modified after the `Raycast` is created, the changes may or may not have an effect on the object.
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---Specifies a sound name, gain (=volume) and pitch. This is either a string or a table. In string form, you just specify the sound name or the empty string for no sound.
|
---Specifies a sound name, gain (=volume) and pitch. This is either a string or a table. In string form, you just specify the sound name or the empty string for no sound.
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check, duplicate-doc-alias
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---@alias string string|StringAbstract
|
---@alias string string|StringAbstract
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check, duplicate-doc-alias
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
---@alias tablelib tablelib|TableAbstract
|
---@alias tablelib tablelib|TableAbstract
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---Base class Unified Inventory
|
---Base class Unified Inventory
|
||||||
---@class UnifiedInventory
|
---@class UnifiedInventory
|
||||||
---@field set_inventory_formspec fun(player: ObjectRef, formspecname: string): nil
|
---@field set_inventory_formspec fun(player: ObjectRef, formspecname: string): nil
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---https://github.com/sumneko/lua-language-server/wiki
|
---https://github.com/sumneko/lua-language-server/wiki
|
||||||
|
|
||||||
------All `vector.*` functions allow vectors `{x = X, y = Y, z = Z}` without metatables. Returned vectors always have a metatable set.
|
------All `vector.*` functions allow vectors `{x = X, y = Y, z = Z}` without metatables. Returned vectors always have a metatable set.
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@diagnostic disable: codestyle-check
|
||||||
---Base class XBows
|
---Base class XBows
|
||||||
---@class XBows
|
---@class XBows
|
||||||
---@field pvp boolean
|
---@field pvp boolean
|
||||||
|
@ -16,7 +17,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 {["x_bows_attach_arrows_to_entities"]: boolean, ["x_bows_show_damage_numbers"]: boolean, ["x_bows_show_3d_quiver"]: boolean}
|
---@field settings {["x_bows_attach_arrows_to_entities"]: boolean | nil, ["x_bows_show_damage_numbers"]: boolean | nil, ["x_bows_show_3d_quiver"]: boolean | nil}
|
||||||
---@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
|
||||||
|
|
Ŝarĝante…
Reference in New Issue