From 1caf0fba61573c62928c393f7a2c9fecc942704d Mon Sep 17 00:00:00 2001 From: Duane Date: Tue, 12 Jul 2016 22:36:14 -0500 Subject: [PATCH] Add breathing elixir. --- elixir.lua | 118 ++++++++++++++++++-------- init.lua | 2 +- textures/fun_caves_elixir_breathe.png | Bin 0 -> 1275 bytes 3 files changed, 82 insertions(+), 38 deletions(-) create mode 100644 textures/fun_caves_elixir_breathe.png diff --git a/elixir.lua b/elixir.lua index 1ac8c56..b681e02 100644 --- a/elixir.lua +++ b/elixir.lua @@ -11,7 +11,6 @@ local elixir_ingredients = { 'default:aspen_sapling', 'default:aspen_tree', 'default:aspen_wood', - 'default:bronze_lump', 'default:cactus', 'default:clay_lump', 'default:cloud', @@ -32,8 +31,6 @@ local elixir_ingredients = { 'default:jungletree', 'default:junglewood', 'default:leaves', - 'default:mese_crystal', - 'default:obsidian', 'default:pine_needles', 'default:pine_sapling', 'default:pine_tree', @@ -61,7 +58,6 @@ local elixir_ingredients = { 'fun_caves:bird_of_paradise', 'fun_caves:black_sand', 'fun_caves:brain_coral', - 'fun_caves:cloud', 'fun_caves:diamondwood', 'fun_caves:dragon_eye', 'fun_caves:dry_fiber', @@ -69,25 +65,15 @@ local elixir_ingredients = { 'fun_caves:giant_mushroom_cap', 'fun_caves:giant_mushroom_stem', 'fun_caves:hibiscus', - 'fun_caves:hot_brass', - 'fun_caves:hot_cobble', - 'fun_caves:hot_iron', 'fun_caves:huge_mushroom_cap', 'fun_caves:icicle_down', 'fun_caves:icicle_up', 'fun_caves:ironwood', 'fun_caves:leaves', - 'fun_caves:leaves_black', - 'fun_caves:leaves_lumin', - 'fun_caves:lumin_tree', - 'fun_caves:moon_weed', 'fun_caves:onion', 'fun_caves:orchid', 'fun_caves:petrified_wood', 'fun_caves:pillar_coral', - 'fun_caves:polluted_dirt', - 'fun_caves:precious_coral', - 'fun_caves:radioactive_ore', 'fun_caves:small_rocks', 'fun_caves:staghorn_coral', 'fun_caves:stalactite', @@ -96,21 +82,18 @@ local elixir_ingredients = { 'fun_caves:stalagmite', 'fun_caves:stalagmite_mossy', 'fun_caves:stalagmite_slimy', - 'fun_caves:storm_cloud', 'fun_caves:thin_ice', 'fun_caves:tree', 'wool:white', 'wool:black', } +local count = 0 for _, name in pairs(elixir_ingredients) do local item = minetest.registered_items[name] if not item then item = minetest.registered_nodes[name] end - if not item then - break - end if item then if item.groups then groups = table.copy(item.groups) @@ -119,44 +102,105 @@ for _, name in pairs(elixir_ingredients) do end groups.elixir_ingredient = 1 minetest.override_item(name, {groups = groups}) + count = count + 1 else --print(name) end end ---for _, list in pairs({'registered_items', 'registered_nodes', 'registered_craftitems'}) do --- for _, item in pairs(minetest[list]) do --- if item and item.groups.elixir_ingredient then --- print(item.name) --- end --- end ---end -minetest.register_craftitem("fun_caves:elixir", { - description = "Unknown Elixir", - inventory_image = "fun_caves_elixir.png", - on_use = minetest.item_eat(-2), +if count > 15 then + --for _, list in pairs({'registered_items', 'registered_nodes', 'registered_craftitems'}) do + -- for _, item in pairs(minetest[list]) do + -- if item and item.groups.elixir_ingredient then + -- print(item.name) + -- end + -- end + --end + + local elixirs = {} + + minetest.register_craftitem("fun_caves:elixir", { + description = "unknown elixir", + inventory_image = "fun_caves_elixir.png", + on_use = minetest.item_eat(-2), + }) + + minetest.register_craft({ + type = "shapeless", + output = 'fun_caves:elixir', + recipe = { + 'mobs_slimes:green_slimeball', + 'group:elixir_ingredient', + 'group:elixir_ingredient', + 'group:elixir_ingredient', + "vessels:glass_bottle", + }, + }) + + minetest.register_craft({ + type = "shapeless", + output = 'fun_caves:elixir', + recipe = { + 'fun_caves:syrup', + 'group:elixir_ingredient', + 'group:elixir_ingredient', + 'group:elixir_ingredient', + }, + }) + + minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) + if itemstack:get_name() ~= "fun_caves:elixir" then + return + end + + local ingredients = {} + for i = 1, player:get_inventory():get_size("craft") do + local name = old_craft_grid[i]:get_name() + if name ~= '' and name ~= 'fun_caves:syrup' and not name:find('green_slimeball$') then + ingredients[#ingredients+1] = name + print(name) + end + end + end) +end + + +fun_caves.register_status({ + name = 'breathe', + terminate = function(player) + local player_name = player:get_player_name() + minetest.chat_send_player(player_name, minetest.colorize('#FF0000', 'Your breathing becomes more difficult...')) + end, +}) + +minetest.register_craftitem("fun_caves:elixir_breathe", { + description = 'Dr Robertson\'s Patented Easy Breathing Elixir', + inventory_image = "fun_caves_elixir_breathe.png", + on_use = function(itemstack, user, pointed_thing) + local player_name = user:get_player_name() + fun_caves.set_status(user:get_player_name(), 'breathe', elixir_duration) + minetest.chat_send_player(player_name, 'Your breathing becomes easier...') + itemstack:take_item() + return itemstack + end, }) minetest.register_craft({ type = "shapeless", - output = 'fun_caves:elixir', + output = 'fun_caves:elixir_breathe', recipe = { 'mobs_slimes:green_slimeball', - 'group:elixir_ingredient', - 'group:elixir_ingredient', - 'group:elixir_ingredient', + 'fun_caves:coral_gem', "vessels:glass_bottle", }, }) minetest.register_craft({ type = "shapeless", - output = 'fun_caves:elixir', + output = 'fun_caves:elixir_breathe', recipe = { 'fun_caves:syrup', - 'group:elixir_ingredient', - 'group:elixir_ingredient', - 'group:elixir_ingredient', + 'fun_caves:coral_gem', }, }) diff --git a/init.lua b/init.lua index 9bc2ea3..df6c48d 100644 --- a/init.lua +++ b/init.lua @@ -56,7 +56,7 @@ end if not fun_caves.db then fun_caves.db = {} end -for _, i in pairs({'teleport_data', 'hunger', 'status', 'translocators'}) do +for _, i in pairs({'teleport_data', 'hunger', 'status', 'translocators', 'elixir_formulae'}) do if not fun_caves.db[i] then fun_caves.db[i] = {} end diff --git a/textures/fun_caves_elixir_breathe.png b/textures/fun_caves_elixir_breathe.png new file mode 100644 index 0000000000000000000000000000000000000000..8f157dea60a09a0530e64c8c631521f6c48baf28 GIT binary patch literal 1275 zcmVsb-EwMK3Z_1};gZ;vS{q+S&RUvpADBE$6`>2F|Z| z=hc16FvMCSY$u{rMH0}YmlDyQ^tQUuCpNdrb$i?UiRkr6M$JUT<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