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 4"), ItemStack("pyutest_core:stick 6"), ItemStack("pyutest_core:sugar 3"), ItemStack("pyutest_core:tree_sapling 2"), ItemStack("pyutest_core:apple 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("liquid_sources", "Liquid Sources", { ItemStack("pyutest_core:water_source 5"), ItemStack("pyutest_core:lava_source 5"), ItemStack("pyutest_core:oil_source 5"), ItemStack("pyutest_core:liquid_acid_source 5") }, PyuTestCore.LOOTBOX_USEFULLNESS.USEFUL) PyuTestCore.make_lootbox("lighting", "Lighting", { ItemStack("pyutest_core:light 2"), ItemStack("pyutest_core:torch 13") }, PyuTestCore.LOOTBOX_USEFULLNESS.AMAZING)