Remove lv, mv, and hv tiers from power tools.
authorRealBadAngel <mk@realbadangel.pl>
Wed, 17 Jul 2013 17:14:01 +0000 (19:14 +0200)
committerRealBadAngel <mk@realbadangel.pl>
Wed, 17 Jul 2013 17:14:01 +0000 (19:14 +0200)
Theyre already tiered with Mk1-3 (at least drill is, more in the future).
Tools can be considered as designed for different tiers of circuits thx to their power needs.
For example Mk3 will require ages to load in LV batbox.
Batboxes load tools timining: LV standard (1000EU), MV 4x faster (4000EU), HV 16x faster (16000EU)
Also since 1EU is the same in any circuit it is possible to move energy from one to another with portable devices like crystals.

Other changes:
- moved charge/discharge functions to battery_boxes_commons.lua
- added UI style backgrounds for all the batboxes

technic/init.lua
technic/machines/hv/battery_box.lua
technic/machines/init.lua
technic/machines/lv/battery_box.lua
technic/machines/mv/battery_box.lua
technic/register_machine_and_tool.lua
technic/tools/chainsaw.lua
technic/tools/flashlight.lua
technic/tools/mining_drill.lua
technic/tools/mining_laser_mk1.lua
technic/tools/sonic_screwdriver.lua

index 3068885fededd7363549f70ace58fb75e9296272..da67c0754df1862e213098e167756901244bfca8 100644 (file)
@@ -1,4 +1,4 @@
--- Minetest 0.4.6 mod: technic
+-- Minetest 0.4.7 mod: technic
 -- namespace: technic
 -- (c) 2012-2013 by RealBadAngel <mk@realbadangel.pl>
 
index 10b9e66755a3b3a0feea9daddb2bfdb0581601a4..34e41fc566b320edcb7470ba7fe4596d71650092 100644 (file)
@@ -17,13 +17,15 @@ local battery_box_formspec =
        "invsize[8,9;]"..
        "image[1,1;1,2;technic_power_meter_bg.png]"..
        "list[current_name;src;3,1;1,1;]"..
-       "image[4,1;1,1;technic_battery_reload.png]"..
        "list[current_name;dst;5,1;1,1;]"..
        "label[0,0;HV Battery Box]"..
        "label[3,0;Charge]"..
        "label[5,0;Discharge]"..
        "label[1,3;Power level]"..
-       "list[current_player;main;0,5;8,4;]"
+       "list[current_player;main;0,5;8,4;]"..
+       "background[-0.19,-0.25;8.4,9.75;ui_form_bg.png]"..
+       "background[0,0;8,4;ui_hv_battery_box.png]"..
+       "background[0,5;8,4;ui_main_inventory.png]"
 
 minetest.register_node("technic:hv_battery_box", {
        description = "HV Battery Box",
@@ -84,92 +86,6 @@ for i = 1,8,1 do
        })
 end
 
-local power_tools = technic.HV_power_tools
-
-local function charge_HV_tools(meta, charge)
-       --charge registered power tools
-       local inv = meta:get_inventory()
-       if not inv:is_empty("src") then
-               local srcstack = inv:get_stack("src", 1)
-               local src_item = srcstack:to_table()
-               local src_meta = get_item_meta(src_item["metadata"])
-
-               local toolname = src_item["name"]
-               if power_tools[toolname] ~= nil then
-                       -- Set meta data for the tool if it didn't do it itself :-(
-                       src_meta = get_item_meta(src_item["metadata"])
-                       if src_meta==nil then
-                               src_meta = {}
-                               src_meta["technic_hv_power_tool"] = true
-                               src_meta["charge"] = 0
-                       else
-                               if src_meta["technic_hv_power_tool"] == nil then
-                               src_meta["technic_hv_power_tool"] = true
-                               src_meta["charge"] = 0
-                               end
-                       end
-                       -- Do the charging
-                       local item_max_charge = power_tools[toolname]
-                       local tool_charge     = src_meta["charge"]
-                       local charge_step     = 1000 -- how much to charge per tick
-                       if tool_charge < item_max_charge and tool_charge > 0 then
-                               if tool_charge - charge_step < 0 then
-                                       charge_step = charge
-                               end
-                               if tool_charge + charge_step > item_max_charge then
-                                       charge_step = item_max_charge - tool_charge
-                               end
-                               tool_charge = tool_charge + charge_step
-                               charge = charge - charge_step
-                               technic.set_RE_wear(src_item, tool_charge, item_max_charge)
-                               src_meta["charge"]   = tool_charge
-                               src_item["metadata"] = set_item_meta(src_meta)
-                               inv:set_stack("src", 1, src_item)
-                       end
-               end
-       end
-       return charge -- return the remaining charge in the battery
-end
-
-local function discharge_HV_tools(meta, charge, max_charge)
-       -- discharging registered power tools
-       local inv = meta:get_inventory()
-       if not inv:is_empty("dst") then
-               srcstack = inv:get_stack("dst", 1)
-               src_item = srcstack:to_table()
-               local src_meta = get_item_meta(src_item["metadata"])
-               local toolname = src_item["name"]
-               if power_tools[toolname] ~= nil then
-                       -- Set meta data for the tool if it didn't do it itself :-(
-                       src_meta = get_item_meta(src_item["metadata"]) or {}
-                       if src_meta["technic_hv_power_tool"] == nil then
-                               src_meta["technic_hv_power_tool"] = true
-                               src_meta["charge"] = 0
-                       end
-
-                       -- Do the discharging
-                       local item_max_charge = power_tools[toolname]
-                       local tool_charge     = src_meta["charge"]
-                       local charge_step     = 4000 -- how much to discharge per tick
-                       if tool_charge > 0 and charge < max_charge then
-                               if tool_charge + charge_step > max_charge then
-                                       charge_step = max_charge - charge
-                               end
-                               if tool_charge - charge_step < 0 then
-                                       charge_step = charge
-                               end
-                               tool_charge = tool_charge - charge_step
-                               charge = charge + charge_step
-                               technic.set_RE_wear(src_item, tool_charge, item_max_charge)
-                               src_meta["charge"] = tool_charge
-                               src_item["metadata"] = set_item_meta(src_meta)
-                               inv:set_stack("dst", 1, src_item)
-                       end
-               end
-       end
-       return charge -- return the remaining charge in the battery
-end
-
 minetest.register_abm({
        nodenames = {"technic:hv_battery_box",  "technic:hv_battery_box1", "technic:hv_battery_box2",
                     "technic:hv_battery_box3", "technic:hv_battery_box4", "technic:hv_battery_box5",
@@ -192,8 +108,8 @@ minetest.register_abm({
                end
 
                -- Charging/discharging tools here
-               current_charge = charge_HV_tools(meta, current_charge)
-               current_charge = discharge_HV_tools(meta, current_charge, max_charge)
+               current_charge = charge_tools(meta, current_charge, 16000)
+               current_charge = discharge_tools(meta, current_charge, max_charge, 16000)
 
                -- Set a demand (we allow batteries to charge on less than the demand though)
                meta:set_int("HV_EU_demand", math.min(max_charge_rate, max_charge-current_charge))
index 58b42f44a035741c8d48f855c4d0bba864ca8077..d798e9fbac1302517fc5725f2e04bbb461864cac 100644 (file)
@@ -3,6 +3,7 @@ local path = technic.modpath.."/machines"
 dofile(path.."/switching_station.lua")
 dofile(path.."/supply_converter.lua")
 dofile(path.."/alloy_furnaces_commons.lua")
+dofile(path.."/battery_boxes_commons.lua")
 dofile(path.."/lv/init.lua")
 dofile(path.."/mv/init.lua")
 dofile(path.."/hv/init.lua")
index a26b72bb999c796cf169c8f5f56157d46f3c62d2..e27da51471a8cda9e9ee1faf14462d68f60a2e6e 100644 (file)
@@ -1,8 +1,8 @@
 -- LV Battery box and some other nodes...
-technic.register_LV_power_tool("technic:battery",10000)
-technic.register_MV_power_tool("technic:red_energy_crystal",100000)
-technic.register_HV_power_tool("technic:green_energy_crystal",250000)
-technic.register_HV_power_tool("technic:blue_energy_crystal",500000)
+technic.register_power_tool("technic:battery",10000)
+technic.register_power_tool("technic:red_energy_crystal",100000)
+technic.register_power_tool("technic:green_energy_crystal",250000)
+technic.register_power_tool("technic:blue_energy_crystal",500000)
 
 minetest.register_craft({
        output = 'technic:battery 1',
@@ -47,7 +47,7 @@ local battery_box_formspec =
        "image[1,1;1,2;technic_power_meter_bg.png]"..
        "list[current_name;src;3,1;1,1;]"..
        "list[current_name;dst;5,1;1,1;]"..
-       "label[0,0;Battery box]"..
+       "label[0,0;LV Battery Box]"..
        "label[3,0;Charge]"..
        "label[5,0;Discharge]"..
        "label[1,3;Power level]"..
@@ -116,89 +116,6 @@ for i=1,8,1 do
       })
 end
 
-local power_tools = technic.LV_power_tools
-
-local charge_LV_tools = function(meta, charge)
-                    --charge registered power tools
-                    local inv = meta:get_inventory()
-                    if inv:is_empty("src")==false  then
-                       local srcstack = inv:get_stack("src", 1)
-                       local src_item=srcstack:to_table()
-                       local src_meta=get_item_meta(src_item["metadata"])
-                       
-                       local toolname = src_item["name"]
-                       if power_tools[toolname] ~= nil then
-                          -- Set meta data for the tool if it didn't do it itself :-(
-                          src_meta=get_item_meta(src_item["metadata"])
-                          if src_meta==nil then
-                             src_meta={}
-                             src_meta["technic_power_tool"]=true
-                             src_meta["charge"]=0
-                          else
-                             if src_meta["technic_power_tool"]==nil then
-                                src_meta["technic_power_tool"]=true
-                                src_meta["charge"]=0
-                             end
-                          end
-                          -- Do the charging
-                          local item_max_charge = power_tools[toolname]
-                          local load            = src_meta["charge"]
-                          local load_step       = 1000 -- how much to charge per tick
-                          if load<item_max_charge and charge>0 then
-                             if charge-load_step<0 then load_step=charge end
-                             if load+load_step>item_max_charge then load_step=item_max_charge-load end
-                             load=load+load_step
-                             charge=charge-load_step
-                             technic.set_RE_wear(src_item,load,item_max_charge)
-                             src_meta["charge"]   = load
-                             src_item["metadata"] = set_item_meta(src_meta)
-                             inv:set_stack("src", 1, src_item)
-                          end
-                       end
-                    end
-                    return charge -- return the remaining charge in the battery
-                 end
-
-local discharge_LV_tools = function(meta, charge, max_charge)
-                       -- discharging registered power tools
-                       local inv = meta:get_inventory()
-                       if inv:is_empty("dst") == false then
-                          srcstack = inv:get_stack("dst", 1)
-                          src_item=srcstack:to_table()
-                          local src_meta=get_item_meta(src_item["metadata"])
-                          local toolname = src_item["name"]
-                          if power_tools[toolname] ~= nil then
-                             -- Set meta data for the tool if it didn't do it itself :-(
-                             src_meta=get_item_meta(src_item["metadata"])
-                             if src_meta==nil then
-                                src_meta={}
-                                src_meta["technic_power_tool"]=true
-                                src_meta["charge"]=0
-                             else
-                                if src_meta["technic_power_tool"]==nil then
-                                   src_meta["technic_power_tool"]=true
-                                   src_meta["charge"]=0
-                                end
-                             end
-                             -- Do the discharging
-                             local item_max_charge = power_tools[toolname]
-                             local load            = src_meta["charge"]
-                             local load_step       = 4000 -- how much to discharge per tick
-                             if load>0 and charge<max_charge then
-                                if charge+load_step>max_charge then load_step=max_charge-charge end
-                                if load-load_step<0 then load_step=load end
-                                load=load-load_step
-                                charge=charge+load_step
-                                technic.set_RE_wear(src_item,load,item_max_charge)
-                                src_meta["charge"]=load
-                                src_item["metadata"]=set_item_meta(src_meta)
-                                inv:set_stack("dst", 1, src_item)
-                             end
-                          end
-                       end
-                       return charge -- return the remaining charge in the battery
-                    end
-
 minetest.register_abm(
    {nodenames = {"technic:battery_box","technic:battery_box1","technic:battery_box2","technic:battery_box3","technic:battery_box4",
                 "technic:battery_box5","technic:battery_box6","technic:battery_box7","technic:battery_box8"},
@@ -223,8 +140,8 @@ minetest.register_abm(
                end
 
                -- Charging/discharging tools here
-               current_charge = charge_LV_tools(meta, current_charge)
-               current_charge = discharge_LV_tools(meta, current_charge, max_charge)
+               current_charge = charge_tools(meta, current_charge, 1000)
+               current_charge = discharge_tools(meta, current_charge, max_charge, 1000)
 
                -- Set a demand (we allow batteries to charge on less than the demand though)
                meta:set_int("LV_EU_demand", math.min(max_charge_rate, max_charge-current_charge))
index e1295ce88754c2e2a95ffd214093873264536d1f..86a1d780a291da9332b2ce0b40119251e1bf0997 100644 (file)
@@ -9,16 +9,18 @@ minetest.register_craft(
  })
 
 local battery_box_formspec =
-   "invsize[8,9;]"..
-   "image[1,1;1,2;technic_power_meter_bg.png]"..
-   "list[current_name;src;3,1;1,1;]"..
-   "image[4,1;1,1;technic_battery_reload.png]"..
-   "list[current_name;dst;5,1;1,1;]"..
-   "label[0,0;MV_Battery box]"..
-   "label[3,0;Charge]"..
-   "label[5,0;Discharge]"..
-   "label[1,3;Power level]"..
-   "list[current_player;main;0,5;8,4;]"
+       "invsize[8,9;]"..
+       "image[1,1;1,2;technic_power_meter_bg.png]"..
+       "list[current_name;src;3,1;1,1;]"..
+       "list[current_name;dst;5,1;1,1;]"..
+       "label[0,0;MV Battery Box]"..
+       "label[3,0;Charge]"..
+       "label[5,0;Discharge]"..
+       "label[1,3;Power level]"..
+       "list[current_player;main;0,5;8,4;]"..
+       "background[-0.19,-0.25;8.4,9.75;ui_form_bg.png]"..
+       "background[0,0;8,4;ui_mv_battery_box.png]"..
+       "background[0,5;8,4;ui_main_inventory.png]"
 
 minetest.register_node(
    "technic:mv_battery_box", {
@@ -78,89 +80,6 @@ for i=1,8,1 do
       })
 end
 
-local power_tools = technic.MV_power_tools
-
-local charge_MV_tools = function(meta, charge)
-                    --charge registered power tools
-                    local inv = meta:get_inventory()
-                    if inv:is_empty("src")==false  then
-                       local srcstack = inv:get_stack("src", 1)
-                       local src_item=srcstack:to_table()
-                       local src_meta=get_item_meta(src_item["metadata"])
-                       
-                       local toolname = src_item["name"]
-                       if power_tools[toolname] ~= nil then
-                          -- Set meta data for the tool if it didn't do it itself :-(
-                          src_meta=get_item_meta(src_item["metadata"])
-                          if src_meta==nil then
-                             src_meta={}
-                             src_meta["technic_mv_power_tool"]=true
-                             src_meta["charge"]=0
-                          else
-                             if src_meta["technic_mv_power_tool"]==nil then
-                                src_meta["technic_mv_power_tool"]=true
-                                src_meta["charge"]=0
-                             end
-                          end
-                          -- Do the charging
-                          local item_max_charge = power_tools[toolname]
-                          local load            = src_meta["charge"]
-                          local load_step       = 1000 -- how much to charge per tick
-                          if load<item_max_charge and charge>0 then
-                             if charge-load_step<0 then load_step=charge end
-                             if load+load_step>item_max_charge then load_step=item_max_charge-load end
-                             load=load+load_step
-                             charge=charge-load_step
-                             technic.set_RE_wear(src_item,load,item_max_charge)
-                             src_meta["charge"]   = load
-                             src_item["metadata"] = set_item_meta(src_meta)
-                             inv:set_stack("src", 1, src_item)
-                          end
-                       end
-                    end
-                    return charge -- return the remaining charge in the battery
-                 end
-
-local discharge_MV_tools = function(meta, charge, max_charge)
-                       -- discharging registered power tools
-                       local inv = meta:get_inventory()
-                       if inv:is_empty("dst") == false then
-                          srcstack = inv:get_stack("dst", 1)
-                          src_item=srcstack:to_table()
-                          local src_meta=get_item_meta(src_item["metadata"])
-                          local toolname = src_item["name"]
-                          if power_tools[toolname] ~= nil then
-                             -- Set meta data for the tool if it didn't do it itself :-(
-                             src_meta=get_item_meta(src_item["metadata"])
-                             if src_meta==nil then
-                                src_meta={}
-                                src_meta["technic_mv_power_tool"]=true
-                                src_meta["charge"]=0
-                             else
-                                if src_meta["technic_mv_power_tool"]==nil then
-                                   src_meta["technic_mv_power_tool"]=true
-                                   src_meta["charge"]=0
-                                end
-                             end
-                             -- Do the discharging
-                             local item_max_charge = power_tools[toolname]
-                             local load            = src_meta["charge"]
-                             local load_step       = 4000 -- how much to discharge per tick
-                             if load>0 and charge<max_charge then
-                                if charge+load_step>max_charge then load_step=max_charge-charge end
-                                if load-load_step<0 then load_step=load end
-                                load=load-load_step
-                                charge=charge+load_step
-                                technic.set_RE_wear(src_item,load,item_max_charge)
-                                src_meta["charge"]=load
-                                src_item["metadata"]=set_item_meta(src_meta)
-                                inv:set_stack("dst", 1, src_item)
-                             end
-                          end
-                       end
-                       return charge -- return the remaining charge in the battery
-                    end
-
 minetest.register_abm(
    {
       nodenames = {"technic:mv_battery_box","technic:mv_battery_box1","technic:mv_battery_box2","technic:mv_battery_box3","technic:mv_battery_box4",
@@ -187,8 +106,8 @@ minetest.register_abm(
                end
 
                -- Charging/discharging tools here
-               current_charge = charge_MV_tools(meta, current_charge)
-               current_charge = discharge_MV_tools(meta, current_charge, max_charge)
+               current_charge = charge_tools(meta, current_charge, 4000)
+               current_charge = discharge_tools(meta, current_charge, max_charge, 4000)
 
                -- Set a demand (we allow batteries to charge on less than the demand though)
                meta:set_int("MV_EU_demand", math.min(max_charge_rate, max_charge-current_charge))
index b7d039a386cb980730922cf5b492f0dd588a371e..6ea361d5bdc857a3e657e9980f64510407e1588b 100644 (file)
@@ -1,9 +1,15 @@
 -- This file includes the functions and data structures for registering machines and tools for LV, MV, HV types.
 -- We use the technic namespace for these functions and data to avoid eventual conflict.
 
+-- register power tools here
+technic.power_tools = {}
+technic.register_power_tool = function(craftitem,max_charge)
+                                   technic.power_tools[craftitem] = max_charge
+                                end
+
 -- register LV machines here
 technic.LV_machines    = {}
-technic.LV_power_tools = {}
+
 technic.register_LV_machine = function(nodename,type)
                                 technic.LV_machines[nodename] = type
                              end
@@ -12,10 +18,6 @@ technic.unregister_LV_machine = function(nodename,type)
                                   technic.LV_machines[nodename] = nil
                                end
 
-technic.register_LV_power_tool = function(craftitem,max_charge)
-                                   technic.LV_power_tools[craftitem] = max_charge
-                                end
-
 -- register MV machines here
 technic.MV_machines    = {}
 technic.MV_power_tools = {}
@@ -27,10 +29,6 @@ technic.unregister_MV_machine = function(nodename)
                                   technic.MV_machines[nodename] = nil
                                end
 
-technic.register_MV_power_tool = function(craftitem,max_charge)
-                                   technic.MV_power_tools[craftitem] = max_charge
-                                end
-
 -- register HV machines here
 technic.HV_machines    = {}
 technic.HV_power_tools = {}
@@ -42,11 +40,6 @@ technic.unregister_HV_machine = function(nodename)
                                   technic.HV_machines[nodename] = nil
                                end
 
-technic.register_HV_power_tool = function(craftitem,max_charge)
-                                   technic.HV_power_tools[craftitem] = max_charge
-                                end
-
-
 -- Utility functions. Not sure exactly what they do.. water.lua uses the two first.
 function technic.get_RE_item_load (load1,max_load)
    if load1==0 then load1=65535 end
index ae0c30c914163bca0b187f7054a89b1d09862bb6..891f4e467f236375f464f3c37ef2f88344b8011e 100644 (file)
@@ -3,7 +3,7 @@ local chainsaw_max_charge      = 30000 -- 30000 - Maximum charge of the saw
 local chainsaw_charge_per_node = 12    -- 12    - Gives 2500 nodes on a single charge (about 50 complete normal trees)
 local chainsaw_leaves          = true  -- true  - Cut down entire trees, leaves and all
 
-technic.register_LV_power_tool ("technic:chainsaw",chainsaw_max_charge)
+technic.register_power_tool ("technic:chainsaw",chainsaw_max_charge)
 
 minetest.register_tool("technic:chainsaw", {
         description = "Chainsaw",
index 5f3ea969245e275793af2d54815297e54024fefe..f5918946e4ae041fb20d6d113bb5326fc83939b6 100644 (file)
@@ -1,7 +1,7 @@
 -- original code comes from walkin_light mod by Echo http://minetest.net/forum/viewtopic.php?id=2621
 
 local flashlight_max_charge=30000
-technic.register_LV_power_tool ("technic:flashlight",flashlight_max_charge)
+technic.register_power_tool ("technic:flashlight",flashlight_max_charge)
       
 minetest.register_tool("technic:flashlight", {
        description = "Flashlight",
index 6df9e9799edfd2f8ab7d1791f8cc9b6e7c810f18..860127f8fcbe7559e5ffefaffeb3114c302b9723 100644 (file)
@@ -210,7 +210,7 @@ function drill_dig_it4 (pos,player)
        drill_dig_it0 (pos,player)
 end
 
-technic.register_MV_power_tool ("technic:mining_drill",mining_drill_max_charge)
+technic.register_power_tool ("technic:mining_drill",mining_drill_max_charge)
 minetest.register_tool("technic:mining_drill", {
        description = "Mining Drill Mk1",
        inventory_image = "technic_mining_drill.png",
@@ -243,10 +243,10 @@ minetest.register_tool("technic:mining_drill_mk2", {
        return itemstack
        end,
 })
-technic.register_HV_power_tool ("technic:mining_drill_mk2",mining_drill_mk2_max_charge)
+technic.register_power_tool ("technic:mining_drill_mk2",mining_drill_mk2_max_charge)
 
 for i=1,4,1 do
-technic.register_HV_power_tool ("technic:mining_drill_mk2_"..i,mining_drill_mk2_max_charge)
+technic.register_power_tool ("technic:mining_drill_mk2_"..i,mining_drill_mk2_max_charge)
 minetest.register_tool("technic:mining_drill_mk2_"..i, {
        description = "Mining Drill Mk2 in Mode "..i,
        inventory_image = "technic_mining_drill_mk2.png^technic_tool_mode"..i..".png",
@@ -267,10 +267,10 @@ minetest.register_tool("technic:mining_drill_mk3", {
        return itemstack
        end,
 })
-technic.register_HV_power_tool ("technic:mining_drill_mk3",mining_drill_mk3_max_charge)
+technic.register_power_tool ("technic:mining_drill_mk3",mining_drill_mk3_max_charge)
 
 for i=1,5,1 do
-technic.register_HV_power_tool ("technic:mining_drill_mk3_"..i,mining_drill_mk3_max_charge)
+technic.register_power_tool ("technic:mining_drill_mk3_"..i,mining_drill_mk3_max_charge)
 minetest.register_tool("technic:mining_drill_mk3_"..i, {
        description = "Mining Drill Mk3 in Mode "..i,
        inventory_image = "technic_mining_drill_mk3.png^technic_tool_mode"..i..".png",
index 8b891316bf97a9650884c5a7b673bdc1a1e63119..245725f9f20304972f4dec4e0c03c063ed88e38c 100644 (file)
@@ -1,5 +1,5 @@
 local laser_mk1_max_charge=40000
-technic.register_LV_power_tool ("technic:laser_mk1",laser_mk1_max_charge)
+technic.register_power_tool ("technic:laser_mk1",laser_mk1_max_charge)
 
 local laser_shoot = function(itemstack, player, pointed_thing)
                                local laser_straight_mode=0
index 00922f74ec9481232e2048252fe250717620226e..a290c940931b2b95805c2701fe9fef5993e578ea 100644 (file)
@@ -1,5 +1,5 @@
 local sonic_screwdriver_max_charge=15000
-technic.register_HV_power_tool ("technic:sonic_screwdriver",sonic_screwdriver_max_charge)
+technic.register_power_tool ("technic:sonic_screwdriver",sonic_screwdriver_max_charge)
 
 minetest.register_tool("technic:sonic_screwdriver", {
                        description = "Sonic Screwdriver",