@@ -47,21 +47,27 @@ if minetest.get_modpath("default") then
47
47
-- get the fields from the chest formspec, we can do this bc. newest functions are called first
48
48
-- https://github.com/minetest/minetest/blob/d4b10db998ebeb689b3d27368e30952a42169d03/doc/lua_api.md?plain=1#L5840
49
49
minetest .register_on_player_receive_fields (function (player , formname , fields )
50
- if formname == " default:chest" then
51
- local pn = player :get_player_name ()
52
- local pos = default .chest .open_chests [pn ].pos
53
- local chest = pos and minetest .get_node (pos )
54
- local is_pipeworks_chest = chest and pipeworks .chests [chest ]
55
- if is_pipeworks_chest and not fields .quit and pipeworks .may_configure (pos , player ) then
56
- -- Pipeworks Switch
57
- fs_helpers .on_receive_fields (pos , fields )
58
- minetest .show_formspec (player :get_player_name (),
59
- " default:chest" ,
60
- default .chest .get_chest_formspec (pos ))
61
- end
62
- -- Do NOT return true here, the callback from default still needs to run
63
- return false
50
+ if fields .quit or formname ~= " default:chest" then
51
+ return
64
52
end
53
+ local pn = player :get_player_name ()
54
+ local chest_open = default .chest .open_chests [pn ]
55
+ if not chest_open then
56
+ -- chest already closed before formspec
57
+ return
58
+ end
59
+ local pos = chest_open .pos
60
+ local chest = pos and minetest .get_node (pos )
61
+ local is_pipeworks_chest = chest and pipeworks .chests [chest ]
62
+ if is_pipeworks_chest and pipeworks .may_configure (pos , player ) then
63
+ -- Pipeworks Switch
64
+ fs_helpers .on_receive_fields (pos , fields )
65
+ minetest .show_formspec (pn ,
66
+ " default:chest" ,
67
+ default .chest .get_chest_formspec (pos ))
68
+ end
69
+ -- Do NOT return true here, the callback from default still needs to run
70
+ return false
65
71
end )
66
72
67
73
local connect_sides = {left = 1 , right = 1 , back = 1 , bottom = 1 , top = 1 }
@@ -152,17 +158,18 @@ elseif minetest.get_modpath("hades_chests") then
152
158
-- get the fields from the chest formspec, we can do this bc. newest functions are called first
153
159
-- https://github.com/minetest/minetest/blob/d4b10db998ebeb689b3d27368e30952a42169d03/doc/lua_api.md?plain=1#L5840
154
160
minetest .register_on_player_receive_fields (function (player , formname , fields )
155
- if formname == " hades_chests:chest_locked" then
156
- local pn = player :get_player_name ()
157
- local pos = open_chests [pn ]
158
- if not fields .quit and pos and pipeworks .may_configure (pos , player ) then
159
- -- Pipeworks Switch
160
- fs_helpers .on_receive_fields (pos , fields )
161
- minetest .show_formspec (pn , " hades_chests:chest_locked" , get_locked_chest_formspec (pos ))
162
- end
163
- -- Do NOT return true here, the callback from hades still needs to run (if they add one)
164
- return false
161
+ if fields .quit or formname ~= " hades_chests:chest_locked" then
162
+ return
163
+ end
164
+ local pn = player :get_player_name ()
165
+ local pos = open_chests [pn ]
166
+ if pos and pipeworks .may_configure (pos , player ) then
167
+ -- Pipeworks Switch
168
+ fs_helpers .on_receive_fields (pos , fields )
169
+ minetest .show_formspec (pn , " hades_chests:chest_locked" , get_locked_chest_formspec (pos ))
165
170
end
171
+ -- Do NOT return true here, the callback from hades still needs to run (if they add one)
172
+ return false
166
173
end )
167
174
168
175
local connect_sides = {left = 1 , right = 1 , back = 1 , bottom = 1 , top = 1 }
@@ -175,4 +182,4 @@ elseif minetest.get_modpath("mcl_barrels") then
175
182
local connect_sides = {left = 1 , right = 1 , back = 1 , front = 1 , bottom = 1 }
176
183
pipeworks .override_chest (" mcl_barrels:barrel_closed" , {}, connect_sides )
177
184
pipeworks .override_chest (" mcl_barrels:barrel_open" , {}, connect_sides )
178
- end
185
+ end
0 commit comments