2013-07-17 15:34:35 -04:00
|
|
|
|
Rationalise machine terminology
All electrically-powered machines now consistently indicate their
tier (supply voltage) in their names. As this implies that they are
electrically powered, the furnaces no longer have "Electric" in their
names. The fuel-fired equivalents of electric machines, which exist
for alloy furnace and furnace, now say "Fuel-Fired" to distinguish them.
(The fuel-fired alloy furnace used to say "Coal", which was inaccurate
because it uses any fuel. The fuel-fired furnace, from the default mod,
used to just be called "Furnace", which is ambiguous.)
Electric power generators now consistently indicate their tier and have
the word "Generator" in their names. This makes their purpose much
clearer, and makes obvious craft guide searches produce useful results.
The fuel-fired generators, previously just (ambiguously) called
"Generator", are now explicitly "Fuel-Fired".
2014-06-20 16:58:52 +01:00
|
|
|
-- Fuel driven alloy furnace. This uses no EUs:
|
2013-07-17 15:34:35 -04:00
|
|
|
|
2013-10-30 13:45:32 -04:00
|
|
|
local S = technic.getter
|
2013-07-17 15:34:35 -04:00
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = 'technic:coal_alloy_furnace',
|
|
|
|
recipe = {
|
|
|
|
{'default:brick', 'default:brick', 'default:brick'},
|
|
|
|
{'default:brick', '', 'default:brick'},
|
|
|
|
{'default:brick', 'default:brick', 'default:brick'},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2014-07-06 16:25:53 +01:00
|
|
|
local machine_name = S("Fuel-Fired Alloy Furnace")
|
|
|
|
local formspec =
|
|
|
|
"size[8,9]"..
|
|
|
|
"label[0,0;"..machine_name.."]"..
|
|
|
|
"image[2,2;1,1;default_furnace_fire_bg.png]"..
|
|
|
|
"list[current_name;fuel;2,3;1,1;]"..
|
|
|
|
"list[current_name;src;2,1;2,1;]"..
|
|
|
|
"list[current_name;dst;5,1;2,2;]"..
|
|
|
|
"list[current_player;main;0,5;8,4;]"
|
|
|
|
|
2013-07-17 15:34:35 -04:00
|
|
|
minetest.register_node("technic:coal_alloy_furnace", {
|
2014-07-06 16:25:53 +01:00
|
|
|
description = machine_name,
|
2013-11-27 12:28:56 -05:00
|
|
|
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png",
|
|
|
|
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png",
|
|
|
|
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front.png"},
|
2013-07-17 15:34:35 -04:00
|
|
|
paramtype2 = "facedir",
|
|
|
|
groups = {cracky=2},
|
|
|
|
legacy_facedir_simple = true,
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
on_construct = function(pos)
|
2014-11-30 12:45:42 -05:00
|
|
|
local meta = minetest.get_meta(pos)
|
2014-07-06 16:25:53 +01:00
|
|
|
meta:set_string("formspec", formspec)
|
|
|
|
meta:set_string("infotext", machine_name)
|
2013-07-17 15:34:35 -04:00
|
|
|
local inv = meta:get_inventory()
|
|
|
|
inv:set_size("fuel", 1)
|
2014-07-03 15:57:39 +02:00
|
|
|
inv:set_size("src", 2)
|
2013-07-17 15:34:35 -04:00
|
|
|
inv:set_size("dst", 4)
|
|
|
|
end,
|
2013-11-27 12:28:56 -05:00
|
|
|
can_dig = technic.machine_can_dig,
|
|
|
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
|
|
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
|
|
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
2013-07-17 15:34:35 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("technic:coal_alloy_furnace_active", {
|
2014-07-06 16:25:53 +01:00
|
|
|
description = machine_name,
|
2013-11-27 12:28:56 -05:00
|
|
|
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png",
|
|
|
|
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png",
|
|
|
|
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front_active.png"},
|
2013-07-17 15:34:35 -04:00
|
|
|
paramtype2 = "facedir",
|
|
|
|
light_source = 8,
|
|
|
|
drop = "technic:coal_alloy_furnace",
|
|
|
|
groups = {cracky=2, not_in_creative_inventory=1},
|
|
|
|
legacy_facedir_simple = true,
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
2013-11-27 12:28:56 -05:00
|
|
|
can_dig = technic.machine_can_dig,
|
|
|
|
allow_metadata_inventory_put = technic.machine_inventory_put,
|
|
|
|
allow_metadata_inventory_take = technic.machine_inventory_take,
|
|
|
|
allow_metadata_inventory_move = technic.machine_inventory_move,
|
2013-07-17 15:34:35 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"technic:coal_alloy_furnace", "technic:coal_alloy_furnace_active"},
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local inv = meta:get_inventory()
|
2014-07-03 15:57:39 +02:00
|
|
|
|
|
|
|
if inv:get_size("src") == 1 then -- Old furnace -> convert it
|
|
|
|
inv:set_size("src", 2)
|
|
|
|
inv:set_stack("src", 2, inv:get_stack("src2", 1))
|
|
|
|
inv:set_size("src2", 0)
|
|
|
|
end
|
|
|
|
|
2013-07-17 15:34:35 -04:00
|
|
|
local recipe = nil
|
|
|
|
|
|
|
|
for i, name in pairs({
|
|
|
|
"fuel_totaltime",
|
|
|
|
"fuel_time",
|
|
|
|
"src_totaltime",
|
|
|
|
"src_time"}) do
|
|
|
|
if not meta:get_float(name) then
|
|
|
|
meta:set_float(name, 0.0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Get what to cook if anything
|
2014-07-03 15:57:39 +02:00
|
|
|
local result = technic.get_recipe("alloy", inv:get_list("src"))
|
2013-07-17 15:34:35 -04:00
|
|
|
|
|
|
|
local was_active = false
|
|
|
|
|
|
|
|
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
|
|
|
was_active = true
|
|
|
|
meta:set_int("fuel_time", meta:get_int("fuel_time") + 1)
|
2014-07-03 15:57:39 +02:00
|
|
|
if result then
|
2013-07-17 15:34:35 -04:00
|
|
|
meta:set_int("src_time", meta:get_int("src_time") + 1)
|
2014-07-03 15:57:39 +02:00
|
|
|
if meta:get_int("src_time") >= result.time then
|
2013-07-17 15:34:35 -04:00
|
|
|
meta:set_int("src_time", 0)
|
2014-07-03 15:57:39 +02:00
|
|
|
local result_stack = ItemStack(result.output)
|
|
|
|
if inv:room_for_item("dst", result_stack) then
|
|
|
|
inv:set_list("src", result.new_input)
|
|
|
|
inv:add_item("dst", result_stack)
|
|
|
|
end
|
2013-07-17 15:34:35 -04:00
|
|
|
end
|
|
|
|
else
|
|
|
|
meta:set_int("src_time", 0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
|
|
|
local percent = math.floor(meta:get_float("fuel_time") /
|
|
|
|
meta:get_float("fuel_totaltime") * 100)
|
2013-10-30 13:45:32 -04:00
|
|
|
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..percent.."%)")
|
2013-12-10 20:14:39 -05:00
|
|
|
technic.swap_node(pos, "technic:coal_alloy_furnace_active")
|
2013-07-17 15:34:35 -04:00
|
|
|
meta:set_string("formspec",
|
|
|
|
"size[8,9]"..
|
2013-10-30 13:45:32 -04:00
|
|
|
"label[0,0;"..machine_name.."]"..
|
2013-07-17 15:34:35 -04:00
|
|
|
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
2013-10-30 13:45:32 -04:00
|
|
|
(100 - percent)..":default_furnace_fire_fg.png]"..
|
2013-07-17 15:34:35 -04:00
|
|
|
"list[current_name;fuel;2,3;1,1;]"..
|
2014-07-03 15:57:39 +02:00
|
|
|
"list[current_name;src;2,1;2,1;]"..
|
2013-07-17 15:34:35 -04:00
|
|
|
"list[current_name;dst;5,1;2,2;]"..
|
|
|
|
"list[current_player;main;0,5;8,4;]")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2014-07-03 15:57:39 +02:00
|
|
|
local recipe = technic.get_recipe("alloy", inv:get_list("src"))
|
2013-07-17 15:34:35 -04:00
|
|
|
|
2014-07-03 15:57:39 +02:00
|
|
|
if not recipe then
|
2013-07-17 15:34:35 -04:00
|
|
|
if was_active then
|
2014-07-03 15:57:39 +02:00
|
|
|
meta:set_string("infotext", S("%s is empty"):format(machine_name))
|
2013-12-10 20:14:39 -05:00
|
|
|
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
2013-07-17 15:34:35 -04:00
|
|
|
meta:set_string("formspec", formspec)
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Next take a hard look at the fuel situation
|
|
|
|
local fuel = nil
|
2014-07-18 17:08:05 +01:00
|
|
|
local afterfuel
|
2013-07-17 15:34:35 -04:00
|
|
|
local fuellist = inv:get_list("fuel")
|
|
|
|
|
|
|
|
if fuellist then
|
2014-07-18 17:08:05 +01:00
|
|
|
fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
|
2013-07-17 15:34:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
if fuel.time <= 0 then
|
2013-10-30 13:45:32 -04:00
|
|
|
meta:set_string("infotext", S("%s Out Of Fuel"):format(machine_name))
|
2013-12-10 20:14:39 -05:00
|
|
|
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
2013-07-17 15:34:35 -04:00
|
|
|
meta:set_string("formspec", formspec)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
meta:set_string("fuel_totaltime", fuel.time)
|
|
|
|
meta:set_string("fuel_time", 0)
|
|
|
|
|
2014-07-18 17:08:05 +01:00
|
|
|
inv:set_stack("fuel", 1, afterfuel.items[1])
|
2013-07-17 15:34:35 -04:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|