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
--- Minetest 0.4.6 mod: technic
+-- Minetest 0.4.7 mod: technic
-- namespace: technic
-- (c) 2012-2013 by RealBadAngel <mk@realbadangel.pl>
"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",
})
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",
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))
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")
-- 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',
"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]"..
})
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"},
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))
})
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", {
})
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",
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))
-- 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
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 = {}
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 = {}
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
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",
-- 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",
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",
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",
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",
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
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",