2024-06-17 14:32:51 -06:00

55 lines
1.8 KiB
Lua

PyuTestCore.make_spellbook = function (nsname, sname, desc, color, action)
if action == nil then
action = function(_, _, _)end
end
PyuTestCore.make_item(nsname, sname, desc, {}, "spellbook.png", {
color = color,
on_use = function (itemstack, user, pointed_thing)
local pos = user:get_pos()
minetest.sound_play({name = "spellbook_action", gain = 0.75}, {pos = pos})
action(itemstack, user, pointed_thing)
end,
})
end
PyuTestCore.make_sword = function (nsname, sname, desc, texture, damage, durability)
PyuTestCore.make_tool(nsname, sname, desc, {}, texture, {
stack_max = 1,
tool_capabilities = {
groupcaps = {
block = {
uses = durability / 2
}
},
punch_attack_uses = durability,
damage_groups = {fleshy = damage}
}
})
end
PyuTestCore.make_sword("pyutest_core:iron_sword", "iron_sword", "Iron Sword", "iron-sword.png", 7, 400)
PyuTestCore.make_sword("pyutest_core:diamond_sword", "diamond_sword", "Diamond Sword", "diamond-sword.png", 12, 600)
PyuTestCore.make_spellbook("pyutest_core:explosions_spellbook", "explosions_spellbook", "Spellbook of Explosions", "gray", function (itemstack, user)
PyuTestCore.create_explosion(user:get_pos(), 3, false, 4, user)
end)
PyuTestCore.make_spellbook("pyutest_core:fire_spellbook", "fire_spellbook", "Spellbook of Fire", "orange", function (itemstack, user)
local range = 2
local function replace(pos)
local node = minetest.get_node_or_nil(pos)
if node == nil then return end
if node.name ~= "air" then return end
minetest.set_node(pos, {name = "pyutest_core:fire"})
end
for dx = -range, range do
for dz = -range, range do
local pos = user:get_pos()
replace({x = pos.x + dx, y = pos.y, z = pos.z + dz})
end
end
end)