mirror of
https://github.com/minetest-mods/technic.git
synced 2025-03-20 11:20:31 +01:00
Add progress indicator for fuel-fired alloy furnace
This commit is contained in:
parent
d33b067896
commit
8056cc27d6
@ -13,20 +13,24 @@ minetest.register_craft({
|
|||||||
})
|
})
|
||||||
|
|
||||||
local machine_name = S("Fuel-Fired Alloy Furnace")
|
local machine_name = S("Fuel-Fired Alloy Furnace")
|
||||||
local formspec =
|
local function make_formspec(fuel_percent, progress_percentage)
|
||||||
"size[8,9]"..
|
return "size[8,9]"..
|
||||||
"label[0,0;"..machine_name.."]"..
|
"label[0,0;"..machine_name.."]"..
|
||||||
"image[2,2;1,1;default_furnace_fire_bg.png]"..
|
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||||
"list[current_name;fuel;2,3;1,1;]"..
|
fuel_percent..":default_furnace_fire_fg.png]"..
|
||||||
"list[current_name;src;2,1;2,1;]"..
|
"list[current_name;fuel;2,3;1,1;]"..
|
||||||
"list[current_name;dst;5,1;2,2;]"..
|
"list[current_name;src;2,1;2,1;]"..
|
||||||
"list[current_player;main;0,5;8,4;]"..
|
"list[current_name;dst;5,1;2,2;]"..
|
||||||
"listring[current_name;dst]"..
|
"list[current_player;main;0,5;8,4;]"..
|
||||||
"listring[current_player;main]"..
|
"listring[current_name;dst]"..
|
||||||
"listring[current_name;src]"..
|
"listring[current_player;main]"..
|
||||||
"listring[current_player;main]"..
|
"listring[current_name;src]"..
|
||||||
"listring[current_name;fuel]"..
|
"listring[current_player;main]"..
|
||||||
"listring[current_player;main]"
|
"listring[current_name;fuel]"..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
"image[4,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
|
||||||
|
progress_percentage..":gui_furnace_arrow_fg.png^[transformR270]"
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("technic:coal_alloy_furnace", {
|
minetest.register_node("technic:coal_alloy_furnace", {
|
||||||
description = machine_name,
|
description = machine_name,
|
||||||
@ -39,7 +43,7 @@ minetest.register_node("technic:coal_alloy_furnace", {
|
|||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", formspec)
|
meta:set_string("formspec", make_formspec(0, 0))
|
||||||
meta:set_string("infotext", machine_name)
|
meta:set_string("infotext", machine_name)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("fuel", 1)
|
inv:set_size("fuel", 1)
|
||||||
@ -124,21 +128,11 @@ minetest.register_abm({
|
|||||||
meta:get_float("fuel_totaltime") * 100)
|
meta:get_float("fuel_totaltime") * 100)
|
||||||
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..percent.."%)")
|
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..percent.."%)")
|
||||||
technic.swap_node(pos, "technic:coal_alloy_furnace_active")
|
technic.swap_node(pos, "technic:coal_alloy_furnace_active")
|
||||||
meta:set_string("formspec",
|
if result and result.time ~= 0 then
|
||||||
"size[8,9]"..
|
meta:set_string("formspec", make_formspec(100 - percent, 100.0 * meta:get_int("src_time") / result.time))
|
||||||
"label[0,0;"..machine_name.."]"..
|
else
|
||||||
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
meta:set_string("formspec", make_formspec(100 - percent, 0))
|
||||||
(100 - percent)..":default_furnace_fire_fg.png]"..
|
end
|
||||||
"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;]"..
|
|
||||||
"listring[current_name;dst]"..
|
|
||||||
"listring[current_player;main]"..
|
|
||||||
"listring[current_name;src]"..
|
|
||||||
"listring[current_player;main]"..
|
|
||||||
"listring[current_name;fuel]"..
|
|
||||||
"listring[current_player;main]")
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -148,7 +142,7 @@ minetest.register_abm({
|
|||||||
if was_active then
|
if was_active then
|
||||||
meta:set_string("infotext", S("%s is empty"):format(machine_name))
|
meta:set_string("infotext", S("%s is empty"):format(machine_name))
|
||||||
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
||||||
meta:set_string("formspec", formspec)
|
meta:set_string("formspec", make_formspec(0, 0))
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -165,7 +159,7 @@ minetest.register_abm({
|
|||||||
if fuel.time <= 0 then
|
if fuel.time <= 0 then
|
||||||
meta:set_string("infotext", S("%s Out Of Fuel"):format(machine_name))
|
meta:set_string("infotext", S("%s Out Of Fuel"):format(machine_name))
|
||||||
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
||||||
meta:set_string("formspec", formspec)
|
meta:set_string("formspec", make_formspec(0, 0))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user