@@ -67,28 +67,11 @@ local def = {
6767 -- Allow all items with energy storage to be placed in the inventory
6868 allow_metadata_inventory_put = function (pos , listname , _ , stack , player )
6969 if listname == " batteries" then
70- if not minetest .global_exists (" technic" ) then
71- return 0
72- end
73-
74- local node_name = stack :get_name ()
75-
76- -- Allow all items with energy storage from technic mod
77- if technic .power_tools [node_name ] ~= nil then
78- local meta = stack :get_metadata ()
79- local md = minetest .deserialize (meta )
80- -- And specifically if they hold any charge
81- -- Disregard empty batteries, the player should know better
82- if md and md .charge > 0 then
83- if digtron .check_protected_and_record (pos , player ) then
84- return 0
85- end
86- return stack :get_count ()
87- else
70+ if minetest .global_exists (" technic" ) and technic .get_charge (stack ) > 0 then
71+ if digtron .check_protected_and_record (pos , player ) then
8872 return 0
8973 end
90- else
91- return 0
74+ return stack :get_count ()
9275 end
9376 end
9477 return 0
@@ -116,12 +99,9 @@ local def = {
11699 return inv :add_item (" batteries" , stack )
117100 end ,
118101 can_insert = function (pos , _ , stack )
119- local meta = stack :get_metadata ()
120- local md = minetest .deserialize (meta )
121- -- And specifically if they hold any charge
122102 -- Disregard empty batteries, the player should know better
123- if md and md . charge > 0 then
124- meta = minetest .get_meta (pos )
103+ if minetest . global_exists ( " technic " ) and technic . get_charge ( stack ) > 0 then
104+ local meta = minetest .get_meta (pos )
125105 local inv = meta :get_inventory ()
126106 return inv :room_for_item (" batteries" , stack )
127107 end
0 commit comments