lavastuff-cd2025/init.lua

431 lines
11 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
2020-03-20 10:04:15 -07:00
S = minetest.get_translator(minetest.get_current_modname())
else
2020-03-20 10:04:15 -07:00
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
2020-03-20 10:04:15 -07:00
lavastuff.cook_limit = 15
end
if lavastuff.enable_tool_fire ~= false then
2020-03-20 10:04:15 -07:00
lavastuff.enable_tool_fire = true
end
lavastuff.blacklisted_items = { -- Items lava tools will not smelt
2020-03-20 10:04:15 -07:00
"default:mese_crystal",
"default:mese",
}
local fire_node
if minetest.get_modpath("fire") then
fire_node = "fire:basic_flame"
elseif minetest.get_modpath("mcl_fire") then
fire_node = "mcl_fire:fire"
elseif minetest.get_modpath("nc_fire") then
fire_node = "nc_fire:fire"
end
if minetest.registered_items[fire_node] and lavastuff.enable_tool_fire == true then
2020-03-20 10:04:15 -07:00
function lavastuff.tool_fire_func(itemstack, user, pointed)
local name = user:get_player_name()
if pointed.type == "node" then
local node = minetest.get_node(pointed.under)
local node_under = node.name
local def = minetest.registered_nodes[node_under]
if def.on_rightclick then
return def.on_rightclick(pointed.under, node, user, itemstack, pointed)
end
if minetest.is_protected(pointed.under, name) then return end
if def.on_ignite then
def.on_ignite(pointed.under, user)
elseif minetest.get_item_group(node_under, "flammable") >= 1
and minetest.get_node(pointed.above).name == "air" then
minetest.set_node(pointed.above, {name = fire_node})
2020-03-20 10:04:15 -07:00
end
end
end
2019-03-25 14:48:19 -07:00
end
2018-10-17 16:49:18 -07:00
function lavastuff.burn_drops(tool)
2020-03-20 10:04:15 -07:00
local old_handle_node_drops = minetest.handle_node_drops
2020-08-13 16:34:39 -07:00
function minetest.handle_node_drops(pos, drops, digger, ...)
2020-05-22 14:55:43 -07:00
if not digger or digger:get_wielded_item():get_name() ~= (tool) then
2020-08-13 16:34:39 -07:00
return old_handle_node_drops(pos, drops, digger, ...)
2020-03-20 10:04:15 -07:00
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
2020-08-13 16:34:39 -07:00
return old_handle_node_drops(pos, drops, digger, ...)
2020-03-20 10:04:15 -07:00
end
end
-- if we have cooked result then add to new list
if output and output.item and not output.item:is_empty() and output.time <= lavastuff.cook_limit then
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
2020-08-13 16:34:39 -07:00
return old_handle_node_drops(pos, hot_drops, digger, ...)
2020-03-20 10:04:15 -07:00
end
2018-10-17 16:49:18 -07:00
end
lavastuff.burn_drops("lavastuff:sword")
lavastuff.burn_drops("lavastuff:axe")
lavastuff.burn_drops("lavastuff:shovel")
--
-- Crafitem
2017-10-29 16:32:37 -07:00
--
minetest.register_craftitem("lavastuff:ingot", {
2020-03-20 10:04:15 -07:00
description = S("Lava Ingot"),
inventory_image = "lavastuff_ingot.png",
light_source = 7, -- Texture will have a glow when dropped
2020-05-20 20:05:13 -07:00
groups = {craftitem = 1},
2017-10-28 01:06:04 -07:00
})
2017-11-16 10:45:07 +10:00
2017-10-29 16:32:37 -07:00
--
-- Orb compat and registration
2017-10-29 16:32:37 -07:00
--
2017-11-16 10:45:07 +10:00
if not minetest.get_modpath("mobs_monster") then
2020-03-20 10:04:15 -07:00
minetest.register_craftitem("lavastuff:orb", {
description = S("Lava Orb"),
inventory_image = "zmobs_lava_orb.png",
light_source = 7, -- Texture will have a glow when dropped
2020-05-20 20:05:13 -07:00
groups = {craftitem = 1},
2020-03-20 10:04:15 -07:00
})
minetest.register_alias("mobs:lava_orb", "lavastuff:orb")
else
2020-03-20 10:04:15 -07:00
minetest.register_alias("lavastuff:orb", "mobs:lava_orb")
end
2017-10-29 16:32:37 -07:00
2020-05-20 20:05:13 -07:00
--
-- Armor Crafts
--
if minetest.get_modpath("3d_armor") or minetest.get_modpath("mcl_armor") then
minetest.register_craft({
output = "lavastuff:helmet",
recipe = {
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
{"lavastuff:ingot", "", "lavastuff:ingot"},
{"", "", ""},
}
})
minetest.register_craft({
output = "lavastuff:chestplate",
recipe = {
{"lavastuff:ingot", "", "lavastuff:ingot"},
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
}
})
minetest.register_craft({
output = "lavastuff:leggings",
recipe = {
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
{"lavastuff:ingot", "", "lavastuff:ingot"},
{"lavastuff:ingot", "", "lavastuff:ingot"},
}
})
minetest.register_craft({
output = "lavastuff:boots",
recipe = {
{"lavastuff:ingot", "", "lavastuff:ingot"},
{"lavastuff:ingot", "", "lavastuff:ingot"},
}
})
if not minetest.get_modpath("mcl_armor") then
minetest.register_craft({
output = "lavastuff:shield",
recipe = {
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
{"lavastuff:ingot", "lavastuff:ingot", "lavastuff:ingot"},
{"", "lavastuff:ingot", ""},
}
})
end
end
2017-10-29 16:32:37 -07:00
--
-- Tools
--
2017-10-08 17:49:28 -07:00
minetest.register_tool("lavastuff:sword", {
2020-03-20 10:04:15 -07:00
description = S("Lava Sword"),
inventory_image = "lavastuff_sword.png",
2020-05-20 20:05:13 -07:00
groups = {weapon = 1, sword = 1},
2020-03-20 10:04:15 -07:00
light_source = 7, -- Texture will have a glow when dropped
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},
},
2020-03-20 10:04:15 -07:00
on_place = lavastuff.tool_fire_func,
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
2020-03-20 10:04:15 -07:00
minetest.register_alias("mobs:pick_lava", "lavastuff:pick")
minetest.register_tool("lavastuff:pick", {
description = S("Lava Pickaxe"),
inventory_image = "lavastuff_pick.png",
2020-05-20 20:05:13 -07:00
groups = {tool = 1, pickaxe = 1},
2020-03-20 10:04:15 -07:00
light_source = 7, -- Texture will have a glow when dropped
tool_capabilities = {
burns = true, -- fire_plus support
full_punch_interval = 0.7,
max_drop_level = 3,
groupcaps={
cracky = {
times = {[1] = 1.8, [2] = 0.8, [3] = 0.40},
uses = 40,
maxlevel = 3
},
},
damage_groups = {fleshy = 6, burns = 1},
},
on_place = lavastuff.tool_fire_func,
})
2018-10-17 16:34:43 -07:00
-- Lava Pick (restores autosmelt functionality)
2020-03-20 10:04:15 -07:00
lavastuff.burn_drops("lavastuff:pick")
else
2020-03-20 10:04:15 -07:00
minetest.register_alias("lavastuff:pick", "mobs:pick_lava")
minetest.register_tool(":mobs:pick_lava", {
description = S("Lava Pickaxe"),
inventory_image = "lavastuff_pick.png",
2020-05-20 20:05:13 -07:00
groups = {tool = 1, pickaxe = 1},
2020-03-20 10:04:15 -07:00
light_source = 7, -- Texture will have a glow when dropped
tool_capabilities = {
burns = true, -- fire_plus support
full_punch_interval = 0.7,
max_drop_level = 3,
groupcaps={
cracky = {
times = {[1] = 1.8, [2] = 0.8, [3] = 0.40},
uses = 40,
maxlevel = 3
},
},
damage_groups = {fleshy = 6, burns = 1},
},
on_place = lavastuff.tool_fire_func,
})
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", {
2020-03-20 10:04:15 -07:00
description = S("Lava Shovel"),
inventory_image = "lavastuff_shovel.png",
wield_image = "lavastuff_shovel.png^[transformR90",
2020-05-20 20:05:13 -07:00
groups = {tool = 1, shovel = 1},
2020-03-20 10:04:15 -07:00
light_source = 7, -- Texture will have a glow when dropped
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},
},
2020-03-20 10:04:15 -07:00
on_place = lavastuff.tool_fire_func,
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", {
2020-03-20 10:04:15 -07:00
description = S("Lava Axe"),
inventory_image = "lavastuff_axe.png",
2020-05-20 20:05:13 -07:00
groups = {tool = 1, axe = 1},
2020-03-20 10:04:15 -07:00
light_source = 7, -- Texture will have a glow when dropped
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},
},
2020-03-20 10:04:15 -07:00
on_place = lavastuff.tool_fire_func,
sound = {breaks = "default_tool_breaks"},
2017-10-29 16:32:37 -07:00
})
--
2020-05-20 20:05:13 -07:00
-- Tool Craft
2017-10-29 16:32:37 -07:00
--
if minetest.get_modpath("mobs_monster") then
2020-03-20 10:04:15 -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
2018-10-17 16:34:43 -07:00
--
-- Nodes
--
2020-01-16 22:43:26 -06:00
minetest.register_node("lavastuff:block", {
2020-03-20 10:04:15 -07:00
description = S("Lava Block"),
tiles = {"lavastuff_block.png"},
is_ground_content = false,
sounds = default and default.node_sound_stone_defaults(),
2020-03-20 10:04:15 -07:00
groups = {cracky = 2, level = 2},
light_source = 4,
2018-10-17 16:34:43 -07:00
})
if not minetest.get_modpath("moreblocks") and minetest.get_modpath("stairs") then
2020-03-20 10:04:15 -07:00
stairs.register_stair_and_slab(
"lava",
"lavastuff:block",
{cracky = 2, level = 2},
{"lavastuff_block.png"},
S("Lava Stair"),
S("Lava Slab"),
default.node_sound_stone_defaults(),
true,
S("Inner Lava Stair"),
S("Outer Lava Stair")
2020-03-20 10:04:15 -07:00
)
end
if minetest.get_modpath("moreblocks") then
2020-03-20 10:04:15 -07:00
stairsplus:register_all("lavastuff", "lava", "lavastuff:ingot", {
description = "Lava",
tiles = {"lavastuff_block.png"},
groups = {cracky = 2, level = 2},
light_source = 4,
sounds = default and default.node_sound_stone_defaults(),
2020-03-20 10:04:15 -07:00
})
2019-01-25 16:38:58 -08:00
end
2017-11-16 20:16:01 -08:00
--
--Toolranks support
--
if minetest.get_modpath("toolranks") then
2020-03-20 10:04:15 -07:00
minetest.override_item("lavastuff:sword", {
description = toolranks.create_description(S("Lava Sword"), 0, 1),
original_description = S("Lava Sword"),
after_use = toolranks.new_afteruse
})
minetest.override_item("lavastuff:pick", {
description = toolranks.create_description(S("Lava Pickaxe"), 0, 1),
original_description = S("Lava Pickaxe"),
after_use = toolranks.new_afteruse
})
minetest.override_item("lavastuff:axe", {
description = toolranks.create_description(S("Lava Axe"), 0, 1),
original_description = S("Lava Axe"),
after_use = toolranks.new_afteruse
})
minetest.override_item("lavastuff:shovel", {
description = toolranks.create_description(S("Lava Shovel"), 0, 1),
original_description = S("Lava Shovel"),
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 = {{
2020-03-20 10:04:15 -07:00
name = "lavastuff_lava_in_a_bottle.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0
}
}},
2019-03-25 14:48:19 -07:00
inventory_image = "lavastuff_lava_in_a_bottle.png^[verticalframe:2:0",
wield_image = "lavastuff_lava_in_a_bottle.png^[verticalframe:2:0",
2020-03-20 10:04:15 -07:00
paramtype = "light",
light_source = 9,
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 and default.node_sound_glass_defaults(),
})
2019-03-25 14:48:19 -07:00
--
-- Register crafts based on current game
--
if minetest.get_modpath("default") and minetest.get_modpath("bucket") and minetest.get_modpath("vessels") then
dofile(minetest.get_modpath("lavastuff") .. "/compat/mtg.lua")
2020-05-20 20:05:13 -07:00
elseif minetest.get_modpath("mcl_core") then
dofile(minetest.get_modpath("lavastuff") .. "/compat/mcl2.lua")
end