22local S = digtron .S
33-- local MP = minetest.get_modpath(minetest.get_current_modname())
44-- local S = dofile(MP.."/intllib.lua")
5-
5+ local have_technic_mod = core . get_modpath ( " technic " )
66
77-- Battery storage. Controller node draws electrical power from here.
88-- Note that batttery boxes are digtron group 7.
@@ -24,7 +24,7 @@ local battery_holder_formspec = function()
2424end
2525
2626local holder_groups = {cracky = 3 , oddly_breakable_by_hand = 3 , digtron = 7 , tubedevice = 1 , tubedevice_receiver = 1 }
27- if not minetest . get_modpath ( " technic " ) then
27+ if not have_technic_mod then
2828 -- if technic isn't installed there's no point in offering battery holders.
2929 -- leave them registered, though, in case technic is being removed from an existing server.
3030 holder_groups .not_in_creative_inventory = 1
@@ -66,8 +66,12 @@ local def = {
6666
6767 -- Allow all items with energy storage to be placed in the inventory
6868 allow_metadata_inventory_put = function (pos , listname , _ , stack , player )
69+ if not have_technic_mod then
70+ return 0
71+ end
72+
6973 if listname == " batteries" then
70- if minetest . global_exists ( " technic " ) and technic .get_charge (stack ) > 0 then
74+ if technic .get_charge (stack ) > 0 then
7175 if digtron .check_protected_and_record (pos , player ) then
7276 return 0
7377 end
@@ -99,8 +103,12 @@ local def = {
99103 return inv :add_item (" batteries" , stack )
100104 end ,
101105 can_insert = function (pos , _ , stack )
106+ if not have_technic_mod then
107+ return false
108+ end
109+
102110 -- Disregard empty batteries, the player should know better
103- if minetest . global_exists ( " technic " ) and technic .get_charge (stack ) > 0 then
111+ if technic .get_charge (stack ) > 0 then
104112 local meta = minetest .get_meta (pos )
105113 local inv = meta :get_inventory ()
106114 return inv :room_for_item (" batteries" , stack )
0 commit comments