2024-06-27 21:01:35 -06:00

55 lines
1.6 KiB
Lua

PyuTestCore.LOOTBOX_USEFULLNESS = {
USELESS = "purple",
AVERAGE = "lightblue",
USEFUL = "coral",
AMAZING = "cyan"
}
PyuTestCore.make_lootbox = function (type, dtype, items, usefullness)
local id = "pyutest_core:"..type.."_lootbox"
minetest.register_node(id, {
description = Translate(dtype .. " Lootbox"),
groups = {block = PyuTestCore.BLOCK_BREAKABLE_CHOPPY},
tiles = {"crate.png"},
color = usefullness,
sounds = PyuTestCore.make_node_sounds(),
on_rightclick = function (pos, _, clicker)
if clicker == nil then return end
for _, v in pairs(items) do
minetest.add_item(pos, v)
end
minetest.sound_play("lootbox_unlock", {
pos = pos,
gain = 1
})
minetest.remove_node(pos)
end
})
end
PyuTestCore.make_lootbox("trash", "Trash", {
ItemStack("pyutest_core:deadbush 19"),
ItemStack("pyutest_core:")
}, PyuTestCore.LOOTBOX_USEFULLNESS.USELESS)
PyuTestCore.make_lootbox("resource", "Resource", {
ItemStack("pyutest_core:gunpowder 3"),
ItemStack("pyutest_core:stick 4"),
ItemStack("pyutest_core:sugar 2"),
ItemStack("pyutest_core:tree_sapling 3"),
ItemStack("pyutest_core:apple 3"),
ItemStack("pyutest_core:string 5")
}, PyuTestCore.LOOTBOX_USEFULLNESS.AVERAGE)
PyuTestCore.make_lootbox("griefer", "Griefer's Dream", {
ItemStack("pyutest_core:tnt 3"),
ItemStack("pyutest_core:bomb 2")
}, PyuTestCore.LOOTBOX_USEFULLNESS.USEFUL)
PyuTestCore.make_lootbox("lighting", "Lighting", {
ItemStack("pyutest_core:light 2"),
ItemStack("pyutest_core:torch 13")
}, PyuTestCore.LOOTBOX_USEFULLNESS.AMAZING)