forked from mtcontrib/x_enchanting
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
4303c5f8bf | |||
1e5a76ed18 | |||
96b8369500 |
64
api.lua
64
api.lua
@ -473,7 +473,7 @@ function XEnchanting.get_enchanted_descriptions(self, enchantments)
|
|||||||
|
|
||||||
enchantments_desc = '\n' .. minetest.colorize('#AE81FF', S('Enchanted'))
|
enchantments_desc = '\n' .. minetest.colorize('#AE81FF', S('Enchanted'))
|
||||||
.. '\n' .. table.concat(enchantments_desc, '\n')
|
.. '\n' .. table.concat(enchantments_desc, '\n')
|
||||||
enchantments_desc_masked = table.concat(enchantments_desc_masked, '') .. '...?'
|
enchantments_desc_masked = table.concat(enchantments_desc_masked, '') .. '..?'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
enchantments_desc = enchantments_desc,
|
enchantments_desc = enchantments_desc,
|
||||||
@ -534,6 +534,58 @@ function XEnchanting.set_enchanted_tool(self, pos, itemstack, level, player_name
|
|||||||
pos = pos,
|
pos = pos,
|
||||||
max_hear_distance = 10
|
max_hear_distance = 10
|
||||||
}, true)
|
}, true)
|
||||||
|
|
||||||
|
-- particles
|
||||||
|
local particlespawner_def = {
|
||||||
|
amount = 50,
|
||||||
|
time = 0.5,
|
||||||
|
minpos = { x = pos.x - 1, y = pos.y + 1, z = pos.z - 1 },
|
||||||
|
maxpos = { x = pos.x + 1, y = pos.y + 1.5, z = pos.z + 1 },
|
||||||
|
minvel = { x = -0.1, y = -0.5, z = -0.1 },
|
||||||
|
maxvel = { x = 0.1, y = -1.5, z = 0.1 },
|
||||||
|
minacc = { x = -0.1, y = -0.5, z = -0.1 },
|
||||||
|
maxacc = { x = 0.1, y = -1.5, z = 0.1 },
|
||||||
|
minexptime = 0.5,
|
||||||
|
maxexptime = 1,
|
||||||
|
minsize = 0.5,
|
||||||
|
maxsize = 1,
|
||||||
|
texture = 'x_enchanting_scroll_particle.png^[colorize:#A179E9:256',
|
||||||
|
glow = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if minetest.has_feature({ dynamic_add_media_table = true, particlespawner_tweenable = true }) then
|
||||||
|
-- new syntax, after v5.6.0
|
||||||
|
particlespawner_def = {
|
||||||
|
amount = 50,
|
||||||
|
time = 0.5,
|
||||||
|
size = {
|
||||||
|
min = 0.5,
|
||||||
|
max = 1,
|
||||||
|
},
|
||||||
|
exptime = 2,
|
||||||
|
pos = {
|
||||||
|
min = vector.new({ x = pos.x - 1.5, y = pos.y + 1, z = pos.z - 1.5 }),
|
||||||
|
max = vector.new({ x = pos.x + 1.5, y = pos.y + 1.5, z = pos.z + 1.5 }),
|
||||||
|
},
|
||||||
|
attract = {
|
||||||
|
kind = 'point',
|
||||||
|
strength = 2,
|
||||||
|
origin = vector.new({ x = pos.x, y = pos.y + 0.65, z = pos.z }),
|
||||||
|
die_on_contact = true
|
||||||
|
},
|
||||||
|
texture = {
|
||||||
|
name = 'x_enchanting_scroll_particle.png^[colorize:#A179E9:256',
|
||||||
|
alpha_tween = {
|
||||||
|
0.5, 1,
|
||||||
|
style = 'fwd',
|
||||||
|
reps = 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
glow = 1
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.add_particlespawner(particlespawner_def)
|
||||||
end
|
end
|
||||||
|
|
||||||
function XEnchanting.get_enchantment_data(self, player, nr_of_bookshelfs, tool_def)
|
function XEnchanting.get_enchantment_data(self, player, nr_of_bookshelfs, tool_def)
|
||||||
@ -817,17 +869,17 @@ function XEnchanting.get_formspec(self, pos, player_name, data)
|
|||||||
|
|
||||||
if inv:get_stack('trade', 1):get_count() >= i then
|
if inv:get_stack('trade', 1):get_count() >= i then
|
||||||
---@diagnostic disable-next-line: codestyle-check
|
---@diagnostic disable-next-line: codestyle-check
|
||||||
formspec[#formspec + 1] = 'image_button[2.75,' .. -0.5 + i .. ';5,1;x_enchanting_image_button.png;slot_' .. i .. ';' .. slot.descriptions.enchantments_desc_masked .. ' ' .. minetest.colorize('#594E47', S('level') .. ': ' .. slot.level) .. ']'
|
formspec[#formspec + 1] = 'image_button[3.125,' .. -0.5 + i .. ';5.125,1;x_enchanting_image_button.png;slot_' .. i .. ';' .. slot.descriptions.enchantments_desc_masked .. minetest.formspec_escape(' [' .. slot.level .. ']') .. ']'
|
||||||
else
|
else
|
||||||
---@diagnostic disable-next-line: codestyle-check
|
---@diagnostic disable-next-line: codestyle-check
|
||||||
formspec[#formspec + 1] = 'image_button[2.75,' .. -0.5 + i .. ';5,1;x_enchanting_image_button_disabled.png;slot_' .. i .. ';' .. slot.descriptions.enchantments_desc_masked .. ' ' .. minetest.colorize('#594E47', S('level') .. ': ' .. slot.level) .. ']'
|
formspec[#formspec + 1] = 'image_button[3.125,' .. -0.5 + i .. ';5.125,1;x_enchanting_image_button_disabled.png;slot_' .. i .. ';' .. slot.descriptions.enchantments_desc_masked .. minetest.formspec_escape(' [' .. slot.level .. ']') .. ']'
|
||||||
end
|
end
|
||||||
|
|
||||||
formspec[#formspec + 1] = 'image[2.75,' .. -0.5 + i .. ';1,1;x_enchanting_image_trade_' .. i .. '.png;]'
|
formspec[#formspec + 1] = 'image[2.3,' .. -0.5 + i .. ';1,1;x_enchanting_image_trade_' .. i .. '.png;]'
|
||||||
else
|
else
|
||||||
-- disabled buttons
|
-- disabled buttons
|
||||||
---@diagnostic disable-next-line: codestyle-check
|
---@diagnostic disable-next-line: codestyle-check
|
||||||
formspec[#formspec + 1] = 'image_button[2.75,' .. -0.5 + i .. ';5,1;x_enchanting_image_button_disabled.png;slot_' .. i .. ';]'
|
formspec[#formspec + 1] = 'image_button[3.125,' .. -0.5 + i .. ';5.125,1;x_enchanting_image_button_disabled.png;slot_' .. i .. ';]'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -836,7 +888,7 @@ function XEnchanting.get_formspec(self, pos, player_name, data)
|
|||||||
for i = 1, 3, 1 do
|
for i = 1, 3, 1 do
|
||||||
-- disabled buttons
|
-- disabled buttons
|
||||||
---@diagnostic disable-next-line: codestyle-check
|
---@diagnostic disable-next-line: codestyle-check
|
||||||
formspec[#formspec + 1] = 'image_button[2.75,' .. -0.5 + i .. ';5,1;x_enchanting_image_button_disabled.png;slot_' .. i .. ';]'
|
formspec[#formspec + 1] = 'image_button[3.125,' .. -0.5 + i .. ';5.125,1;x_enchanting_image_button_disabled.png;slot_' .. i .. ';]'
|
||||||
end
|
end
|
||||||
|
|
||||||
model_scroll_is_open = false
|
model_scroll_is_open = false
|
||||||
|
57
init.lua
57
init.lua
@ -95,6 +95,63 @@ minetest.register_on_mods_loaded(function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elseif starts_with(name, 'animalia:') then
|
||||||
|
if def.death_func and def.drops then
|
||||||
|
local prev_death_func = def.death_func
|
||||||
|
|
||||||
|
---@param self table
|
||||||
|
def.death_func = function(self)
|
||||||
|
local puncher = self._puncher
|
||||||
|
|
||||||
|
if not self
|
||||||
|
or not self.object
|
||||||
|
or not self.object:get_luaentity()
|
||||||
|
or not puncher
|
||||||
|
or not puncher:is_player()
|
||||||
|
or self._looting_dropped
|
||||||
|
then
|
||||||
|
return prev_death_func(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
local wield_stack = puncher:get_wielded_item()
|
||||||
|
local wield_stack_meta = wield_stack:get_meta()
|
||||||
|
local looting = wield_stack_meta:get_float('is_looting')
|
||||||
|
|
||||||
|
if looting == 0 then
|
||||||
|
return prev_death_func(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
local pos = self.object:get_pos()
|
||||||
|
|
||||||
|
prev_death_func(self)
|
||||||
|
|
||||||
|
local death_by_player = puncher and puncher:is_player()
|
||||||
|
|
||||||
|
if death_by_player and pos then
|
||||||
|
local tool_capabilities = wield_stack:get_tool_capabilities()
|
||||||
|
self._looting_dropped = true
|
||||||
|
|
||||||
|
for _, drop in ipairs(def.drops) do
|
||||||
|
if math.random(10, 100) / 100 < looting / (looting + 1) then
|
||||||
|
local drop_min = drop.min or 0
|
||||||
|
local drop_max = drop.max or 0
|
||||||
|
local count = math.random(drop_min, drop_max)
|
||||||
|
local stack = ItemStack({
|
||||||
|
name = drop.name,
|
||||||
|
count = count
|
||||||
|
})
|
||||||
|
local chance = math.random(1, tool_capabilities.max_drop_level)
|
||||||
|
|
||||||
|
stack:set_count(stack:get_count() * chance)
|
||||||
|
|
||||||
|
if stack:get_count() > 0 then
|
||||||
|
minetest.item_drop(stack, puncher, pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
# textdomain: x_enchanting
|
# textdomain: x_enchanting
|
||||||
Sharpness=
|
Sharpness=
|
||||||
|
Looting=
|
||||||
Fortune=
|
Fortune=
|
||||||
Unbreaking=
|
Unbreaking=
|
||||||
Efficiency=
|
Efficiency=
|
||||||
Silk Touch=
|
Silk Touch=
|
||||||
Curse of Vanishing=
|
Curse of Vanishing=
|
||||||
Knockback=
|
Knockback=
|
||||||
|
Power=
|
||||||
|
Punch=
|
||||||
|
Infinity=
|
||||||
Enchanted=
|
Enchanted=
|
||||||
Enchant=
|
Enchant=
|
||||||
level=
|
|
||||||
Enchanting Table=
|
Enchanting Table=
|
||||||
owned by=
|
owned by=
|
||||||
Scroll of Enchantments=
|
Scroll of Enchantments=
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
# textdomain: x_enchanting
|
# textdomain: x_enchanting
|
||||||
Sharpness=Ostrosť
|
Sharpness=Ostrosť
|
||||||
|
Looting=
|
||||||
Fortune=Šťastie
|
Fortune=Šťastie
|
||||||
Unbreaking=Nelámavosť
|
Unbreaking=Nelámavosť
|
||||||
Efficiency=Výkonnosť
|
Efficiency=Výkonnosť
|
||||||
Silk Touch=Hodvábny dotyk
|
Silk Touch=Hodvábny dotyk
|
||||||
Curse of Vanishing=Kliatba zmiznutia
|
Curse of Vanishing=Kliatba zmiznutia
|
||||||
Knockback=Spätný úder
|
Knockback=Spätný úder
|
||||||
|
Power=
|
||||||
|
Punch=
|
||||||
|
Infinity=
|
||||||
Enchanted=Očarený
|
Enchanted=Očarený
|
||||||
Enchant=Očarovať
|
Enchant=Očarovať
|
||||||
level=level
|
|
||||||
Enchanting Table=Čarovný stôl
|
Enchanting Table=Čarovný stôl
|
||||||
owned by=vlastník
|
owned by=vlastník
|
||||||
Scroll of Enchantments=Čarovný Zvitok
|
Scroll of Enchantments=Čarovný Zvitok
|
||||||
|
12
table.lua
12
table.lua
@ -337,8 +337,11 @@ minetest.register_node('x_enchanting:table', {
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local p_name = player:get_player_name()
|
local p_name = player:get_player_name()
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
local item_stack = inv:get_stack('item', 1)
|
||||||
|
local item_stack_meta = item_stack:get_meta()
|
||||||
|
local is_enchanted = item_stack_meta:get_int('is_enchanted')
|
||||||
|
|
||||||
if not inv:is_empty('item') then
|
if not inv:is_empty('item') and is_enchanted == 0 then
|
||||||
-- bookshelfs
|
-- bookshelfs
|
||||||
local bookshelfs = minetest.find_nodes_in_area(
|
local bookshelfs = minetest.find_nodes_in_area(
|
||||||
{ x = pos.x - 2, y = pos.y, z = pos.z - 2 },
|
{ x = pos.x - 2, y = pos.y, z = pos.z - 2 },
|
||||||
@ -346,7 +349,6 @@ minetest.register_node('x_enchanting:table', {
|
|||||||
{ 'default:bookshelf', 'group:bookshelf' }
|
{ 'default:bookshelf', 'group:bookshelf' }
|
||||||
)
|
)
|
||||||
|
|
||||||
local item_stack = inv:get_stack('item', 1)
|
|
||||||
local data = XEnchanting:get_enchantment_data(
|
local data = XEnchanting:get_enchantment_data(
|
||||||
player,
|
player,
|
||||||
#bookshelfs,
|
#bookshelfs,
|
||||||
@ -370,8 +372,11 @@ minetest.register_node('x_enchanting:table', {
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local p_name = player:get_player_name()
|
local p_name = player:get_player_name()
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
local item_stack = inv:get_stack('item', 1)
|
||||||
|
local item_stack_meta = item_stack:get_meta()
|
||||||
|
local is_enchanted = item_stack_meta:get_int('is_enchanted')
|
||||||
|
|
||||||
if not inv:is_empty('item') then
|
if not inv:is_empty('item') and is_enchanted == 0 then
|
||||||
-- bookshelfs
|
-- bookshelfs
|
||||||
local bookshelfs = minetest.find_nodes_in_area(
|
local bookshelfs = minetest.find_nodes_in_area(
|
||||||
{ x = pos.x - 2, y = pos.y, z = pos.z - 2 },
|
{ x = pos.x - 2, y = pos.y, z = pos.z - 2 },
|
||||||
@ -379,7 +384,6 @@ minetest.register_node('x_enchanting:table', {
|
|||||||
{ 'default:bookshelf', 'group:bookshelf' }
|
{ 'default:bookshelf', 'group:bookshelf' }
|
||||||
)
|
)
|
||||||
|
|
||||||
local item_stack = inv:get_stack('item', 1)
|
|
||||||
local data = XEnchanting:get_enchantment_data(
|
local data = XEnchanting:get_enchantment_data(
|
||||||
player,
|
player,
|
||||||
#bookshelfs,
|
#bookshelfs,
|
||||||
|
Reference in New Issue
Block a user