@@ -13,16 +13,23 @@ local vessels_shelf_formspec =
13
13
" listring[current_player;main]" ..
14
14
default .get_hotbar_bg (0 , 2.85 )
15
15
16
- -- Inventory slots overlay
17
- local vx , vy = 0 , 0.3
18
- for i = 1 , 16 do
19
- if i == 9 then
20
- vx = 0
21
- vy = vy + 1
16
+ local function get_vessels_shelf_formspec (inv )
17
+ local formspec = vessels_shelf_formspec
18
+ local invlist = inv and inv :get_list (" vessels" )
19
+ -- Inventory slots overlay
20
+ local vx , vy = 0 , 0.3
21
+ for i = 1 , 16 do
22
+ if i == 9 then
23
+ vx = 0
24
+ vy = vy + 1
25
+ end
26
+ if not invlist or invlist [i ]:is_empty () then
27
+ formspec = formspec ..
28
+ " image[" .. vx .. " ," .. vy .. " ;1,1;vessels_shelf_slot.png]"
29
+ end
30
+ vx = vx + 1
22
31
end
23
- vessels_shelf_formspec = vessels_shelf_formspec ..
24
- " image[" .. vx .. " ," .. vy .. " ;1,1;vessels_shelf_slot.png]"
25
- vx = vx + 1
32
+ return formspec
26
33
end
27
34
28
35
minetest .register_node (" vessels:shelf" , {
@@ -36,7 +43,7 @@ minetest.register_node("vessels:shelf", {
36
43
37
44
on_construct = function (pos )
38
45
local meta = minetest .get_meta (pos )
39
- meta :set_string (" formspec" , vessels_shelf_formspec )
46
+ meta :set_string (" formspec" , get_vessels_shelf_formspec ( nil ) )
40
47
local inv = meta :get_inventory ()
41
48
inv :set_size (" vessels" , 8 * 2 )
42
49
end ,
@@ -53,14 +60,20 @@ minetest.register_node("vessels:shelf", {
53
60
on_metadata_inventory_move = function (pos , from_list , from_index , to_list , to_index , count , player )
54
61
minetest .log (" action" , player :get_player_name () ..
55
62
" moves stuff in vessels shelf at " .. minetest .pos_to_string (pos ))
63
+ local meta = minetest .get_meta (pos )
64
+ meta :set_string (" formspec" , get_vessels_shelf_formspec (meta :get_inventory ()))
56
65
end ,
57
66
on_metadata_inventory_put = function (pos , listname , index , stack , player )
58
67
minetest .log (" action" , player :get_player_name () ..
59
68
" moves stuff to vessels shelf at " .. minetest .pos_to_string (pos ))
69
+ local meta = minetest .get_meta (pos )
70
+ meta :set_string (" formspec" , get_vessels_shelf_formspec (meta :get_inventory ()))
60
71
end ,
61
72
on_metadata_inventory_take = function (pos , listname , index , stack , player )
62
73
minetest .log (" action" , player :get_player_name () ..
63
74
" takes stuff from vessels shelf at " .. minetest .pos_to_string (pos ))
75
+ local meta = minetest .get_meta (pos )
76
+ meta :set_string (" formspec" , get_vessels_shelf_formspec (meta :get_inventory ()))
64
77
end ,
65
78
on_blast = function (pos )
66
79
local drops = {}
0 commit comments