diff options
author | root <root@linux-forks.de> | 2018-08-24 18:51:29 +0200 |
---|---|---|
committer | root <root@linux-forks.de> | 2018-08-24 18:51:29 +0200 |
commit | b32bd2d50b685e9f550f1138d3db1ed0c6504d2c (patch) | |
tree | 430cb14a8978df59148721419c412b2fefa59459 /crystal.lua | |
parent | 36dbea5a590b5cf6b6a80dbc1625215a1ba50e47 (diff) | |
parent | 9dac31a106b10e72bb3a5e71f8cd5d8f69e5aafb (diff) |
Merge https://notabug.org/TenPlus1/ethereal
Diffstat (limited to 'crystal.lua')
-rw-r--r-- | crystal.lua | 72 |
1 files changed, 62 insertions, 10 deletions
diff --git a/crystal.lua b/crystal.lua index fdbdd17..2b2868a 100644 --- a/crystal.lua +++ b/crystal.lua @@ -32,20 +32,67 @@ minetest.register_craftitem("ethereal:crystal_ingot", { wield_image = "crystal_ingot.png", }) -minetest.register_craft({ - output = "ethereal:crystal_ingot", - recipe = { - {"default:mese_crystal", "ethereal:crystal_spike"}, - {"ethereal:crystal_spike", "default:mese_crystal"}, - } -}) +if minetest.get_modpath("builtin_item") then + + minetest.override_item("ethereal:crystal_spike", { + + dropped_step = function(self, pos, dtime) + + self.ctimer = (self.ctimer or 0) + dtime + if self.ctimer < 5.0 then return end + self.ctimer = 0 + + if self.node_inside + and self.node_inside.name ~= "default:water_source" then + return + end + + local objs = core.get_objects_inside_radius(pos, 0.8) + + if not objs or #objs ~= 2 then return end + + local crystal, mese, ent = nil, nil, nil + + for k, obj in pairs(objs) do + + ent = obj:get_luaentity() + + if ent and ent.name == "__builtin:item" then + + if ent.itemstring == "default:mese_crystal 2" + and not mese then + + mese = obj + + elseif ent.itemstring == "ethereal:crystal_spike 2" + and not crystal then + + crystal = obj + end + end + end + + if mese and crystal then + + mese:remove() + crystal:remove() + + core.add_item(pos, "ethereal:crystal_ingot") + + return false + end + end + }) +end minetest.register_craft({ + type = "shapeless", output = "ethereal:crystal_ingot", recipe = { - {"ethereal:crystal_spike", "default:mese_crystal"}, - {"default:mese_crystal", "ethereal:crystal_spike"}, - } + "default:mese_crystal", "ethereal:crystal_spike", + "ethereal:crystal_spike", "default:mese_crystal", "bucket:bucket_water" + }, + replacements = { {"bucket:bucket_water", "bucket:bucket_empty"} } }) -- Crystal Block @@ -253,4 +300,9 @@ minetest.override_item("ethereal:shovel_crystal", { original_description = "Crystal Shovel", description = toolranks.create_description("Crystal Shovel", 0, 1), after_use = toolranks.new_afteruse}) + +minetest.override_item("ethereal:sword_crystal", { + original_description = "Crystal Sword", + description = toolranks.create_description("Crystal Sword", 0, 1), + after_use = toolranks.new_afteruse}) end |