Skip to content

Commit 6e5468b

Browse files
committed
Rework coal alloy furnace ABM a bit
1 parent 1fe4b32 commit 6e5468b

File tree

1 file changed

+32
-39
lines changed

1 file changed

+32
-39
lines changed

technic/machines/other/coal_alloy_furnace.lua

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,10 @@ minetest.register_abm({
107107
chance = 1,
108108
action = function(pos, node, active_object_count, active_object_count_wider)
109109
local meta = minetest.get_meta(pos)
110-
local inv = meta:get_inventory()
111-
112-
if inv:get_size("src") == 1 then -- Old furnace -> convert it
113-
inv:set_size("src", 2)
114-
inv:set_stack("src", 2, inv:get_stack("src2", 1))
115-
inv:set_size("src2", 0)
110+
local inv = meta:get_inventory()
111+
local src_list = not inv:get_list("src")
112+
if not src_list then
113+
return
116114
end
117115

118116
for i, name in pairs({
@@ -126,7 +124,7 @@ minetest.register_abm({
126124
end
127125

128126
-- Get what to cook if anything
129-
local recipe = technic.get_recipe("alloy", inv:get_list("src"))
127+
local recipe = technic.get_recipe("alloy", src_list)
130128

131129
local was_active = false
132130

@@ -150,32 +148,32 @@ minetest.register_abm({
150148
meta:set_string("infotext", S("@1 Active", machine_name).." ("..percent.."%)")
151149
technic.swap_node(pos, "technic:coal_alloy_furnace_active")
152150
meta:set_string("formspec",
153-
size..
154-
"label[0,0;"..machine_name.."]"..
155-
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
156-
(100 - percent)..":default_furnace_fire_fg.png]"..
157-
"list[context;fuel;2,3;1,1;]"..
158-
"list[context;src;2,1;2,1;]"..
159-
"list[context;dst;5,1;2,2;]"..
160-
161-
(minetest.get_modpath("mcl_formspec") and
162-
mcl_formspec.get_itemslot_bg(2,3,1,1)..
163-
mcl_formspec.get_itemslot_bg(2,1,2,1)..
164-
mcl_formspec.get_itemslot_bg(5,1,2,2)..
165-
-- player inventory
166-
"list[current_player;main;0,4.5;9,3;9]"..
167-
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
168-
"list[current_player;main;0,7.74;9,1;]"..
169-
mcl_formspec.get_itemslot_bg(0,7.74,9,1)
170-
or "list[current_player;main;0,5;8,4;]")..
171-
172-
-- listrings
173-
"listring[context;dst]"..
174-
"listring[current_player;main]"..
175-
"listring[context;src]"..
176-
"listring[current_player;main]"..
177-
"listring[context;fuel]"..
178-
"listring[current_player;main]")
151+
size..
152+
"label[0,0;"..machine_name.."]"..
153+
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
154+
(100 - percent)..":default_furnace_fire_fg.png]"..
155+
"list[context;fuel;2,3;1,1;]"..
156+
"list[context;src;2,1;2,1;]"..
157+
"list[context;dst;5,1;2,2;]"..
158+
159+
(minetest.get_modpath("mcl_formspec") and
160+
mcl_formspec.get_itemslot_bg(2,3,1,1)..
161+
mcl_formspec.get_itemslot_bg(2,1,2,1)..
162+
mcl_formspec.get_itemslot_bg(5,1,2,2)..
163+
-- player inventory
164+
"list[current_player;main;0,4.5;9,3;9]"..
165+
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
166+
"list[current_player;main;0,7.74;9,1;]"..
167+
mcl_formspec.get_itemslot_bg(0,7.74,9,1)
168+
or "list[current_player;main;0,5;8,4;]")..
169+
170+
-- listrings
171+
"listring[context;dst]"..
172+
"listring[current_player;main]"..
173+
"listring[context;src]"..
174+
"listring[current_player;main]"..
175+
"listring[context;fuel]"..
176+
"listring[current_player;main]")
179177
return
180178
end
181179

@@ -189,13 +187,8 @@ minetest.register_abm({
189187
end
190188

191189
-- Next take a hard look at the fuel situation
192-
local fuel = nil
193-
local afterfuel
194190
local fuellist = inv:get_list("fuel")
195-
196-
if fuellist then
197-
fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
198-
end
191+
local fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
199192

200193
if fuel.time <= 0 then
201194
meta:set_string("infotext", S("@1 Out Of Fuel", machine_name))

0 commit comments

Comments
 (0)