3
3
-- Formspecs
4
4
--
5
5
6
- local function active_formspec (fuel_percent , item_percent )
7
- local formspec =
8
- " size[8,8.5]" ..
6
+ function default .get_furnace_active_formspec (fuel_percent , item_percent )
7
+ return " size[8,8.5]" ..
9
8
default .gui_bg ..
10
9
default .gui_bg_img ..
11
10
default .gui_slots ..
@@ -25,28 +24,28 @@ local function active_formspec(fuel_percent, item_percent)
25
24
" listring[context;fuel]" ..
26
25
" listring[current_player;main]" ..
27
26
default .get_hotbar_bg (0 , 4.25 )
28
- return formspec
29
27
end
30
28
31
- local inactive_formspec =
32
- " size[8,8.5]" ..
33
- default .gui_bg ..
34
- default .gui_bg_img ..
35
- default .gui_slots ..
36
- " list[context;src;2.75,0.5;1,1;]" ..
37
- " list[context;fuel;2.75,2.5;1,1;]" ..
38
- " image[2.75,1.5;1,1;default_furnace_fire_bg.png]" ..
39
- " image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]" ..
40
- " list[context;dst;4.75,0.96;2,2;]" ..
41
- " list[current_player;main;0,4.25;8,1;]" ..
42
- " list[current_player;main;0,5.5;8,3;8]" ..
43
- " listring[context;dst]" ..
44
- " listring[current_player;main]" ..
45
- " listring[context;src]" ..
46
- " listring[current_player;main]" ..
47
- " listring[context;fuel]" ..
48
- " listring[current_player;main]" ..
49
- default .get_hotbar_bg (0 , 4.25 )
29
+ function default .get_furnace_inactive_formspec ()
30
+ return " size[8,8.5]" ..
31
+ default .gui_bg ..
32
+ default .gui_bg_img ..
33
+ default .gui_slots ..
34
+ " list[context;src;2.75,0.5;1,1;]" ..
35
+ " list[context;fuel;2.75,2.5;1,1;]" ..
36
+ " image[2.75,1.5;1,1;default_furnace_fire_bg.png]" ..
37
+ " image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]" ..
38
+ " list[context;dst;4.75,0.96;2,2;]" ..
39
+ " list[current_player;main;0,4.25;8,1;]" ..
40
+ " list[current_player;main;0,5.5;8,3;8]" ..
41
+ " listring[context;dst]" ..
42
+ " listring[current_player;main]" ..
43
+ " listring[context;src]" ..
44
+ " listring[current_player;main]" ..
45
+ " listring[context;fuel]" ..
46
+ " listring[current_player;main]" ..
47
+ default .get_hotbar_bg (0 , 4.25 )
48
+ end
50
49
51
50
--
52
51
-- Node callback functions that are the same for active and inactive furnace
@@ -190,7 +189,7 @@ local function furnace_node_timer(pos, elapsed)
190
189
--
191
190
-- Update formspec, infotext and node
192
191
--
193
- local formspec = inactive_formspec
192
+ local formspec
194
193
local item_state
195
194
local item_percent = 0
196
195
if cookable then
@@ -216,20 +215,22 @@ local function furnace_node_timer(pos, elapsed)
216
215
active = " active "
217
216
local fuel_percent = math.floor (fuel_time / fuel_totaltime * 100 )
218
217
fuel_state = fuel_percent .. " %"
219
- formspec = active_formspec (fuel_percent , item_percent )
218
+ formspec = default . get_furnace_active_formspec (fuel_percent , item_percent )
220
219
swap_node (pos , " default:furnace_active" )
221
220
-- make sure timer restarts automatically
222
221
result = true
223
222
else
224
223
if not fuellist [1 ]:is_empty () then
225
224
fuel_state = " 0%"
226
225
end
226
+ formspec = default .get_furnace_inactive_formspec ()
227
227
swap_node (pos , " default:furnace" )
228
228
-- stop timer on the inactive furnace
229
229
minetest .get_node_timer (pos ):stop ()
230
230
end
231
231
232
- local infotext = " Furnace " .. active .. " (Item: " .. item_state .. " ; Fuel: " .. fuel_state .. " )"
232
+ local infotext = " Furnace " .. active .. " (Item: " .. item_state ..
233
+ " ; Fuel: " .. fuel_state .. " )"
233
234
234
235
--
235
236
-- Set meta values
@@ -266,7 +267,7 @@ minetest.register_node("default:furnace", {
266
267
267
268
on_construct = function (pos )
268
269
local meta = minetest .get_meta (pos )
269
- meta :set_string (" formspec" , inactive_formspec )
270
+ meta :set_string (" formspec" , default . get_furnace_inactive_formspec () )
270
271
local inv = meta :get_inventory ()
271
272
inv :set_size (' src' , 1 )
272
273
inv :set_size (' fuel' , 1 )
@@ -327,4 +328,3 @@ minetest.register_node("default:furnace_active", {
327
328
allow_metadata_inventory_move = allow_metadata_inventory_move ,
328
329
allow_metadata_inventory_take = allow_metadata_inventory_take ,
329
330
})
330
-
0 commit comments