@@ -598,6 +598,21 @@ minetest.register_node("default:sign_wall", {
598
598
end ,
599
599
})
600
600
601
+ default .chest_formspec =
602
+ " size[8,9]" ..
603
+ " list[current_name;main;0,0;8,4;]" ..
604
+ " list[current_player;main;0,5;8,4;]"
605
+
606
+ function default .get_locked_chest_formspec (pos )
607
+ local spos = pos .x .. " ," .. pos .y .. " ," .. pos .z
608
+ local formspec =
609
+ " size[8,9]" ..
610
+ " list[nodemeta:" .. spos .. " ;main;0,0;8,4;]" ..
611
+ " list[current_player;main;0,5;8,4;]"
612
+ return formspec
613
+ end
614
+
615
+
601
616
minetest .register_node (" default:chest" , {
602
617
description = " Chest" ,
603
618
tiles = {" default_chest_top.png" , " default_chest_top.png" , " default_chest_side.png" ,
@@ -608,10 +623,7 @@ minetest.register_node("default:chest", {
608
623
sounds = default .node_sound_wood_defaults (),
609
624
on_construct = function (pos )
610
625
local meta = minetest .get_meta (pos )
611
- meta :set_string (" formspec" ,
612
- " size[8,9]" ..
613
- " list[current_name;main;0,0;8,4;]" ..
614
- " list[current_player;main;0,5;8,4;]" )
626
+ meta :set_string (" formspec" ,default .chest_formspec )
615
627
meta :set_string (" infotext" , " Chest" )
616
628
local inv = meta :get_inventory ()
617
629
inv :set_size (" main" , 8 * 4 )
@@ -716,15 +728,27 @@ minetest.register_node("default:chest_locked", {
716
728
on_rightclick = function (pos , node , clicker )
717
729
local meta = minetest .get_meta (pos )
718
730
if has_locked_chest_privilege (meta , clicker ) then
719
- local pos = pos . x .. " , " .. pos . y .. " , " .. pos . z
720
- minetest . show_formspec ( clicker :get_player_name (), " default:chest_locked " ,
721
- " size[8,9] " ..
722
- " list[nodemeta: " .. pos .. " ;main;0,0;8,4;] " ..
723
- " list[current_player;main;0,5;8,4;] " )
731
+ minetest . show_formspec (
732
+ clicker :get_player_name (),
733
+ " default:chest_locked " ,
734
+ default . get_locked_chest_formspec ( pos )
735
+ )
724
736
end
725
737
end ,
726
738
})
727
739
740
+ function default .get_furnace_active_formspec (pos , percent )
741
+ local formspec =
742
+ " size[8,9]" ..
743
+ " image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:" ..
744
+ (100 - percent ).. " :default_furnace_fire_fg.png]" ..
745
+ " list[current_name;fuel;2,3;1,1;]" ..
746
+ " list[current_name;src;2,1;1,1;]" ..
747
+ " list[current_name;dst;5,1;2,2;]" ..
748
+ " list[current_player;main;0,5;8,4;]"
749
+ return formspec
750
+ end
751
+
728
752
default .furnace_inactive_formspec =
729
753
" size[8,9]" ..
730
754
" image[2,2;1,1;default_furnace_fire_bg.png]" ..
@@ -937,14 +961,7 @@ minetest.register_abm({
937
961
meta :get_float (" fuel_totaltime" ) * 100 )
938
962
meta :set_string (" infotext" ," Furnace active: " .. percent .. " %" )
939
963
hacky_swap_node (pos ," default:furnace_active" )
940
- meta :set_string (" formspec" ,
941
- " size[8,9]" ..
942
- " image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:" ..
943
- (100 - percent ).. " :default_furnace_fire_fg.png]" ..
944
- " list[current_name;fuel;2,3;1,1;]" ..
945
- " list[current_name;src;2,1;1,1;]" ..
946
- " list[current_name;dst;5,1;2,2;]" ..
947
- " list[current_player;main;0,5;8,4;]" )
964
+ meta :set_string (" formspec" ,default .get_furnace_active_formspec (pos , percent ))
948
965
return
949
966
end
950
967
0 commit comments