From 671ba32e5aec9e944dd54699555ebf5a6f7714b9 Mon Sep 17 00:00:00 2001 From: RealBadAngel <mk@realbadangel.pl> Date: Tue, 19 Feb 2013 23:11:41 +0100 Subject: [PATCH] Fix to last registered power tool not being able to charge (affected blue energy crystal) --- technic/battery_box_mv.lua | 30 ++++++++++++++++++++++-------- 1 files changed, 22 insertions(+), 8 deletions(-) diff --git a/technic/battery_box_mv.lua b/technic/battery_box_mv.lua index c48adce..b8f4e5e 100644 --- a/technic/battery_box_mv.lua +++ b/technic/battery_box_mv.lua @@ -1,3 +1,14 @@ +MV_machines = {} + +registered_MV_machines_count=0 + +function register_MV_machine (string1,string2) +registered_MV_machines_count=registered_MV_machines_count+1 +MV_machines[registered_MV_machines_count]={} +MV_machines[registered_MV_machines_count].machine_name=string1 +MV_machines[registered_MV_machines_count].machine_type=string2 +end + minetest.register_craft({ output = 'technic:mv_battery_box 1', recipe = { @@ -6,8 +17,6 @@ {'', 'technic:mv_cable', ''}, } }) - - mv_battery_box_formspec = "invsize[8,9;]".. @@ -122,7 +131,7 @@ if src_item["metadata"]=="" then src_item["metadata"]="0" end --create meta for not used before tool/item local item_max_charge = nil - local counter=registered_power_tools_count-1 + local counter=registered_power_tools_count for i=1, counter,1 do if power_tools[i].tool_name==src_item["name"] then item_max_charge=power_tools[i].max_charge @@ -316,10 +325,15 @@ function check_MV_node_subp (PR_nodes,RE_nodes,MV_nodes,pos1) meta = minetest.env:get_meta(pos1) if meta:get_float("mv_cablelike")==1 then new_node_added=add_new_MVcable_node(MV_nodes,pos1) end -if minetest.env:get_node(pos1).name == "technic:solar_panel_mv" then new_node_added=add_new_MVcable_node(PR_nodes,pos1) end -if minetest.env:get_node(pos1).name == "technic:mv_electric_furnace" then new_node_added=add_new_MVcable_node(RE_nodes,pos1) end -if minetest.env:get_node(pos1).name == "technic:mv_electric_furnace_active" then new_node_added=add_new_MVcable_node(RE_nodes,pos1) end -if minetest.env:get_node(pos1).name == "technic:mv_alloy_furnace" then new_node_added=add_new_MVcable_node(RE_nodes,pos1) end -if minetest.env:get_node(pos1).name == "technic:mv_alloy_furnace_active" then new_node_added=add_new_MVcable_node(RE_nodes,pos1) end +for i in ipairs(MV_machines) do + if minetest.env:get_node(pos1).name == MV_machines[i].machine_name then + if MV_machines[i].machine_type == "PR" then + new_node_added=add_new_MVcable_node(PR_nodes,pos1) + end + if MV_machines[i].machine_type == "RE" then + new_node_added=add_new_MVcable_node(RE_nodes,pos1) + end + end +end end -- Gitblit v1.8.0