lavastuff-cd2025/init.lua

514 lines
15 KiB
Lua
Raw Normal View History

2018-10-17 16:49:18 -07:00
lavastuff = {}
local S
2019-02-05 14:30:10 -08:00
2019-02-08 19:01:07 -08:00
if minetest.get_translator ~= nil then
S = minetest.get_translator(minetest.get_current_modname())
else
S = function(str)
return(str)
end
end
lavastuff.enable_tool_fire = minetest.settings:get_bool("lavastuff_enable_tool_fire")
-- Places fire where the player rightclicks with a lava tool
lavastuff.cook_limit = minetest.settings:get("lavastuff_cook_limit")
-- Tools will not smelt dug items if their cooking time is too long
2019-02-01 18:32:34 -08:00
if lavastuff.cook_limit ~= false then
lavastuff.cook_limit = 15
end
if lavastuff.enable_tool_fire ~= false then
lavastuff.enable_tool_fire = true
end
lavastuff.blacklisted_items = { -- Items lava tools will not smelt
"default:mese_crystal",
"default:mese",
}
2019-03-25 14:48:19 -07:00
if minetest.registered_items["fire:basic_flame"] and lavastuff.enable_tool_fire == true then
function lavastuff.tool_fire_func(itemstack, user, pointed_thing)
if not minetest.registered_items["fire:basic_flame"] or
lavastuff.enable_tool_fire == false then
return
end
local node = minetest.get_node(pointed_thing.above)
local pointed = {type = "node", under = pointed_thing.above, above = pointed_thing.above}
local _, can_place = minetest.item_place_node(ItemStack("fire:basic_flame"), user, pointed)
if node.name == "air" and can_place == true then
minetest.set_node(pointed_thing.above, {name = "fire:permanent_flame"})
minetest.after(7, function()
if minetest.get_node(pointed_thing.above).name == "fire:permanent_flame" then
minetest.remove_node(pointed_thing.above)
end
end)
end
end
end
2018-10-17 16:49:18 -07:00
function lavastuff.burn_drops(tool)
local old_handle_node_drops = minetest.handle_node_drops
function minetest.handle_node_drops(pos, drops, digger)
2019-02-01 18:32:34 -08:00
if digger:get_wielded_item():get_name() ~= (tool) then
2018-10-17 16:49:18 -07:00
return old_handle_node_drops(pos, drops, digger)
end
-- reset new smelted drops
local hot_drops = {}
-- loop through current node drops
for _, drop in pairs(drops) do -- get cooked output of current drops
local stack = ItemStack(drop)
local output = minetest.get_craft_result({
method = "cooking",
width = 1,
items = {drop}
})
for _, name in pairs(lavastuff.blacklisted_items) do
if name == drop then
return old_handle_node_drops(pos, drops, digger)
end
end
2018-10-17 16:49:18 -07:00
-- if we have cooked result then add to new list
2019-02-01 18:32:34 -08:00
if output and output.item and not output.item:is_empty() and output.time <= lavastuff.cook_limit then
2018-10-17 16:49:18 -07:00
table.insert(hot_drops,
ItemStack({
name = output.item:get_name(),
count = output.item:to_table().count,
})
)
else -- if not then return normal drops
table.insert(hot_drops, stack)
end
end
return old_handle_node_drops(pos, hot_drops, digger)
end
end
lavastuff.burn_drops("lavastuff:sword")
lavastuff.burn_drops("lavastuff:axe")
lavastuff.burn_drops("lavastuff:shovel")
--
2017-10-29 16:32:37 -07:00
-- Crafitems
--
minetest.register_craftitem("lavastuff:ingot", {
2019-03-27 14:29:36 -07:00
description = S("Lava Ingot"),
2018-10-17 16:34:43 -07:00
inventory_image = "lavastuff_ingot.png",
2017-10-28 01:06:04 -07:00
})
2017-11-16 10:45:07 +10:00
minetest.register_craft({
type = "shapeless",
output = "lavastuff:ingot",
2017-11-16 10:45:07 +10:00
recipe = {"default:mese_crystal", "lavastuff:orb"}
2017-10-27 12:29:35 -07:00
})
2017-10-29 16:32:37 -07:00
--
-- Crafitem Crafts
--
2017-11-16 10:45:07 +10:00
if not minetest.get_modpath("mobs_monster") then
minetest.register_craftitem("lavastuff:orb", {
2019-03-27 14:29:36 -07:00
description = S("Lava Orb"),
2018-10-17 16:34:43 -07:00
inventory_image = "zmobs_lava_orb.png"
2017-11-16 10:45:07 +10:00
})
minetest.register_alias("mobs:lava_orb", "lavastuff:orb")
minetest.register_craft({
output = "lavastuff:orb",
2018-10-17 16:34:43 -07:00
recipe = {
2019-01-04 20:47:52 -08:00
{"", "bucket:bucket_lava", ""},
2018-10-17 16:34:43 -07:00
{"bucket:bucket_lava", "default:mese_crystal", "bucket:bucket_lava"},
2019-01-04 20:47:52 -08:00
{"", "bucket:bucket_lava", ""}
},
replacements = {{"bucket:bucket_lava", "bucket:bucket_empty 4"}}
2017-11-16 10:45:07 +10:00
})
else
2017-11-16 10:45:07 +10:00
minetest.register_alias("lavastuff:orb", "mobs:lava_orb")
end
2017-10-29 16:32:37 -07:00
--
-- Tools
--
2017-10-08 17:49:28 -07:00
minetest.register_tool("lavastuff:sword", {
2019-02-05 14:30:10 -08:00
description = S("Lava Sword"),
2018-10-17 16:34:43 -07:00
inventory_image = "lavastuff_sword.png",
tool_capabilities = {
full_punch_interval = 0.6,
max_drop_level = 1,
groupcaps = {
snappy = {
2019-01-27 20:04:53 -08:00
times = {1.7, 0.7, 0.25},
uses = 50,
maxlevel = 3
},
},
2019-01-27 20:04:53 -08:00
damage_groups = {fleshy = 10, burns = 1},
},
2019-03-25 14:48:19 -07:00
on_place = lavastuff.tool_fire_func,
2018-10-17 16:34:43 -07:00
sound = {breaks = "default_tool_breaks"},
2017-10-08 17:49:28 -07:00
})
2018-10-17 16:34:43 -07:00
if not minetest.get_modpath("mobs_monster") then
2018-10-17 16:34:43 -07:00
minetest.register_alias("mobs:pick_lava", "lavastuff:pick")
2018-10-17 16:34:43 -07:00
minetest.register_tool("lavastuff:pick", {
2019-02-05 14:30:10 -08:00
description = S("Lava Pickaxe"),
2018-10-17 16:34:43 -07:00
inventory_image = "lavastuff_pick.png",
tool_capabilities = {
2019-01-27 20:04:53 -08:00
burns = true, -- fire_plus support
2018-10-17 16:34:43 -07:00
full_punch_interval = 0.7,
max_drop_level = 3,
2018-10-17 16:34:43 -07:00
groupcaps={
cracky = {
times = {[1] = 1.8, [2] = 0.8, [3] = 0.40},
uses = 40,
maxlevel = 3
},
2018-10-17 16:34:43 -07:00
},
2019-01-27 20:04:53 -08:00
damage_groups = {fleshy = 6, burns = 1},
2018-10-17 16:34:43 -07:00
},
2019-03-25 14:48:19 -07:00
on_place = lavastuff.tool_fire_func,
2018-10-17 16:34:43 -07:00
})
2018-10-17 16:34:43 -07:00
-- Lava Pick (restores autosmelt functionality)
2018-10-17 16:49:18 -07:00
lavastuff.burn_drops("lavastuff:pick")
else
2018-10-17 16:34:43 -07:00
minetest.register_alias("lavastuff:pick", "mobs:pick_lava")
minetest.register_tool(":mobs:pick_lava", {
2019-02-05 14:30:10 -08:00
description = S("Lava Pickaxe"),
2018-10-17 16:34:43 -07:00
inventory_image = "lavastuff_pick.png",
tool_capabilities = {
2019-01-27 20:04:53 -08:00
burns = true, -- fire_plus support
2018-10-17 16:34:43 -07:00
full_punch_interval = 0.7,
max_drop_level = 3,
2018-10-17 16:34:43 -07:00
groupcaps={
cracky = {
times = {[1] = 1.8, [2] = 0.8, [3] = 0.40},
uses = 40,
maxlevel = 3
},
2018-10-17 16:34:43 -07:00
},
2019-01-27 20:04:53 -08:00
damage_groups = {fleshy = 6, burns = 1},
2018-10-17 16:34:43 -07:00
},
2019-03-25 14:48:19 -07:00
on_place = lavastuff.tool_fire_func,
2018-10-17 16:34:43 -07:00
})
2017-11-15 15:55:40 -08:00
end
2018-10-17 16:34:43 -07:00
2017-10-29 16:32:37 -07:00
minetest.register_tool("lavastuff:shovel", {
2019-02-05 14:30:10 -08:00
description = S("Lava Shovel"),
2018-10-17 16:34:43 -07:00
inventory_image = "lavastuff_shovel.png",
wield_image = "lavastuff_shovel.png^[transformR90",
tool_capabilities = {
full_punch_interval = 1.0,
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-03-25 14:48:19 -07:00
on_place = lavastuff.tool_fire_func,
2018-10-17 16:34:43 -07:00
sound = {breaks = "default_tool_breaks"},
2017-10-29 16:32:37 -07:00
})
2018-10-17 16:34:43 -07:00
2017-10-29 16:32:37 -07:00
minetest.register_tool("lavastuff:axe", {
2019-02-05 14:30:10 -08:00
description = S("Lava Axe"),
2018-10-17 16:34:43 -07:00
inventory_image = "lavastuff_axe.png",
tool_capabilities = {
full_punch_interval = 0.8,
max_drop_level = 1,
groupcaps = {
choppy = {
times = {[1] = 2.00, [2] = 0.80, [3] = 0.40},
uses = 40,
maxlevel = 3
},
},
2019-01-27 20:04:53 -08:00
damage_groups = {fleshy = 7, burns = 1},
},
2019-03-25 14:48:19 -07:00
on_place = lavastuff.tool_fire_func,
2018-10-17 16:34:43 -07:00
sound = {breaks = "default_tool_breaks"},
2017-10-29 16:32:37 -07:00
})
--
-- Tool Crafts
--
2017-10-08 17:49:28 -07:00
minetest.register_craft({
output = "lavastuff:sword",
2018-10-17 16:34:43 -07:00
recipe = {
{"lavastuff:ingot"},
{"lavastuff:ingot"},
{"default:obsidian_shard"},
2018-10-17 16:34:43 -07:00
}
2017-10-08 17:49:28 -07:00
})
2018-10-17 16:34:43 -07:00
2017-11-15 15:55:40 -08:00
minetest.register_craft({
2018-10-17 16:34:43 -07:00
output = "lavastuff:pick",
recipe = {
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
{"", "default:obsidian_shard", ""},
{"", "default:obsidian_shard", ""},
}
2017-11-15 15:55:40 -08:00
})
2018-10-17 16:34:43 -07:00
2017-10-29 16:32:37 -07:00
minetest.register_craft({
output = "lavastuff:shovel",
2018-10-17 16:34:43 -07:00
recipe = {
{"lavastuff:ingot"},
{"default:obsidian_shard"},
{"default:obsidian_shard"},
2018-10-17 16:34:43 -07:00
}
2017-10-08 17:49:28 -07:00
})
2018-10-17 16:34:43 -07:00
2017-10-08 17:49:28 -07:00
minetest.register_craft({
output = "lavastuff:axe",
2018-10-17 16:34:43 -07:00
recipe = {
{"lavastuff:ingot", "lavastuff:ingot", ""},
{"lavastuff:ingot", "default:obsidian_shard", ""},
{"", "default:obsidian_shard", ""},
2018-10-17 16:34:43 -07:00
}
2017-10-08 17:49:28 -07:00
})
2018-10-17 16:34:43 -07:00
if minetest.get_modpath("mobs_monster") then
2018-10-17 16:34:43 -07:00
minetest.clear_craft({
recipe = {
{"mobs:lava_orb", "mobs:lava_orb", "mobs:lava_orb"},
{"", "default:obsidian_shard", ""},
{"", "default:obsidian_shard", ""},
}
})
2017-11-15 15:55:40 -08:00
end
2017-10-29 16:32:37 -07:00
--
-- Armor
--
2017-11-15 23:09:46 -08:00
if minetest.get_modpath("3d_armor") then
armor:register_armor("lavastuff:helmet", {
2019-02-05 14:30:10 -08:00
description = S("Lava Helmet"),
2018-10-17 16:34:43 -07:00
inventory_image = "lavastuff_inv_helmet.png",
groups = {armor_head=1, armor_heal=12, armor_use=100, armor_fire=10},
armor_groups = {fleshy=15},
damage_groups = {cracky=2, snappy=1, level=3},
2018-10-17 16:34:43 -07:00
wear = 0,
})
armor:register_armor("lavastuff:chestplate", {
2019-02-05 14:30:10 -08:00
description = S("Lava Chestplate"),
2018-10-17 16:34:43 -07:00
inventory_image = "lavastuff_inv_chestplate.png",
groups = {armor_torso=1, armor_heal=12, armor_use=100, armor_fire=10},
armor_groups = {fleshy=20},
damage_groups = {cracky=2, snappy=1, level=3},
2018-10-17 16:34:43 -07:00
wear = 0,
})
armor:register_armor("lavastuff:leggings", {
2019-02-05 14:30:10 -08:00
description = S("Lava Leggings"),
2018-10-17 16:34:43 -07:00
inventory_image = "lavastuff_inv_leggings.png",
groups = {armor_legs=1, armor_heal=12, armor_use=100, armor_fire=10},
armor_groups = {fleshy=20},
damage_groups = {cracky=2, snappy=1, level=3},
2018-10-17 16:34:43 -07:00
wear = 0,
})
armor:register_armor("lavastuff:boots", {
2019-02-05 14:30:10 -08:00
description = S("Lava Boots"),
2018-10-17 16:34:43 -07:00
inventory_image = "lavastuff_inv_boots.png",
groups = {armor_feet=1, armor_heal=12, armor_use=100, armor_fire=10, physics_jump=0.5, physics_speed = 1},
armor_groups = {fleshy=15},
damage_groups = {cracky=2, snappy=1, level=3},
2018-10-17 16:34:43 -07:00
wear = 0,
})
armor:register_armor("lavastuff:shield", {
2019-02-05 14:30:10 -08:00
description = S("Lava Shield"),
2018-10-17 16:34:43 -07:00
inventory_image = "lavastuff_inven_shield.png",
groups = {armor_shield=1, armor_heal=12, armor_use=100, armor_fire=10},
armor_groups = {fleshy=20},
damage_groups = {cracky=2, snappy=1, level=3},
2018-10-17 16:34:43 -07:00
wear = 0,
})
2017-11-15 23:09:46 -08:00
end
2019-01-25 16:43:12 -08:00
--
-- Armor Crafts
--
2017-10-29 16:32:37 -07:00
2017-11-15 23:09:46 -08:00
if minetest.get_modpath("3d_armor") then
2018-10-17 16:34:43 -07:00
minetest.register_craft({
output = "lavastuff:helmet",
2018-10-17 16:34:43 -07:00
recipe = {
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
{"lavastuff:ingot", "", "lavastuff:ingot"},
{"", "", ""},
2018-10-17 16:34:43 -07:00
}
})
minetest.register_craft({
output = "lavastuff:chestplate",
2018-10-17 16:34:43 -07:00
recipe = {
{"lavastuff:ingot", "", "lavastuff:ingot"},
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
2018-10-17 16:34:43 -07:00
}
})
minetest.register_craft({
output = "lavastuff:leggings",
2018-10-17 16:34:43 -07:00
recipe = {
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
{"lavastuff:ingot", "", "lavastuff:ingot"},
{"lavastuff:ingot", "", "lavastuff:ingot"},
2018-10-17 16:34:43 -07:00
}
})
minetest.register_craft({
output = "lavastuff:boots",
2018-10-17 16:34:43 -07:00
recipe = {
{"lavastuff:ingot", "", "lavastuff:ingot"},
{"lavastuff:ingot", "", "lavastuff:ingot"},
2018-10-17 16:34:43 -07:00
}
})
minetest.register_craft({
output = "lavastuff:shield",
2018-10-17 16:34:43 -07:00
recipe = {
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
{"", "lavastuff:ingot", ""},
2018-10-17 16:34:43 -07:00
}
})
2017-11-15 23:09:46 -08:00
end
2017-10-29 16:32:37 -07:00
2018-10-17 16:34:43 -07:00
--
-- Nodes
--
minetest.register_node ("lavastuff:block", {
2019-02-05 14:30:10 -08:00
description = S("Lava Block"),
2018-10-17 16:34:43 -07:00
tiles = {"lavastuff_block.png"},
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
2019-01-25 16:38:58 -08:00
groups = {cracky = 2, level = 2},
2019-03-27 14:29:36 -07:00
light_source = 7,
2018-10-17 16:34:43 -07:00
})
minetest.register_craft({
type = "shapeless",
output = "lavastuff:ingot 9",
recipe = {"lavastuff:block"}
2018-10-17 16:34:43 -07:00
})
minetest.register_craft({
output = "lavastuff:block",
2018-10-17 16:34:43 -07:00
recipe = {
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
2018-10-17 16:34:43 -07:00
}
})
2017-10-29 16:32:37 -07:00
2019-01-25 16:38:58 -08:00
if not minetest.get_modpath("moreblocks") then
stairs.register_stair_and_slab(
"lava",
"lavastuff:block",
{cracky = 2, level = 2},
{"lavastuff_block.png"},
2019-02-05 14:30:10 -08:00
S("Lava Stair"),
S("Lava Slab"),
2019-01-25 16:38:58 -08:00
default.node_sound_stone_defaults(),
true
)
else
stairsplus:register_all("lavastuff", "lava", "lavastuff:ingot", {
description = "Lava",
tiles = {"lavastuff_block.png"},
groups = {cracky = 2, level = 2},
2019-03-27 14:29:36 -07:00
light_source = 7,
2019-01-25 16:38:58 -08:00
sounds = default.node_sound_wood_defaults(),
})
end
2017-11-16 20:16:01 -08:00
--
--Toolranks support
--
if minetest.get_modpath("toolranks") then
minetest.override_item("lavastuff:sword", {
2019-02-05 14:30:10 -08:00
description = toolranks.create_description(S("Lava Sword"), 0, 1),
original_description = S("Lava Sword"),
2018-10-17 16:34:43 -07:00
after_use = toolranks.new_afteruse
})
minetest.override_item("lavastuff:pick", {
2019-02-05 14:30:10 -08:00
description = toolranks.create_description(S("Lava Pickaxe"), 0, 1),
original_description = S("Lava Pickaxe"),
2018-10-17 16:34:43 -07:00
after_use = toolranks.new_afteruse
})
minetest.override_item("lavastuff:axe", {
2019-02-05 14:30:10 -08:00
description = toolranks.create_description(S("Lava Axe"), 0, 1),
original_description = S("Lava Axe"),
2018-10-17 16:34:43 -07:00
after_use = toolranks.new_afteruse
})
minetest.override_item("lavastuff:shovel", {
2019-02-05 14:30:10 -08:00
description = toolranks.create_description(S("Lava Shovel"), 0, 1),
original_description = S("Lava Shovel"),
2018-10-17 16:34:43 -07:00
after_use = toolranks.new_afteruse
})
2017-11-16 20:16:01 -08:00
end
--
2019-03-25 14:48:19 -07:00
-- Lava in a Bottle
--
2019-03-25 14:48:19 -07:00
minetest.register_node("lavastuff:lava_in_a_bottle", {
2019-03-27 14:29:36 -07:00
description = S("Lava in a Bottle"),
2019-03-25 14:48:19 -07:00
drawtype = "plantlike",
tiles = {{
name = "lavastuff_lava_in_a_bottle.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0
}
}},
inventory_image = "lavastuff_lava_in_a_bottle.png^[verticalframe:2:0",
wield_image = "lavastuff_lava_in_a_bottle.png^[verticalframe:2:0",
paramtype = "light",
2019-03-25 15:01:16 -07:00
light_source = 8,
2019-03-25 14:48:19 -07:00
is_ground_content = false,
walkable = false,
2019-03-25 14:48:19 -07:00
selection_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
},
groups = {vessel = 1, dig_immediate = 3, attached_node = 1},
sounds = default.node_sound_glass_defaults(),
})
2019-03-25 14:48:19 -07:00
minetest.register_craft({
output = "lavastuff:lava_in_a_bottle",
recipe = {
{"", "bucket:bucket_lava"},
{"", "vessels:glass_bottle"},
},
replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}}
})