2013-07-17 21:34:35 +02: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 17:58:52 +02:00
|
|
|
-- Fuel driven alloy furnace. This uses no EUs:
|
2013-07-17 21:34:35 +02:00
|
|
|
|
2013-10-30 18:45:32 +01:00
|
|
|
local S = technic.getter
|
2013-07-17 21:34:35 +02: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'},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("technic:coal_alloy_furnace", {
|
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 17:58:52 +02:00
|
|
|
description = S("Fuel-Fired Alloy Furnace"),
|
2013-11-27 18:28:56 +01: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 21:34:35 +02:00
|
|
|
paramtype2 = "facedir",
|
|
|
|
groups = {cracky=2},
|
|
|
|
legacy_facedir_simple = true,
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
on_construct = function(pos)
|
|
|
|
local meta = minetest.env:get_meta(pos)
|
|
|
|
meta:set_string("formspec", coal_alloy_furnace_formspec)
|
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 17:58:52 +02:00
|
|
|
meta:set_string("infotext", S("Fuel-Fired Alloy Furnace"))
|
2013-07-17 21:34:35 +02:00
|
|
|
local inv = meta:get_inventory()
|
|
|
|
inv:set_size("fuel", 1)
|
|
|
|
inv:set_size("src", 1)
|
|
|
|
inv:set_size("src2", 1)
|
|
|
|
inv:set_size("dst", 4)
|
|
|
|
end,
|
2013-11-27 18:28:56 +01: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 21:34:35 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("technic:coal_alloy_furnace_active", {
|
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 17:58:52 +02:00
|
|
|
description = S("Fuel-Fired Alloy Furnace"),
|
2013-11-27 18:28:56 +01: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 21:34:35 +02: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 18:28:56 +01: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 21:34:35 +02: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()
|
|
|
|
local recipe = nil
|
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 17:58:52 +02:00
|
|
|
local machine_name = S("Fuel-Fired Alloy Furnace")
|
2013-07-17 21:34:35 +02:00
|
|
|
local formspec =
|
|
|
|
"size[8,9]"..
|
2013-10-30 18:45:32 +01:00
|
|
|
"label[0,0;"..machine_name.."]"..
|
2013-07-17 21:34:35 +02:00
|
|
|
"image[2,2;1,1;default_furnace_fire_bg.png]"..
|
|
|
|
"list[current_name;fuel;2,3;1,1;]"..
|
|
|
|
"list[current_name;src;2,1;1,1;]"..
|
|
|
|
"list[current_name;src2;3,1;1,1;]"..
|
|
|
|
"list[current_name;dst;5,1;2,2;]"..
|
|
|
|
"list[current_player;main;0,5;8,4;]"
|
|
|
|
|
|
|
|
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
|
|
|
|
local srcstack = inv:get_stack("src", 1)
|
|
|
|
local src2stack = inv:get_stack("src2", 1)
|
|
|
|
local recipe = technic.get_alloy_recipe(srcstack, src2stack)
|
|
|
|
if srcstack:get_name() > src2stack:get_name() then
|
|
|
|
local temp = srcstack
|
|
|
|
srcstack = src2stack
|
|
|
|
src2stack = temp
|
|
|
|
end
|
|
|
|
|
|
|
|
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)
|
|
|
|
if recipe then
|
|
|
|
meta:set_int("src_time", meta:get_int("src_time") + 1)
|
|
|
|
if meta:get_int("src_time") == 6 then
|
|
|
|
-- check if there's room for output in "dst" list
|
|
|
|
local dst_stack = ItemStack(recipe.output)
|
|
|
|
if inv:room_for_item("dst", dst_stack) then
|
|
|
|
srcstack:take_item(recipe.input[1].count)
|
|
|
|
inv:set_stack("src", 1, srcstack)
|
|
|
|
src2stack:take_item(recipe.input[2].count)
|
|
|
|
inv:set_stack("src2", 1, src2stack)
|
|
|
|
inv:add_item("dst", dst_stack)
|
|
|
|
end
|
|
|
|
meta:set_int("src_time", 0)
|
|
|
|
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 18:45:32 +01:00
|
|
|
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..percent.."%)")
|
2013-12-11 02:14:39 +01:00
|
|
|
technic.swap_node(pos, "technic:coal_alloy_furnace_active")
|
2013-07-17 21:34:35 +02:00
|
|
|
meta:set_string("formspec",
|
|
|
|
"size[8,9]"..
|
2013-10-30 18:45:32 +01:00
|
|
|
"label[0,0;"..machine_name.."]"..
|
2013-07-17 21:34:35 +02:00
|
|
|
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
2013-10-30 18:45:32 +01:00
|
|
|
(100 - percent)..":default_furnace_fire_fg.png]"..
|
2013-07-17 21:34:35 +02:00
|
|
|
"list[current_name;fuel;2,3;1,1;]"..
|
|
|
|
"list[current_name;src;2,1;1,1;]"..
|
|
|
|
"list[current_name;src2;3,1;1,1;]"..
|
|
|
|
"list[current_name;dst;5,1;2,2;]"..
|
|
|
|
"list[current_player;main;0,5;8,4;]")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- FIXME: Make this look more like the electrical version.
|
|
|
|
-- This code refetches the recipe to see if it can be done again after the iteration
|
|
|
|
srcstack = inv:get_stack("src", 1)
|
|
|
|
srcstack = inv:get_stack("src2", 1)
|
|
|
|
local recipe = technic.get_alloy_recipe(srcstack, src2stack)
|
|
|
|
|
|
|
|
if recipe then
|
|
|
|
if was_active then
|
|
|
|
meta:set_string("infotext", "Furnace is empty")
|
2013-12-11 02:14:39 +01:00
|
|
|
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
2013-07-17 21:34:35 +02:00
|
|
|
meta:set_string("formspec", formspec)
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Next take a hard look at the fuel situation
|
|
|
|
local fuel = nil
|
|
|
|
local fuellist = inv:get_list("fuel")
|
|
|
|
|
|
|
|
if fuellist then
|
|
|
|
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
|
|
|
|
end
|
|
|
|
|
|
|
|
if fuel.time <= 0 then
|
2013-10-30 18:45:32 +01:00
|
|
|
meta:set_string("infotext", S("%s Out Of Fuel"):format(machine_name))
|
2013-12-11 02:14:39 +01:00
|
|
|
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
2013-07-17 21:34:35 +02:00
|
|
|
meta:set_string("formspec", formspec)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
meta:set_string("fuel_totaltime", fuel.time)
|
|
|
|
meta:set_string("fuel_time", 0)
|
|
|
|
|
|
|
|
local stack = inv:get_stack("fuel", 1)
|
|
|
|
stack:take_item()
|
|
|
|
inv:set_stack("fuel", 1, stack)
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|