1
0
mirror of https://bitbucket.org/minetest_gamers/x_enchanting.git synced 2025-06-29 22:30:35 +02:00

Compare commits

...

6 Commits

Author SHA1 Message Date
172eed1768 Disable Lua Diagnostics in pipeline 2023-02-23 21:57:21 -05:00
745708505f Prevent double enchantments and adding incompatible enchantments 2023-02-23 21:56:47 -05:00
8090e23daf Update License Year 2023-02-23 21:19:03 -05:00
46633e5b44 Update License Year 2023-02-23 21:18:58 -05:00
48d215b08e add gitattributes 2022-12-05 15:14:51 -05:00
f8f40d61a2 update licensing 2022-11-28 16:26:42 -05:00
9 changed files with 64 additions and 32 deletions

15
.gitattributes vendored Normal file
View File

@ -0,0 +1,15 @@
# Creating an archive
.* export-ignore
assets export-ignore
scripts export-ignore
bin export-ignore
docs export-ignore
types export-ignore
*.zip export-ignore
bitbucket-pipelines.yml export-ignore
package.json export-ignore
package-lock.json export-ignore
screenshot*.png export-ignore
i18n.py export-ignore
config.ld export-ignore

View File

@ -1,7 +1,7 @@
GNU LESSER GENERAL PUBLIC LICENSE GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999 Version 2.1, February 1999
Copyright (C) 2022 SaKeL <juraj.vajda@gmail.com> Copyright (C) 2023 SaKeL <juraj.vajda@gmail.com>
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.

View File

@ -187,7 +187,7 @@ GNU Lesser General Public License v2.1 or later (see included LICENSE file)
### Textures ### Textures
**CC BY-SA 4.0, Pixel Perfection by XSSheep**, https://minecraft.curseforge.com/projects/pixel-perfection-freshly-updated **CC-BY-SA-4.0, Pixel Perfection by XSSheep**, https://minecraft.curseforge.com/projects/pixel-perfection-freshly-updated
- x_enchanting_symbol_1.png - x_enchanting_symbol_1.png
- x_enchanting_symbol_2.png - x_enchanting_symbol_2.png
@ -227,11 +227,11 @@ GNU Lesser General Public License v2.1 or later (see included LICENSE file)
- x_enchanting_scroll_mesh.png -- Derived from a texture TumeniNodes (CC BY-SA 3.0) - x_enchanting_scroll_mesh.png -- Derived from a texture TumeniNodes (CC BY-SA 3.0)
- x_enchanting_scroll_particle.png - x_enchanting_scroll_particle.png
- x_enchanting_table.png - x_enchanting_table.png
- x_enchanting_gui_slot_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC BY-SA 4.0) - x_enchanting_gui_slot_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC-BY-SA-4.0)
- x_enchanting_gui_cloth_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC BY-SA 4.0) - x_enchanting_gui_cloth_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC-BY-SA-4.0)
- x_enchanting_gui_cloth_trade_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC BY-SA 4.0) - x_enchanting_gui_cloth_trade_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC-BY-SA-4.0)
- x_enchanting_gui_formbg.png -- Derived from texture Pixel Perfection by XSSheep (CC BY-SA 4.0) - x_enchanting_gui_formbg.png -- Derived from texture Pixel Perfection by XSSheep (CC-BY-SA-4.0)
- x_enchanting_gui_hb_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC BY-SA 4.0) - x_enchanting_gui_hb_bg.png -- Derived from texture Pixel Perfection by XSSheep (CC-BY-SA-4.0)
### Models ### Models

23
api.lua
View File

@ -1,6 +1,6 @@
--[[ --[[
X Enchanting. Adds Enchanting Mechanics and API. X Enchanting. Adds Enchanting Mechanics and API.
Copyright (C) 2022 SaKeL <juraj.vajda@gmail.com> Copyright (C) 2023 SaKeL <juraj.vajda@gmail.com>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
@ -306,6 +306,17 @@ local function get_table_length(table)
return length return length
end end
---Find element v of t satisfying f(v)
local function tableFind(t, f)
for _, v in ipairs(t) do
if f(v) then
return v
end
end
return nil
end
---@diagnostic disable-next-line: unused-local ---@diagnostic disable-next-line: unused-local
function XEnchanting.has_tool_group(self, name) function XEnchanting.has_tool_group(self, name)
if minetest.get_item_group(name, 'pickaxe') > 0 then if minetest.get_item_group(name, 'pickaxe') > 0 then
@ -767,11 +778,17 @@ function XEnchanting.get_enchantment_data(self, player, nr_of_bookshelfs, tool_d
table.remove(possible_enchantments, idx) table.remove(possible_enchantments, idx)
end end
end end
else else
local probability = (probability_level + 1) / 50 local probability = (probability_level + 1) / 50
table.insert(final_enchantments, rand_ench) local alreadyInTable = tableFind(final_enchantments, function(value)
return value.id == rand_ench.id
end)
if not alreadyInTable then
table.insert(final_enchantments, rand_ench)
end
table.remove(possible_enchantments, rand_ench_idx) table.remove(possible_enchantments, rand_ench_idx)
for idx, value in pairs(possible_enchantments) do for idx, value in pairs(possible_enchantments) do

View File

@ -43,24 +43,24 @@ 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: # - parallel:
- step: - step:
name: Lua Check name: Lua Check
script: script:
- apt-get update - apt-get update
- apt-get -y install lua5.1 - apt-get -y install lua5.1
- apt-get -y install luarocks - apt-get -y install luarocks
- luarocks install luacheck - luarocks install luacheck
- luacheck . - luacheck .
- step: # - step:
name: Lua Diagnostics # name: Lua Diagnostics
caches: # caches:
- node-modules # - node-modules
- npm # - npm
- nvm # - nvm
script: # script:
- nvm use v17.2.0 # - nvm use v17.2.0
- npm run lua-diagnostics # - npm run lua-diagnostics
- step: - step:
name: Deploy to ContentDB name: Deploy to ContentDB
caches: caches:

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/** /**
* Run LUA diagnostics in continuous integration * Run LUA diagnostics in continuous integration
* Copyright (C) 2022 SaKeL <juraj.vajda@gmail.com> * Copyright (C) 2023 SaKeL <juraj.vajda@gmail.com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View File

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