2017-02-26 15:21:49 -07:00
|
|
|
if not minetest.get_modpath("fire") then return end
|
|
|
|
|
2020-02-28 15:03:34 -07:00
|
|
|
local S = minetest.get_translator(minetest.get_current_modname())
|
2017-02-26 15:21:49 -07:00
|
|
|
|
2017-03-01 23:53:31 -07:00
|
|
|
local brasier_longdesc = S("A brasier for producing copious amounts of light and heat.")
|
2023-08-14 10:22:24 +03:00
|
|
|
|
|
|
|
-- luacheck: ignore
|
2017-03-01 23:53:31 -07:00
|
|
|
local brasier_usagehelp = S("To ignite the brasier place a flammable fuel in its inventory slot. A lump of coal will burn for about half an hour.")
|
|
|
|
|
2017-02-26 15:21:49 -07:00
|
|
|
local brasier_nodebox = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.25, 0, -0.25, 0.25, 0.125, 0.25}, -- base
|
|
|
|
{-0.375, 0.125, -0.375, 0.375, 0.25, 0.375}, -- mid
|
|
|
|
{-0.5, 0.25, -0.5, 0.5, 0.375, 0.5}, -- plat
|
|
|
|
{-0.5, 0.375, 0.375, 0.5, 0.5, 0.5}, -- edge
|
|
|
|
{-0.5, 0.375, -0.5, 0.5, 0.5, -0.375}, -- edge
|
|
|
|
{0.375, 0.375, -0.375, 0.5, 0.5, 0.375}, -- edge
|
|
|
|
{-0.5, 0.375, -0.375, -0.375, 0.5, 0.375}, -- edge
|
|
|
|
{0.25, -0.5, -0.375, 0.375, 0.125, -0.25}, -- leg
|
|
|
|
{-0.375, -0.5, 0.25, -0.25, 0.125, 0.375}, -- leg
|
|
|
|
{0.25, -0.5, 0.25, 0.375, 0.125, 0.375}, -- leg
|
|
|
|
{-0.375, -0.5, -0.375, -0.25, 0.125, -0.25}, -- leg
|
|
|
|
{-0.125, -0.0625, -0.125, 0.125, 0, 0.125}, -- bottom_knob
|
|
|
|
}
|
|
|
|
}
|
2017-02-26 20:44:50 -07:00
|
|
|
local brasier_selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.375, -0.5, -0.375, 0.375, 0.25, 0.375}, -- mid
|
|
|
|
{-0.5, 0.25, -0.5, 0.5, 0.5, 0.5}, -- plat
|
|
|
|
}
|
|
|
|
}
|
2017-02-26 15:21:49 -07:00
|
|
|
|
|
|
|
local brasier_burn = function(pos)
|
2017-02-26 21:59:29 -07:00
|
|
|
local pos_above = {x=pos.x, y=pos.y+1, z=pos.z}
|
|
|
|
local node_above = minetest.get_node(pos_above)
|
|
|
|
local timer = minetest.get_node_timer(pos)
|
2023-08-14 10:22:24 +03:00
|
|
|
|
|
|
|
-- already burning, don't burn a new thing.
|
|
|
|
if timer:is_started() and node_above.name == "fire:permanent_flame" then return end
|
|
|
|
|
2017-02-26 15:21:49 -07:00
|
|
|
local inv = minetest.get_inventory({type="node", pos=pos})
|
2023-11-19 19:32:08 +01:00
|
|
|
if not inv then return end -- Stop nodetimer
|
|
|
|
|
2017-02-26 15:21:49 -07:00
|
|
|
local item = inv:get_stack("fuel", 1)
|
|
|
|
local fuel_burned = minetest.get_craft_result({method="fuel", width=1, items={item:peek_item(1)}}).time
|
2023-08-14 10:22:24 +03:00
|
|
|
|
2017-02-26 20:58:22 -07:00
|
|
|
if fuel_burned > 0 and (node_above.name == "air" or node_above.name == "fire:permanent_flame") then
|
2017-02-26 15:21:49 -07:00
|
|
|
item:set_count(item:get_count() - 1)
|
|
|
|
inv:set_stack("fuel", 1, item)
|
2017-02-26 21:59:29 -07:00
|
|
|
|
2017-02-26 15:21:49 -07:00
|
|
|
timer:start(fuel_burned * 60) -- one minute of flame per second of burn time, for balance.
|
2023-08-14 10:22:24 +03:00
|
|
|
|
2017-02-26 15:21:49 -07:00
|
|
|
if node_above.name == "air" then
|
|
|
|
minetest.set_node(pos_above, {name = "fire:permanent_flame"})
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if node_above.name == "fire:permanent_flame" then
|
|
|
|
minetest.set_node(pos_above, {name = "air"})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-26 20:44:50 -07:00
|
|
|
local brasier_on_construct = function(pos)
|
|
|
|
local inv = minetest.get_meta(pos):get_inventory()
|
|
|
|
inv:set_size("fuel", 1)
|
2023-08-14 10:22:24 +03:00
|
|
|
|
2017-02-26 20:44:50 -07:00
|
|
|
local meta = minetest.get_meta(pos)
|
2023-08-14 10:22:24 +03:00
|
|
|
meta:set_string("formspec",
|
2017-02-26 20:44:50 -07:00
|
|
|
"size[8,5.3]" ..
|
|
|
|
default.gui_bg ..
|
|
|
|
default.gui_bg_img ..
|
|
|
|
default.gui_slots ..
|
|
|
|
"list[current_name;fuel;3.5,0;1,1;]" ..
|
|
|
|
"list[current_player;main;0,1.15;8,1;]" ..
|
|
|
|
"list[current_player;main;0,2.38;8,3;8]" ..
|
|
|
|
"listring[current_name;main]" ..
|
|
|
|
"listring[current_player;main]" ..
|
|
|
|
default.get_hotbar_bg(0,1.15)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
local brasier_on_destruct = function(pos, oldnode)
|
|
|
|
local pos_above = {x=pos.x, y=pos.y+1, z=pos.z}
|
|
|
|
local node_above = minetest.get_node(pos_above)
|
|
|
|
if node_above.name == "fire:permanent_flame" then
|
|
|
|
minetest.set_node(pos_above, {name = "air"})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local brasier_can_dig = function(pos, player)
|
|
|
|
local inv = minetest.get_meta(pos):get_inventory()
|
|
|
|
return inv:is_empty("fuel")
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Only allow fuel items to be placed in fuel
|
|
|
|
local brasier_allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
|
|
|
if listname == "fuel" then
|
|
|
|
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
|
|
|
|
return stack:get_count()
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
2017-02-26 15:21:49 -07:00
|
|
|
minetest.register_node("castle_lighting:brasier_floor", {
|
2017-02-26 20:44:50 -07:00
|
|
|
description = S("Floor Brasier"),
|
2017-03-01 23:53:31 -07:00
|
|
|
_doc_items_longdesc = brasier_longdesc,
|
|
|
|
_doc_items_usagehelp = brasier_usagehelp,
|
2017-02-26 15:21:49 -07:00
|
|
|
tiles = {
|
|
|
|
"castle_steel.png^(castle_coal_bed.png^[mask:castle_brasier_bed_mask.png)",
|
|
|
|
"castle_steel.png",
|
|
|
|
"castle_steel.png",
|
|
|
|
"castle_steel.png",
|
|
|
|
"castle_steel.png",
|
|
|
|
"castle_steel.png",
|
|
|
|
},
|
|
|
|
drawtype = "nodebox",
|
|
|
|
groups = {cracky=2},
|
|
|
|
paramtype = "light",
|
|
|
|
node_box = brasier_nodebox,
|
2017-02-26 20:44:50 -07:00
|
|
|
selection_box = brasier_selection_box,
|
2023-08-14 10:22:24 +03:00
|
|
|
|
2017-02-26 20:44:50 -07:00
|
|
|
on_construct = brasier_on_construct,
|
|
|
|
on_destruct = brasier_on_destruct,
|
|
|
|
can_dig = brasier_can_dig,
|
|
|
|
allow_metadata_inventory_put = brasier_allow_metadata_inventory_put,
|
|
|
|
on_metadata_inventory_put = brasier_burn,
|
|
|
|
on_timer = brasier_burn,
|
2017-02-26 15:21:49 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "castle_lighting:brasier_floor",
|
|
|
|
recipe = {
|
|
|
|
{"default:steel_ingot", "default:torch", "default:steel_ingot"},
|
|
|
|
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
|
|
|
}
|
2017-02-26 20:44:50 -07:00
|
|
|
})
|
|
|
|
|
2017-02-26 21:51:14 -07:00
|
|
|
if minetest.get_modpath("hopper") and hopper ~= nil and hopper.add_container ~= nil then
|
|
|
|
hopper:add_container({
|
|
|
|
{"top", "castle_lighting:brasier_floor", "fuel"},
|
|
|
|
{"bottom", "castle_lighting:brasier_floor", "fuel"},
|
|
|
|
{"side", "castle_lighting:brasier_floor", "fuel"},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2017-02-26 20:44:50 -07:00
|
|
|
------------------------------------------------------------------------------------------------------
|
|
|
|
-- Masonry brasiers
|
|
|
|
|
|
|
|
local materials
|
|
|
|
if minetest.get_modpath("castle_masonry") then
|
|
|
|
materials = castle_masonry.materials
|
|
|
|
else
|
2023-08-14 10:22:24 +03:00
|
|
|
materials = {{name="stonebrick", desc=S("Stonebrick"), tile="default_stone_brick.png",
|
|
|
|
craft_material="default:stonebrick"}}
|
2017-02-26 20:44:50 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
local get_material_properties = function(material)
|
|
|
|
local composition_def
|
|
|
|
local burn_time
|
|
|
|
if material.composition_material ~= nil then
|
|
|
|
composition_def = minetest.registered_nodes[material.composition_material]
|
|
|
|
burn_time = minetest.get_craft_result({method="fuel", width=1, items={ItemStack(material.composition_material)}}).time
|
|
|
|
else
|
|
|
|
composition_def = minetest.registered_nodes[material.craft_material]
|
|
|
|
burn_time = minetest.get_craft_result({method="fuel", width=1, items={ItemStack(material.craft_materia)}}).time
|
|
|
|
end
|
2023-08-14 10:22:24 +03:00
|
|
|
|
2017-02-26 20:44:50 -07:00
|
|
|
local tiles = material.tile
|
|
|
|
if tiles == nil then
|
|
|
|
tiles = composition_def.tile
|
|
|
|
elseif type(tiles) == "string" then
|
|
|
|
tiles = {tiles}
|
|
|
|
end
|
2023-08-14 10:22:24 +03:00
|
|
|
|
2017-02-26 20:44:50 -07:00
|
|
|
-- Apply bed of coals to the texture.
|
|
|
|
if table.getn(tiles) == 1 then
|
2023-08-14 10:22:24 +03:00
|
|
|
tiles = {tiles[1].."^(castle_coal_bed.png^[mask:castle_brasier_bed_mask.png)",
|
|
|
|
tiles[1], tiles[1], tiles[1], tiles[1], tiles[1]}
|
2017-02-26 20:44:50 -07:00
|
|
|
else
|
|
|
|
tiles[1] = tiles[1].."^(castle_coal_bed.png^[mask:castle_brasier_bed_mask.png)"
|
|
|
|
end
|
|
|
|
|
|
|
|
local desc = material.desc
|
|
|
|
if desc == nil then
|
|
|
|
desc = composition_def.description
|
|
|
|
end
|
2023-08-14 10:22:24 +03:00
|
|
|
|
2017-02-26 20:44:50 -07:00
|
|
|
return composition_def, burn_time, tiles, desc
|
|
|
|
end
|
|
|
|
|
|
|
|
local pillar_brasier_nodebox = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.375, 0.125, -0.375, 0.375, 0.25, 0.375}, -- mid
|
|
|
|
{-0.5, 0.25, -0.5, 0.5, 0.375, 0.5}, -- plat
|
|
|
|
{-0.5, 0.375, 0.375, 0.5, 0.5, 0.5}, -- edge
|
|
|
|
{-0.5, 0.375, -0.5, 0.5, 0.5, -0.375}, -- edge
|
|
|
|
{0.375, 0.375, -0.375, 0.5, 0.5, 0.375}, -- edge
|
|
|
|
{-0.5, 0.375, -0.375, -0.375, 0.5, 0.375}, -- edge
|
|
|
|
{-0.25,-0.5,-0.25,0.25,0.125,0.25}, -- support
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
local pillar_brasier_selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.375, 0.125, -0.375, 0.375, 0.25, 0.375}, -- mid
|
|
|
|
{-0.5, 0.25, -0.5, 0.5, 0.5, 0.5}, -- plat
|
|
|
|
{-0.25,-0.5,-0.25,0.25,0.125,0.25}, -- support
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
castle_lighting.register_pillar_brasier = function(material)
|
|
|
|
local composition_def, burn_time, tile, desc = get_material_properties(material)
|
2023-08-14 10:22:24 +03:00
|
|
|
-- No wooden brasiers, snow brasiers, or ice brasiers, alas.
|
|
|
|
if burn_time > 0 or composition_def.groups.puts_out_fire then return end
|
|
|
|
|
2017-02-26 20:50:00 -07:00
|
|
|
local crossbrace_connectable_groups = {}
|
|
|
|
for group, val in pairs(composition_def.groups) do
|
|
|
|
crossbrace_connectable_groups[group] = val
|
2023-08-14 10:22:24 +03:00
|
|
|
end
|
2017-02-26 20:50:00 -07:00
|
|
|
crossbrace_connectable_groups.crossbrace_connectable = 1
|
2023-08-14 10:22:24 +03:00
|
|
|
|
2017-02-26 20:44:50 -07:00
|
|
|
local mod_name = minetest.get_current_modname()
|
|
|
|
|
|
|
|
minetest.register_node(mod_name..":"..material.name.."_pillar_brasier", {
|
|
|
|
drawtype = "nodebox",
|
|
|
|
description = S("@1 Brasier", desc),
|
2017-03-01 23:53:31 -07:00
|
|
|
_doc_items_longdesc = brasier_longdesc,
|
|
|
|
_doc_items_usagehelp = brasier_usagehelp,
|
2017-02-26 20:44:50 -07:00
|
|
|
tiles = tile,
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2017-02-26 20:50:00 -07:00
|
|
|
groups = crossbrace_connectable_groups,
|
2017-02-26 20:44:50 -07:00
|
|
|
sounds = composition_def.sounds,
|
2023-08-14 10:22:24 +03:00
|
|
|
|
2017-02-26 20:44:50 -07:00
|
|
|
node_box = pillar_brasier_nodebox,
|
|
|
|
selection_box = pillar_brasier_selection_box,
|
2023-08-14 10:22:24 +03:00
|
|
|
|
2017-02-26 20:44:50 -07:00
|
|
|
on_construct = brasier_on_construct,
|
|
|
|
on_destruct = brasier_on_destruct,
|
|
|
|
can_dig = brasier_can_dig,
|
|
|
|
allow_metadata_inventory_put = brasier_allow_metadata_inventory_put,
|
|
|
|
on_metadata_inventory_put = brasier_burn,
|
|
|
|
on_timer = brasier_burn,
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = mod_name..":"..material.name.."_pillar_brasier 5",
|
|
|
|
recipe = {
|
|
|
|
{material.craft_material,"default:torch",material.craft_material},
|
|
|
|
{material.craft_material,material.craft_material,material.craft_material},
|
|
|
|
},
|
|
|
|
})
|
2023-08-14 10:22:24 +03:00
|
|
|
|
2017-02-26 21:51:14 -07:00
|
|
|
if minetest.get_modpath("hopper") and hopper ~= nil and hopper.add_container ~= nil then
|
|
|
|
hopper:add_container({
|
|
|
|
{"top", mod_name..":"..material.name.."_pillar_brasier", "fuel"},
|
|
|
|
{"bottom", mod_name..":"..material.name.."_pillar_brasier", "fuel"},
|
|
|
|
{"side", mod_name..":"..material.name.."_pillar_brasier", "fuel"},
|
|
|
|
})
|
|
|
|
end
|
2017-02-26 20:44:50 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
for _, material in pairs(materials) do
|
|
|
|
castle_lighting.register_pillar_brasier(material)
|
|
|
|
end
|