ethereal/crystal.lua

301 lines
7.6 KiB
Lua
Raw Permalink Normal View History

2016-06-09 17:08:34 +03:00
local S = minetest.get_translator("ethereal")
2016-06-09 17:08:34 +03:00
-- Crystal Ingot and recipe
minetest.register_craftitem("ethereal:crystal_ingot", {
description = S("Crystal Ingot"),
inventory_image = "ethereal_crystal_ingot.png",
wield_image = "ethereal_crystal_ingot.png"
})
minetest.register_craft({
output = "ethereal:crystal_ingot",
recipe = {
{"default:mese_crystal", "ethereal:crystal_spike"},
{"ethereal:crystal_spike", "default:mese_crystal"},
{"bucket:bucket_water", ""}
},
replacements = {{"bucket:bucket_water", "bucket:bucket_empty"}}
})
-- Crystal Spike (Hurts if you touch it)
2014-11-09 22:17:41 +03:00
minetest.register_node("ethereal:crystal_spike", {
2016-06-09 17:08:34 +03:00
description = S("Crystal Spike"),
2014-11-09 22:17:41 +03:00
drawtype = "plantlike",
tiles = {"ethereal_crystal_spike.png"},
inventory_image = "ethereal_crystal_spike.png",
wield_image = "ethereal_crystal_spike.png",
2014-11-09 22:17:41 +03:00
paramtype = "light",
light_source = 7,
2015-07-04 14:22:39 +03:00
sunlight_propagates = true,
walkable = true,
2014-11-09 22:17:41 +03:00
damage_per_second = 1,
groups = {cracky = 1, falling_node = 1, puts_out_fire = 1, cools_lava = 1},
2014-11-09 22:17:41 +03:00
sounds = default.node_sound_glass_defaults(),
selection_box = {
type = "fixed", fixed = {-5 / 16, -0.5, -5 / 16, 5 / 16, 0, 5 / 16}
},
node_box = {
type = "fixed", fixed = {-5 / 16, -0.5, -5 / 16, 5 / 16, 0, 5 / 16}
},
2018-08-19 12:03:41 +03:00
dropped_step = function(self, pos, dtime) -- custom function for builtin_item use
2018-08-19 12:03:41 +03:00
self.ctimer = (self.ctimer or 0) + dtime
if self.ctimer < 5.0 then return end -- 5 second timer
self.ctimer = 0
2018-08-19 12:03:41 +03:00
if self.node_inside and self.node_inside.name ~= "default:water_source" then
return
end
2018-08-19 12:03:41 +03:00
local objs = minetest.get_objects_inside_radius(pos, 0.8)
2018-08-19 12:03:41 +03:00
if not objs or #objs ~= 2 then return end
2018-08-19 12:03:41 +03:00
local crystal, mese, ent = nil, nil, nil
2018-08-19 12:03:41 +03:00
for k, obj in pairs(objs) do
2018-08-19 12:03:41 +03:00
ent = obj:get_luaentity()
2018-08-19 12:03:41 +03:00
if ent and ent.name == "__builtin:item" then
2018-08-19 12:03:41 +03:00
if ent.itemstring == "default:mese_crystal 2" and not mese then
2018-08-19 12:03:41 +03:00
mese = obj
2018-08-19 12:03:41 +03:00
elseif ent.itemstring == "ethereal:crystal_spike 2" and not crystal then
2018-08-19 12:03:41 +03:00
crystal = obj
2018-08-19 12:03:41 +03:00
end
end
end
2018-08-19 12:03:41 +03:00
if mese and crystal then
2018-08-19 12:03:41 +03:00
mese:remove()
crystal:remove()
2018-08-19 12:03:41 +03:00
minetest.add_item(pos, "ethereal:crystal_ingot")
2018-08-19 12:03:41 +03:00
return false
2018-08-19 12:03:41 +03:00
end
end
})
-- Crystal Block and recipe
2014-11-09 22:17:41 +03:00
minetest.register_node("ethereal:crystal_block", {
2016-06-09 17:08:34 +03:00
description = S("Crystal Block"),
tiles = {"ethereal_crystal_block.png"},
light_source = 9,
2015-06-24 12:00:12 +03:00
is_ground_content = false,
groups = {cracky = 1, level = 2, puts_out_fire = 1, cools_lava = 1},
sounds = default.node_sound_glass_defaults()
2014-11-09 22:17:41 +03:00
})
minetest.register_craft({
output = "ethereal:crystal_block",
recipe = {
{"ethereal:crystal_ingot", "ethereal:crystal_ingot", "ethereal:crystal_ingot"},
{"ethereal:crystal_ingot", "ethereal:crystal_ingot", "ethereal:crystal_ingot"},
{"ethereal:crystal_ingot", "ethereal:crystal_ingot", "ethereal:crystal_ingot"}
2014-11-09 22:17:41 +03:00
}
})
minetest.register_craft({
output = "ethereal:crystal_ingot 9",
recipe = {{"ethereal:crystal_block"}}
2014-11-09 22:17:41 +03:00
})
-- Crystal Sword (Powerful wee beastie)
2014-11-09 22:17:41 +03:00
minetest.register_tool("ethereal:sword_crystal", {
2016-06-09 17:08:34 +03:00
description = S("Crystal Sword"),
inventory_image = "ethereal_crystal_sword.png",
wield_image = "ethereal_crystal_sword.png",
2014-11-09 22:17:41 +03:00
tool_capabilities = {
full_punch_interval = 0.6,
2015-07-04 14:22:39 +03:00
max_drop_level = 1,
groupcaps = {
snappy = {
times = {[1] = 1.70, [2] = 0.70, [3] = 0.25}, uses = 50, maxlevel = 3
}
2014-11-09 22:17:41 +03:00
},
damage_groups = {fleshy = 10}
},
2019-06-03 12:06:01 +03:00
groups = {sword = 1},
sound = {breaks = "default_tool_breaks"}
2014-11-09 22:17:41 +03:00
})
minetest.register_craft({
output = "ethereal:sword_crystal",
recipe = {
{"ethereal:crystal_ingot"},
{"ethereal:crystal_ingot"},
{"default:steel_ingot"}
2014-11-09 22:17:41 +03:00
}
})
-- Crystal Axe
2014-11-09 22:17:41 +03:00
minetest.register_tool("ethereal:axe_crystal", {
2016-06-09 17:08:34 +03:00
description = S("Crystal Axe"),
inventory_image = "ethereal_crystal_axe.png",
wield_image = "ethereal_crystal_axe.png",
2014-11-09 22:17:41 +03:00
tool_capabilities = {
full_punch_interval = 0.8,
2015-07-04 14:22:39 +03:00
max_drop_level = 1,
groupcaps = {
choppy = {
times = {[1] = 2.00, [2] = 0.80, [3] = 0.40}, uses = 40, maxlevel = 3
}
2014-11-09 22:17:41 +03:00
},
damage_groups = {fleshy = 7}
2014-11-09 22:17:41 +03:00
},
2019-06-03 12:06:01 +03:00
groups = {axe = 1},
sound = {breaks = "default_tool_breaks"}
2014-11-09 22:17:41 +03:00
})
minetest.register_craft({
2019-08-05 10:57:49 +03:00
output = "ethereal:axe_crystal",
2014-11-09 22:17:41 +03:00
recipe = {
2019-08-05 10:57:49 +03:00
{"ethereal:crystal_ingot", "ethereal:crystal_ingot"},
{"ethereal:crystal_ingot", "default:steel_ingot"},
{"", "default:steel_ingot"}
2014-11-09 22:17:41 +03:00
}
})
minetest.register_craft({
2019-08-05 10:57:49 +03:00
output = "ethereal:axe_crystal",
recipe = {
2019-08-05 10:57:49 +03:00
{"ethereal:crystal_ingot", "ethereal:crystal_ingot"},
{"default:steel_ingot", "ethereal:crystal_ingot"},
{"default:steel_ingot", ""}
}
})
2014-11-09 22:17:41 +03:00
-- Crystal Pick (This will last a while)
2014-11-09 22:17:41 +03:00
minetest.register_tool("ethereal:pick_crystal", {
2016-06-09 17:08:34 +03:00
description = S("Crystal Pickaxe"),
inventory_image = "ethereal_crystal_pick.png",
wield_image = "ethereal_crystal_pick.png",
2014-11-09 22:17:41 +03:00
tool_capabilities = {
full_punch_interval = 0.7,
2015-07-04 14:22:39 +03:00
max_drop_level = 3,
2014-11-09 22:17:41 +03:00
groupcaps={
2015-07-04 14:22:39 +03:00
cracky = {
times = {[1] = 1.8, [2] = 0.8, [3] = 0.40}, uses = 40, maxlevel = 3
}
2014-11-09 22:17:41 +03:00
},
damage_groups = {fleshy = 6}
2014-11-09 22:17:41 +03:00
},
2019-06-03 12:06:01 +03:00
groups = {pickaxe = 1},
sound = {breaks = "default_tool_breaks"}
2014-11-09 22:17:41 +03:00
})
minetest.register_craft({
output = "ethereal:pick_crystal",
recipe = {
{"ethereal:crystal_ingot", "ethereal:crystal_ingot", "ethereal:crystal_ingot"},
{"", "default:steel_ingot", ""},
{"", "default:steel_ingot", ""}
2014-11-09 22:17:41 +03:00
}
})
-- backup old function and replace with new silk touch ability for crystal shovel
local old_handle_node_drops = minetest.handle_node_drops
2014-11-09 22:17:41 +03:00
function minetest.handle_node_drops(pos, drops, digger)
2014-11-09 22:17:41 +03:00
-- are we holding Crystal Shovel?
if not digger
or digger:get_wielded_item():get_name() ~= "ethereal:shovel_crystal" then
return old_handle_node_drops(pos, drops, digger)
end
local nn = minetest.get_node(pos).name
if minetest.get_item_group(nn, "crumbly") == 0
or minetest.get_item_group(nn, "no_silktouch") == 1 then
return old_handle_node_drops(pos, drops, digger)
end
return old_handle_node_drops(pos, {ItemStack(nn)}, digger)
end
-- Crystal Shovel
minetest.register_tool("ethereal:shovel_crystal", {
description = S("Crystal Shovel"),
inventory_image = "ethereal_crystal_shovel.png",
wield_image = "ethereal_crystal_shovel.png^[transformR90",
tool_capabilities = {
full_punch_interval = 1.0,
2020-04-27 19:45:15 +03:00
max_drop_level = 1,
groupcaps = {
crumbly = {
times = {[1] = 1.10, [2] = 0.50, [3] = 0.30}, uses = 30, maxlevel = 3
}
},
damage_groups = {fleshy = 4}
},
2019-06-03 12:06:01 +03:00
groups = {shovel = 1},
sound = {breaks = "default_tool_breaks"}
2014-11-09 22:17:41 +03:00
})
minetest.register_craft({
output = "ethereal:shovel_crystal",
recipe = {
{"ethereal:crystal_ingot"},
{"default:steel_ingot"},
{"default:steel_ingot"}
2014-11-09 22:17:41 +03:00
}
})
2015-07-04 14:22:39 +03:00
-- Crystal Gilly Staff (replenishes air supply when used)
2014-11-09 22:17:41 +03:00
minetest.register_tool("ethereal:crystal_gilly_staff", {
2016-06-09 17:08:34 +03:00
description = S("Crystal Gilly Staff"),
inventory_image = "ethereal_crystal_gilly_staff.png",
wield_image = "ethereal_crystal_gilly_staff.png",
2014-11-09 22:17:41 +03:00
on_use = function(itemstack, user, pointed_thing)
if user and user:get_breath() < 10 then user:set_breath(10) end
end
2014-11-09 22:17:41 +03:00
})
minetest.register_craft({
output = "ethereal:crystal_gilly_staff",
recipe = {
2023-04-22 11:00:44 +03:00
{"ethereal:green_moss", "ethereal:gray_moss", "ethereal:fiery_moss"},
{"ethereal:crystal_moss", "ethereal:crystal_ingot", "ethereal:mushroom_moss"},
{"", "ethereal:crystal_ingot", ""}
},
})
-- Add Toolranks mod support
if minetest.get_modpath("toolranks") then
local function add_tool(name, desc, afteruse) -- helper function
2019-06-02 13:22:06 +03:00
minetest.override_item(name, {
original_description = desc,
description = toolranks.create_description(desc, 0, 1),
after_use = afteruse and toolranks.new_afteruse
})
end
add_tool("ethereal:pick_crystal", "Crystal Pickaxe", true)
add_tool("ethereal:axe_crystal", "Crystal Axe", true)
add_tool("ethereal:shovel_crystal", "Crystal Shovel", true)
add_tool("ethereal:sword_crystal", "Crystal Sword", true)
end