From 4b0494062e78580fcf9f9f3b9898ecf0bde12a84 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 3 Jun 2012 18:32:26 +0300 Subject: [PATCH] Add fire visualization to minimal furnace menu --- games/minimal/mods/default/init.lua | 36 +++++++++++------- .../textures/default_furnace_fire_bg.png | Bin 0 -> 313 bytes .../textures/default_furnace_fire_fg.png | Bin 0 -> 865 bytes 3 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 games/minimal/mods/default/textures/default_furnace_fire_bg.png create mode 100644 games/minimal/mods/default/textures/default_furnace_fire_fg.png diff --git a/games/minimal/mods/default/init.lua b/games/minimal/mods/default/init.lua index b117befb..643995c9 100644 --- a/games/minimal/mods/default/init.lua +++ b/games/minimal/mods/default/init.lua @@ -1245,6 +1245,14 @@ minetest.register_node("default:chest_locked", { 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", { description = "Furnace", tile_images = {"default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png", @@ -1255,12 +1263,7 @@ minetest.register_node("default:furnace", { sounds = default.node_sound_stone_defaults(), on_construct = function(pos) local meta = minetest.env:get_meta(pos) - meta:set_string("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("formspec", default.furnace_inactive_formspec) meta:set_string("infotext", "Furnace") local inv = meta:get_inventory() inv:set_size("fuel", 1) @@ -1281,12 +1284,7 @@ minetest.register_node("default:furnace_active", { sounds = default.node_sound_stone_defaults(), on_construct = function(pos) local meta = minetest.env:get_meta(pos) - meta:set_string("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("formspec", default.furnace_inactive_formspec) meta:set_string("infotext", "Furnace"); local inv = meta:get_inventory() inv:set_size("fuel", 1) @@ -1358,8 +1356,18 @@ minetest.register_abm({ end 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") + 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 end @@ -1378,6 +1386,7 @@ minetest.register_abm({ if fuel.time <= 0 then meta:set_string("infotext","Furnace out of fuel") hacky_swap_node(pos,"default:furnace") + meta:set_string("formspec", default.furnace_inactive_formspec) return end @@ -1385,6 +1394,7 @@ minetest.register_abm({ if was_active then meta:set_string("infotext","Furnace is empty") hacky_swap_node(pos,"default:furnace") + meta:set_string("formspec", default.furnace_inactive_formspec) end return end diff --git a/games/minimal/mods/default/textures/default_furnace_fire_bg.png b/games/minimal/mods/default/textures/default_furnace_fire_bg.png new file mode 100644 index 0000000000000000000000000000000000000000..1272e101e5f5fb5e3c78f21f4e7bcf40c1c60c12 GIT binary patch literal 313 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgf4Q*#L2(>w<>RSTlaYFmWY$#R`~Q4>GskuB;>9a|_PZJzxiK1x zR!D}e_;Bc};X=u#b&Z9q&Ez*NEX4~i5|4&)EAxV3ZVowB*%f-Vj%Q(YlJYeyOnByNHZ1#N863)AF-LgxDE1UEGNeiwZ>=w literal 0 HcmV?d00001 diff --git a/games/minimal/mods/default/textures/default_furnace_fire_fg.png b/games/minimal/mods/default/textures/default_furnace_fire_fg.png new file mode 100644 index 0000000000000000000000000000000000000000..fbb19df7438f6c806af40f6357bd0b28761c0169 GIT binary patch literal 865 zcmV-n1D^beP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyh& z4*(X+Ro>PB00QAjL_t(I%Z-y=Xp?so#()1eZ)5W2&1dt`q)SqX^p#aBL+h-Jj(sqY zsW^5wh9csPH$yhYP!OhqUU;{QO{56h#2d9Ja|0R7iZ)>cW{G#?m}CNWKu z<3%Z2=D>4xc+TND&vW2`*Qldm4@bkESK;y>aHkXbKccaegRzuj)m$A6nR2eMpjLp3 z{YYp zP(IQp05gxK0cd=&R(yUZn%*R|J_vw45hnh2g2v_^w8+Jb0?16w5!>R!yC=frr*28C z3oJj$ijy2lQIw$PWe9JK zVFZK7#7FY)jR%CcucOsheL-LbJm}+P+Nll?)AxyfxE{6Rx?)&Z8VpeAUxJ)Qqtj;a z^k*#22GLz{wBn&R1i<_ut2#a%TSv$L#Etgu?+PF{_YlK!(QWfFeQT0-wF1d*vc*ZX zhzHGX*pTCI2|%S%rkR;1c|4~8znEg@y{^~m>_KxGODRlQI zap*DN7{o?PiqR6;lTk6F0oW2p^R(y+3PlsvEOb%%v&hzO_EDW4BlojHNqSgr|B+?$ z&^GXv;Zl}oA4G9jQMfh*8%&TG`CAismweFc;M$p++