diff --git a/CHANGELOG.md b/CHANGELOG.md index 10d9668..a83601a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [Jun 14th 2024] Major Update: Luck and Boxes + +- Added Lootboxes + - Added Trash Lootbox + - Added Resource Lootbox + - Added Griefer's Dream Lootbox + - Added Liquid Sources Lootbox + - Added Lighting Lootbox +- Lootboxes spawn across various biomes +- Revamped Bomb + ## [Jun 14th 2024] Major Update: Items and Utilites Update - Added Gunpowder, Coins, Sugar, and Ash diff --git a/mods/pyutest_core/init.lua b/mods/pyutest_core/init.lua index b61a319..eb2ebd3 100644 --- a/mods/pyutest_core/init.lua +++ b/mods/pyutest_core/init.lua @@ -33,3 +33,4 @@ dofile(PyuTestCore_Path.."/abms.lua") dofile(PyuTestCore_Path.."/tools.lua") dofile(PyuTestCore_Path.."/player.lua") dofile(PyuTestCore_Path.."/crafts.lua") +dofile(PyuTestCore_Path.."/lootboxes.lua") diff --git a/mods/pyutest_core/lootboxes.lua b/mods/pyutest_core/lootboxes.lua new file mode 100644 index 0000000..a7b4abd --- /dev/null +++ b/mods/pyutest_core/lootboxes.lua @@ -0,0 +1,60 @@ +PyuTestCore.LOOTBOX_USEFULLNESS = { + USELESS = "white", + 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_LONG}, + 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:coin 4"), + ItemStack("pyutest_core:tree_sapling 2") +}, 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) diff --git a/mods/pyutest_core/structures.lua b/mods/pyutest_core/structures.lua index 741e0f7..ae8f6f0 100644 --- a/mods/pyutest_core/structures.lua +++ b/mods/pyutest_core/structures.lua @@ -49,3 +49,26 @@ minetest.register_decoration({ rotation = "random", flags = "place_center_x, place_center_z" }) + +minetest.register_decoration({ + deco_type = "simple", + sidelen = 16, + fill_ratio = 0.0008, + place_on = { + "pyutest_core:grass_block", + "pyutest_core:dirt_block", + "pyutest_core:snow_block", + "pyutest_core:mycelium_block", + "pyutest_core:stone_block" + }, + biomes = {"desert", "grassland", "mushroom_fields", "frozen_plains", "forest"}, + y_max = PyuTestCore_BiomeTops.mountains, + y_min = PyuTestCore_SurfaceBiomeBottom, + decoration = { + "pyutest_core:trash_lootbox", + "pyutest_core:resource_lootbox", + "pyutest_core:griefer_lootbox", + "pyutest_core:liquid_sources_lootbox", + "pyutest_core:lighting_lootbox", + } +}) diff --git a/mods/pyutest_core/textures/lootbox_unlock.ogg b/mods/pyutest_core/textures/lootbox_unlock.ogg new file mode 100644 index 0000000..149da1b Binary files /dev/null and b/mods/pyutest_core/textures/lootbox_unlock.ogg differ diff --git a/mods/pyutest_core/tools.lua b/mods/pyutest_core/tools.lua index aa0cda7..9711fe6 100644 --- a/mods/pyutest_core/tools.lua +++ b/mods/pyutest_core/tools.lua @@ -51,13 +51,18 @@ PyuTestCore.make_tool("pyutest_core:pickaxe", "pickaxe", "Pickaxe", {}, "pickaxe } }) -PyuTestCore.make_tool("pyutest_core:bomb", "bomb", "Bomb", {}, "bomb.png", { +PyuTestCore.make_item("pyutest_core:bomb", "bomb", "Bomb", {}, "bomb.png", { + stack_max = 16, on_use = function (_, user) if user == nil then return end local pos = user:get_pos() PyuTestCore.create_explosion(pos, 2) + local stack = user:get_wielded_item() + stack:set_count(stack:get_count() - 1) + + user:set_wielded_item(stack) end })