forked from nalc/nalc_game
Fire visualization in furnace menu
This commit is contained in:
parent
dd9b33db67
commit
fcaacdb4ad
|
@ -1268,6 +1268,14 @@ minetest.register_node("default:chest_locked", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
default.furnace_inactive_formspec =
|
||||||
|
"invsize[8,9;]"..
|
||||||
|
"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;dst;5,1;2,2;]"..
|
||||||
|
"list[current_player;main;0,5;8,4;]"
|
||||||
|
|
||||||
minetest.register_node("default:furnace", {
|
minetest.register_node("default:furnace", {
|
||||||
description = "Furnace",
|
description = "Furnace",
|
||||||
tile_images = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
|
tile_images = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
|
||||||
|
@ -1278,12 +1286,7 @@ minetest.register_node("default:furnace", {
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec", default.furnace_inactive_formspec)
|
||||||
"invsize[8,9;]"..
|
|
||||||
"list[current_name;fuel;2,3;1,1;]"..
|
|
||||||
"list[current_name;src;2,1;1,1;]"..
|
|
||||||
"list[current_name;dst;5,1;2,2;]"..
|
|
||||||
"list[current_player;main;0,5;8,4;]")
|
|
||||||
meta:set_string("infotext", "Furnace")
|
meta:set_string("infotext", "Furnace")
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("fuel", 1)
|
inv:set_size("fuel", 1)
|
||||||
|
@ -1306,7 +1309,7 @@ minetest.register_node("default:furnace", {
|
||||||
|
|
||||||
minetest.register_node("default:furnace_active", {
|
minetest.register_node("default:furnace_active", {
|
||||||
description = "Furnace",
|
description = "Furnace",
|
||||||
tile_images = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
|
tile_images = {"default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png",
|
||||||
"default_furnace_side.png", "default_furnace_side.png", "default_furnace_front_active.png"},
|
"default_furnace_side.png", "default_furnace_side.png", "default_furnace_front_active.png"},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
light_source = 8,
|
light_source = 8,
|
||||||
|
@ -1316,12 +1319,7 @@ minetest.register_node("default:furnace_active", {
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec", default.furnace_inactive_formspec)
|
||||||
"invsize[8,9;]"..
|
|
||||||
"list[current_name;fuel;2,3;1,1;]"..
|
|
||||||
"list[current_name;src;2,1;1,1;]"..
|
|
||||||
"list[current_name;dst;5,1;2,2;]"..
|
|
||||||
"list[current_player;main;0,5;8,4;]")
|
|
||||||
meta:set_string("infotext", "Furnace");
|
meta:set_string("infotext", "Furnace");
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("fuel", 1)
|
inv:set_size("fuel", 1)
|
||||||
|
@ -1405,8 +1403,18 @@ minetest.register_abm({
|
||||||
end
|
end
|
||||||
|
|
||||||
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
||||||
meta:set_string("infotext","Furnace active: "..(meta:get_float("fuel_time")/meta:get_float("fuel_totaltime")*100).."%")
|
local percent = math.floor(meta:get_float("fuel_time") /
|
||||||
|
meta:get_float("fuel_totaltime") * 100)
|
||||||
|
meta:set_string("infotext","Furnace active: "..percent.."%")
|
||||||
hacky_swap_node(pos,"default:furnace_active")
|
hacky_swap_node(pos,"default:furnace_active")
|
||||||
|
meta:set_string("formspec",
|
||||||
|
"invsize[8,9;]"..
|
||||||
|
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||||
|
(100-percent)..":default_furnace_fire_fg.png]"..
|
||||||
|
"list[current_name;fuel;2,3;1,1;]"..
|
||||||
|
"list[current_name;src;2,1;1,1;]"..
|
||||||
|
"list[current_name;dst;5,1;2,2;]"..
|
||||||
|
"list[current_player;main;0,5;8,4;]")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1425,6 +1433,7 @@ minetest.register_abm({
|
||||||
if fuel.time <= 0 then
|
if fuel.time <= 0 then
|
||||||
meta:set_string("infotext","Furnace out of fuel")
|
meta:set_string("infotext","Furnace out of fuel")
|
||||||
hacky_swap_node(pos,"default:furnace")
|
hacky_swap_node(pos,"default:furnace")
|
||||||
|
meta:set_string("formspec", default.furnace_inactive_formspec)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1432,6 +1441,7 @@ minetest.register_abm({
|
||||||
if was_active then
|
if was_active then
|
||||||
meta:set_string("infotext","Furnace is empty")
|
meta:set_string("infotext","Furnace is empty")
|
||||||
hacky_swap_node(pos,"default:furnace")
|
hacky_swap_node(pos,"default:furnace")
|
||||||
|
meta:set_string("formspec", default.furnace_inactive_formspec)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
BIN
mods/default/textures/default_furnace_fire_bg.png
Normal file
BIN
mods/default/textures/default_furnace_fire_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 313 B |
BIN
mods/default/textures/default_furnace_fire_fg.png
Normal file
BIN
mods/default/textures/default_furnace_fire_fg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 865 B |
Loading…
Reference in New Issue
Block a user