Move files to subfolders
authorShadowNinja <noreply@gmail.com>
Thu, 11 Jul 2013 16:19:09 +0000 (12:19 -0400)
committerShadowNinja <noreply@gmail.com>
Thu, 11 Jul 2013 16:31:00 +0000 (12:31 -0400)
109 files changed:
technic/alloy_furnace.lua [deleted file]
technic/alloy_furnace_mv.lua [deleted file]
technic/alloy_furnaces_commons.lua [deleted file]
technic/alloy_furnaces_commons.lua~ [deleted file]
technic/battery_box.lua [deleted file]
technic/battery_box_hv.lua [deleted file]
technic/battery_box_mv.lua [deleted file]
technic/cans.lua [deleted file]
technic/chainsaw.lua [deleted file]
technic/cnc.lua [deleted file]
technic/cnc_api.lua [deleted file]
technic/cnc_nodes.lua [deleted file]
technic/constructor.lua [deleted file]
technic/creative.lua [deleted file]
technic/deployer.lua [deleted file]
technic/down_converter_hv.lua [deleted file]
technic/down_converter_mv.lua [deleted file]
technic/electric.lua [deleted file]
technic/electric_furnace.lua [deleted file]
technic/electric_furnace_mv.lua [deleted file]
technic/extractor.lua [deleted file]
technic/flashlight.lua [deleted file]
technic/flashlight_old.lua [deleted file]
technic/forcefield.lua [deleted file]
technic/frames.lua [deleted file]
technic/generator.lua [deleted file]
technic/geothermal.lua [deleted file]
technic/grinder.lua [deleted file]
technic/grinder.lua~ [deleted file]
technic/grinder_gloopores.lua [deleted file]
technic/init.lua
technic/injector.lua [deleted file]
technic/injector1.lua [deleted file]
technic/lighting.lua [deleted file]
technic/machines/alloy_furnaces_commons.lua [new file with mode: 0644]
technic/machines/grinder_gloopores.lua [new file with mode: 0644]
technic/machines/hv/battery_box.lua [new file with mode: 0644]
technic/machines/hv/forcefield.lua [new file with mode: 0644]
technic/machines/hv/init.lua [new file with mode: 0644]
technic/machines/hv/nuclear_reactor.lua [new file with mode: 0644]
technic/machines/hv/solar_array.lua [new file with mode: 0644]
technic/machines/hv/wires.lua [new file with mode: 0644]
technic/machines/init.lua [new file with mode: 0644]
technic/machines/lv/alloy_furnace.lua [new file with mode: 0644]
technic/machines/lv/battery_box.lua [new file with mode: 0644]
technic/machines/lv/cnc.lua [new file with mode: 0644]
technic/machines/lv/cnc_api.lua [new file with mode: 0644]
technic/machines/lv/cnc_nodes.lua [new file with mode: 0644]
technic/machines/lv/electric_furnace.lua [new file with mode: 0644]
technic/machines/lv/extractor.lua [new file with mode: 0644]
technic/machines/lv/generator.lua [new file with mode: 0644]
technic/machines/lv/geothermal.lua [new file with mode: 0644]
technic/machines/lv/grinder.lua [new file with mode: 0644]
technic/machines/lv/init.lua [new file with mode: 0644]
technic/machines/lv/music_player.lua [new file with mode: 0644]
technic/machines/lv/solar_array.lua [new file with mode: 0644]
technic/machines/lv/solar_panel.lua [new file with mode: 0644]
technic/machines/lv/tool_workshop.lua [new file with mode: 0644]
technic/machines/lv/water_mill.lua [new file with mode: 0644]
technic/machines/lv/wires.lua [new file with mode: 0644]
technic/machines/mv/alloy_furnace.lua [new file with mode: 0644]
technic/machines/mv/battery_box.lua [new file with mode: 0644]
technic/machines/mv/electric_furnace.lua [new file with mode: 0644]
technic/machines/mv/init.lua [new file with mode: 0644]
technic/machines/mv/lighting.lua [new file with mode: 0644]
technic/machines/mv/power_radiator.lua [new file with mode: 0644]
technic/machines/mv/solar_array.lua [new file with mode: 0644]
technic/machines/mv/wires.lua [new file with mode: 0644]
technic/machines/other/constructor.lua [new file with mode: 0644]
technic/machines/other/deployer.lua [new file with mode: 0644]
technic/machines/other/frames.lua [new file with mode: 0644]
technic/machines/other/init.lua [new file with mode: 0644]
technic/machines/other/injector.lua [new file with mode: 0644]
technic/machines/other/node_breaker.lua [new file with mode: 0644]
technic/machines/other/tetris.lua [new file with mode: 0644]
technic/machines/supply_converter.lua [new file with mode: 0644]
technic/machines/switching_station.lua [new file with mode: 0644]
technic/mining_drill.lua [deleted file]
technic/mining_laser_mk1.lua [deleted file]
technic/music_player.lua [deleted file]
technic/node_breaker.lua [deleted file]
technic/nuclear_reactor_hv.lua [deleted file]
technic/power_radiator.lua [deleted file]
technic/project_table.lua [deleted file]
technic/silver_chest.lua [deleted file]
technic/solar_array_hv.lua [deleted file]
technic/solar_array_lv.lua [deleted file]
technic/solar_array_mv.lua [deleted file]
technic/solar_panel.lua [deleted file]
technic/sonic_screwdriver.lua [deleted file]
technic/supply_converter.lua [deleted file]
technic/switching_station.lua [deleted file]
technic/tetris.lua [deleted file]
technic/tool_workshop.lua [deleted file]
technic/tools/cans.lua [new file with mode: 0644]
technic/tools/chainsaw.lua [new file with mode: 0644]
technic/tools/flashlight.lua [new file with mode: 0644]
technic/tools/flashlight_old.lua [new file with mode: 0644]
technic/tools/init.lua [new file with mode: 0644]
technic/tools/mining_drill.lua [new file with mode: 0644]
technic/tools/mining_laser.lua [new file with mode: 0644]
technic/tools/sonic_screwdriver.lua [new file with mode: 0644]
technic/tools/tree_tap.lua [new file with mode: 0644]
technic/tree_tap.lua [deleted file]
technic/water.lua [deleted file]
technic/water_mill.lua [deleted file]
technic/wires.lua [deleted file]
technic/wires_hv.lua [deleted file]
technic/wires_mv.lua [deleted file]

diff --git a/technic/alloy_furnace.lua b/technic/alloy_furnace.lua
deleted file mode 100644 (file)
index fcdb9c0..0000000
+++ /dev/null
@@ -1,367 +0,0 @@
--- LV Alloy furnace
-minetest.register_craft({
-       output = 'technic:coal_alloy_furnace',
-       recipe = {
-               {'default:brick', 'default:brick', 'default:brick'},
-               {'default:brick', '',              'default:brick'},
-               {'default:brick', 'default:brick', 'default:brick'},
-       }
-})
-
--- FIXME: kpoppel: I'd like to introduce an induction heating element here...
-minetest.register_craft({
-       output = 'technic:alloy_furnace',
-       recipe = {
-               {'default:brick', 'default:brick', 'default:brick'},
-               {'default:brick', '', 'default:brick'},
-               {'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
-       }
-})
-
-local alloy_furnace_formspec =
-   "invsize[8,9;]"..
-   "list[current_name;src;3,1;1,1;]"..
-   "list[current_name;src2;3,2;1,1;]"..
-   "list[current_name;dst;5,1;2,2;]"..
-   "list[current_player;main;0,5;8,4;]"..
-   "label[0,0;Electric Alloy Furnace]"
-
-minetest.register_node(
-   "technic:alloy_furnace",
-   {
-      description = "Electric alloy furnace",
-      tiles = {"technic_alloy_furnace_top.png", "technic_machine_bottom.png", "technic_alloy_furnace_side.png",
-              "technic_alloy_furnace_side.png", "technic_alloy_furnace_side.png", "technic_alloy_furnace_front.png"},
-      paramtype2 = "facedir",
-      groups = {cracky=2},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_stone_defaults(),
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       meta:set_string("infotext", "Electric Alloy furnace")
-                       meta:set_float("technic_power_machine", 1)
-                       meta:set_string("formspec", alloy_furnace_formspec)
-                       local inv = meta:get_inventory()
-                       inv:set_size("src", 1)
-                       inv:set_size("src2", 1)
-                       inv:set_size("dst", 4)
-                    end,
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") or not inv:is_empty("src2") or not inv:is_empty("dst") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  else
-                     return true
-                  end
-               end,
-})
-
-minetest.register_node(
-   "technic:alloy_furnace_active",
-   {
-      description = "Alloy Furnace",
-      tiles = {"technic_alloy_furnace_top.png", "technic_machine_bottom.png", "technic_alloy_furnace_side.png",
-              "technic_alloy_furnace_side.png", "technic_alloy_furnace_side.png", "technic_alloy_furnace_front_active.png"},
-      paramtype2 = "facedir",
-      light_source = 8,
-      drop = "technic:alloy_furnace",
-      groups = {cracky=2,not_in_creative_inventory=1},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_stone_defaults(),
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") or not inv:is_empty("src2") or not inv:is_empty("dst") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  else
-                     return true
-                  end
-               end,
-   })
-
-minetest.register_abm(
-   { nodenames = {"technic:alloy_furnace","technic:alloy_furnace_active"},
-     interval = 1,
-     chance   = 1,
-     action = function(pos, node, active_object_count, active_object_count_wider)
-                local meta         = minetest.env:get_meta(pos)
-                local eu_input     = meta:get_int("LV_EU_input")
-                local state        = meta:get_int("state")
-                local next_state   = state
-
-                -- Machine information
-                local machine_name         = "Electric Alloy Furnace"
-                local machine_node         = "technic:alloy_furnace"
-                local machine_state_demand = { 50, 600 }
-
-                -- Setup meta data if it does not exist. state is used as an indicator of this
-                if state == 0 then
-                   meta:set_int("state", 1)
-                   meta:set_int("LV_EU_demand", machine_state_demand[1])
-                   meta:set_int("LV_EU_input", 0)
-                   meta:set_int("tube_time", 0)
-                   return
-                end
-                        
-                -- Power off automatically if no longer connected to a switching station
-                technic.switching_station_timeout_count(pos, "LV")
-                        
-                -- State machine
-                if eu_input == 0 then
-                   -- Unpowered - go idle
-                   hacky_swap_node(pos, machine_node)
-                   meta:set_string("infotext", machine_name.." Unpowered")
-                   next_state = 1
-                elseif eu_input == machine_state_demand[state] then
-                   -- Powered - do the state specific actions
-                           
-                   -- Execute always if powered logic
-                   local inv    = meta:get_inventory()
-                   local empty  = 1
-                   local recipe = nil
-                   local result = nil
-
-                   -- Get what to cook if anything
-                   local srcstack  = inv:get_stack("src", 1)
-                   local src2stack = inv:get_stack("src2", 1)
-                   local src_item1 = nil
-                   local src_item2 = nil
-                   if srcstack and src2stack then
-                      src_item1 = srcstack:to_table()
-                      src_item2 = src2stack:to_table()
-                      empty     = 0
-                   end
-              
-                   if src_item1 and src_item2 then
-                      recipe = technic.get_alloy_recipe(src_item1,src_item2)
-                   end
-                   if recipe then
-                      result = { name=recipe.dst_name, count=recipe.dst_count}
-                   end
-
-                   if recipe then
-                      print("recipe "..recipe.dst_name.." : result "..result.name.." : empty "..empty.." : src_item1 "..src_item1.name.." : src_item2 "..src_item2.name)
-                   end
-
-                   if state == 1 then
-                      hacky_swap_node(pos, machine_node)
-                      meta:set_string("infotext", machine_name.." Idle")
-                      
-                      if empty == 0 and recipe and inv:room_for_item("dst", result) then
-                         meta:set_string("infotext", machine_name.." Active")
-                         meta:set_string("src_time", 0)
-                         next_state = 2
-                      end
-
-                   elseif state == 2 then
-                      hacky_swap_node(pos, machine_node.."_active")
-                      meta:set_int("src_time", meta:get_int("src_time") + 1)
-                      if meta:get_int("src_time") == 4 then -- 4 ticks per output
-                         meta:set_string("src_time", 0)
-                         -- check if there's room for output in "dst" list and that we have the materials
-                         if recipe and inv:room_for_item("dst", result) then
-                            -- Take stuff from "src" list
-                            srcstack:take_item(recipe.src1_count)
-                            inv:set_stack("src", 1, srcstack)
-                            src2stack:take_item(recipe.src2_count)
-                            inv:set_stack("src2", 1, src2stack)
-                          -- Put result in "dst" list
-                            inv:add_item("dst",result)
-                         else
-                            next_state = 1
-                         end
-                      end
-                   end
-                   -- Change state?
-                   if next_state ~= state then
-                      meta:set_int("LV_EU_demand", machine_state_demand[next_state])
-                      meta:set_int("state", next_state)
-                   end
-                end
-             end,
-  })
-
-technic.register_LV_machine ("technic:alloy_furnace","RE")
-technic.register_LV_machine ("technic:alloy_furnace_active","RE")
-
---------------------------------------------------
--- coal driven alloy furnace. This uses no EUs:
---------------------------------------------------
-coal_alloy_furnace_formspec =
-       "size[8,9]"..
-       "label[0,0;Alloy Furnace]"..
-       "image[2,2;1,1;default_furnace_fire_bg.png]"..
-       "list[current_name;fuel;2,3;1,1;]"..
-       "list[current_name;src;2,1;1,1;]"..
-       "list[current_name;src2;3,1;1,1;]"..
-       "list[current_name;dst;5,1;2,2;]"..
-       "list[current_player;main;0,5;8,4;]"
-
-minetest.register_node("technic:coal_alloy_furnace", {
-       description = "Alloy Furnace",
-       tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", "technic_coal_alloy_furnace_side.png",
-               "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front.png"},
-       paramtype2 = "facedir",
-       groups = {cracky=2},
-       legacy_facedir_simple = true,
-       sounds = default.node_sound_stone_defaults(),
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_string("formspec", coal_alloy_furnace_formspec)
-               meta:set_string("infotext", "Alloy Furnace")
-               local inv = meta:get_inventory()
-               inv:set_size("fuel", 1)
-               inv:set_size("src", 1)
-               inv:set_size("src2", 1)
-               inv:set_size("dst", 4)
-       end,
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               if not (inv:is_empty("fuel") or inv:is_empty("dst") or inv:is_empty("src") or inv:is_empty("src2") )then
-                       return false
-                       end
-               return true
-       end,
-})
-
-minetest.register_node("technic:coal_alloy_furnace_active", {
-       description = "Alloy Furnace",
-       tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", "technic_coal_alloy_furnace_side.png",
-               "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front_active.png"},
-       paramtype2 = "facedir",
-       light_source = 8,
-       drop = "technic:coal_alloy_furnace",
-       groups = {cracky=2, not_in_creative_inventory=1},
-       legacy_facedir_simple = true,
-       sounds = default.node_sound_stone_defaults(),
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               if not (inv:is_empty("fuel") or inv:is_empty("dst") or inv:is_empty("src") or inv:is_empty("src2") )then
-                       return false
-                       end
-               return true
-       end,
-})
-
-minetest.register_abm({
-       nodenames = {"technic:coal_alloy_furnace","technic:coal_alloy_furnace_active"},
-       interval = 1,
-       chance = 1,
-
-       action = function(pos, node, active_object_count, active_object_count_wider)
-               local meta = minetest.env:get_meta(pos)
-               for i, name in pairs({
-                               "fuel_totaltime",
-                               "fuel_time",
-                               "src_totaltime",
-                               "src_time"
-               }) do
-                       if meta:get_string(name) == "" then
-                               meta:set_float(name, 0.0)
-                       end
-               end
-
-               local inv    = meta:get_inventory()
-               local recipe = nil
-
-               -- Get what to cook if anything
-               local srcstack = inv:get_stack("src", 1)
-               if srcstack then src_item1=srcstack:to_table() end
-               
-               local src2stack = inv:get_stack("src2", 1)
-               if src2stack then src_item2=src2stack:to_table() end
-               
-               if src_item1 and src_item2 then
-                  recipe = technic.get_alloy_recipe(src_item1,src_item2)
-               end
-
-               local was_active = false
-
-               if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
-                  was_active = true
-                  meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
-                  meta:set_float("src_time", meta:get_float("src_time") + 1)
-                  if recipe and meta:get_float("src_time") == 6 then
-                     -- check if there's room for output in "dst" list
-                     local dst_stack = { name=recipe.dst_name, count=recipe.dst_count}
-                     if inv:room_for_item("dst",dst_stack) then
-                        -- Take stuff from "src" list
-                        srcstack:take_item(recipe.src1_count)
-                        inv:set_stack("src", 1, srcstack)
-                        src2stack:take_item(recipe.src2_count)
-                        inv:set_stack("src2", 1, src2stack)
-                        -- Put result in "dst" list
-                        inv:add_item("dst",dst_stack)
-                     else
-                        print("Furnace inventory full!") -- Silly code...
-                     end
-                     meta:set_string("src_time", 0)
-                  end
-               end
-               
-               if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
-                  local percent = math.floor(meta:get_float("fuel_time") /
-                                          meta:get_float("fuel_totaltime") * 100)
-                  meta:set_string("infotext","Furnace active: "..percent.."%")
-                  hacky_swap_node(pos,"technic:coal_alloy_furnace_active")
-                  meta:set_string("formspec",
-                                  "size[8,9]"..
-                                     "label[0,0;Electric Alloy Furnace]"..
-                                     "image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
-                                     (100-percent)..":default_furnace_fire_fg.png]"..
-                                  "list[current_name;fuel;2,3;1,1;]"..
-                                  "list[current_name;src;2,1;1,1;]"..
-                                  "list[current_name;src2;3,1;1,1;]"..
-                                  "list[current_name;dst;5,1;2,2;]"..
-                                  "list[current_player;main;0,5;8,4;]")
-                  return
-               end
-
-               -- FIXME: Make this look more like the electrical version.
-               -- This code refetches the recipe to see if it can be done again after the iteration
-               srcstack = inv:get_stack("src", 1)
-               if srcstack then src_item1=srcstack:to_table() end
-               srcstack = inv:get_stack("src2", 1)
-               if srcstack then src_item2=srcstack:to_table() end
-               if src_item1 and src_item2 then
-                  recipe = technic.get_alloy_recipe(src_item1,src_item2)
-               end
-
-               if recipe==nil then
-                  if was_active then
-                     meta:set_string("infotext","Furnace is empty")
-                     hacky_swap_node(pos,"technic:coal_alloy_furnace")
-                     meta:set_string("formspec", coal_alloy_furnace_formspec)
-                  end
-                  return
-               end
-
-               -- Next take a hard look at the fuel situation
-               local fuel = nil
-               local fuellist = inv:get_list("fuel")
-
-               if fuellist then
-                  fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
-               end
-
-               if fuel.time <= 0 then
-                  meta:set_string("infotext","Furnace out of fuel")
-                  hacky_swap_node(pos,"technic:coal_alloy_furnace")
-                  meta:set_string("formspec", coal_alloy_furnace_formspec)
-                  return
-               end
-
-               meta:set_string("fuel_totaltime", fuel.time)
-               meta:set_string("fuel_time", 0)
-
-               local stack = inv:get_stack("fuel", 1)
-               stack:take_item()
-               inv:set_stack("fuel", 1, stack)
-            end,
-     })
-
diff --git a/technic/alloy_furnace_mv.lua b/technic/alloy_furnace_mv.lua
deleted file mode 100644 (file)
index cadcb67..0000000
+++ /dev/null
@@ -1,459 +0,0 @@
--- MV alloy furnace
-
-minetest.register_craft({
-       output = 'technic:mv_alloy_furnace',
-       recipe = {
-               {'technic:stainless_steel_ingot', 'technic:alloy_furnace', 'technic:stainless_steel_ingot'},
-               {'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
-               {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
-       }
-})
-
-local mv_alloy_furnace_formspec =
-       "invsize[8,10;]"..
-       "label[0,0;MV Alloy Furnace]"..
-        "list[current_name;src;3,1;1,2;]"..
-       "list[current_name;dst;5,1;2,2;]"..
-       "list[current_player;main;0,6;8,4;]"..
-       "list[current_name;upgrade1;1,4;1,1;]"..
-       "list[current_name;upgrade2;2,4;1,1;]"..
-       "label[1,5;Upgrade Slots]"
-       
-minetest.register_node(
-   "technic:mv_alloy_furnace",
-   {description = "MV Alloy Furnace",
-    tiles = {"technic_mv_alloy_furnace_top.png", "technic_mv_alloy_furnace_bottom.png", "technic_mv_alloy_furnace_side_tube.png",
-            "technic_mv_alloy_furnace_side_tube.png", "technic_mv_alloy_furnace_side.png", "technic_mv_alloy_furnace_front.png"},
-    paramtype2 = "facedir",
-    groups = {cracky=2, tubedevice=1,tubedevice_receiver=1},
-    tube={insert_object=function(pos,node,stack,direction)
-                          local meta=minetest.env:get_meta(pos)
-                          local inv=meta:get_inventory()
-                          return inv:add_item("src",stack)
-                       end,
-         can_insert=function(pos,node,stack,direction)
-                       local meta=minetest.env:get_meta(pos)
-                       local inv=meta:get_inventory()
-                       return inv:room_for_item("src",stack)
-                    end,
-       },
-    legacy_facedir_simple = true,
-    sounds = default.node_sound_stone_defaults(),
-    on_construct = function(pos)
-                     local meta = minetest.env:get_meta(pos)
-                     meta:set_string("infotext", "MV Alloy furnace")
-                     meta:set_float("technic_mv_power_machine", 1)
-                     meta:set_int("tube_time",  0)
-                     meta:set_string("formspec", mv_alloy_furnace_formspec)
-                     local inv = meta:get_inventory()
-                     inv:set_size("src", 2)
-                     inv:set_size("dst", 4)
-                     inv:set_size("upgrade1", 1)
-                     inv:set_size("upgrade2", 1)
-                  end,
-    can_dig = function(pos,player)
-                local meta = minetest.env:get_meta(pos);
-                local inv = meta:get_inventory()
-                if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
-                   minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                   return false
-                else
-                   return true
-                end
-             end,
-})
-
-minetest.register_node(
-   "technic:mv_alloy_furnace_active",
-   {description = "MV Alloy Furnace",
-    tiles = {"technic_mv_alloy_furnace_top.png", "technic_mv_alloy_furnace_bottom.png", "technic_mv_alloy_furnace_side_tube.png",
-            "technic_mv_alloy_furnace_side_tube.png", "technic_mv_alloy_furnace_side.png", "technic_mv_alloy_furnace_front_active.png"},
-    paramtype2 = "facedir",
-    light_source = 8,
-    drop = "technic:mv_alloy_furnace",
-    groups = {cracky=2, tubedevice=1,tubedevice_receiver=1,not_in_creative_inventory=1},
-    tube={insert_object=function(pos,node,stack,direction)
-                          local meta=minetest.env:get_meta(pos)
-                          local inv=meta:get_inventory()
-                          return inv:add_item("src",stack)
-                       end,
-         can_insert=function(pos,node,stack,direction)
-                       local meta=minetest.env:get_meta(pos)
-                       local inv=meta:get_inventory()
-                       return inv:room_for_item("src",stack)
-                    end,
-       },
-    legacy_facedir_simple = true,
-    sounds = default.node_sound_stone_defaults(),
-    can_dig = function(pos,player)
-                local meta = minetest.env:get_meta(pos);
-                local inv = meta:get_inventory()
-                if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
-                   minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                   return false
-                else
-                   return true
-                end
-             end,
-    -- These three makes sure upgrades are not moved in or out while the furnace is active.
-    allow_metadata_inventory_put = function(pos, listname, index, stack, player)
-                                      if listname == "src" or listname == "dst" then
-                                         return 99
-                                      else
-                                         return 0 -- Disallow the move
-                                      end
-                                  end,
-    allow_metadata_inventory_take = function(pos, listname, index, stack, player)
-                                      if listname == "src" or listname == "dst" then
-                                         return 99
-                                      else
-                                         return 0 -- Disallow the move
-                                      end
-                                   end,
-    allow_metadata_inventory_move = function(pos, from_list, to_list, to_list, to_index, count, player)
-                                   return 0
-                                end,
-})
-
-local send_cooked_items = function(pos,x_velocity,z_velocity)
-                            -- Send items on their way in the pipe system.
-                            local meta=minetest.env:get_meta(pos) 
-                            local inv = meta:get_inventory()
-                            local i=0
-                            for _,stack in ipairs(inv:get_list("dst")) do
-                               i=i+1
-                               if stack then
-                                  local item0=stack:to_table()
-                               if item0 then 
-                                  item0["count"]="1"
-                                  local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
-                                  item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
-                                  item1:setvelocity({x=x_velocity, y=0, z=z_velocity})
-                                  item1:setacceleration({x=0, y=0, z=0})
-                                  stack:take_item(1);
-                                  inv:set_stack("dst", i, stack)
-                                  return
-                               end
-                            end
-                         end
-                      end
-
-local smelt_item = function(pos)
-                     local meta=minetest.env:get_meta(pos) 
-                     local inv = meta:get_inventory()
-                     meta:set_int("src_time", meta:get_int("src_time") + 3) -- Cooking time 3x faster
-                     local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
-                     dst_stack={}
-                     dst_stack["name"]=alloy_recipes[dst_index].dst_name
-                     dst_stack["count"]=alloy_recipes[dst_index].dst_count
-
-                     if result and result.item and meta:get_int("src_time") >= result.time then
-                        meta:set_int("src_time", 0)
-                        -- check if there's room for output in "dst" list
-                        if inv:room_for_item("dst",result) then
-                           -- take stuff from "src" list
-                           srcstack = inv:get_stack("src", 1)
-                           srcstack:take_item()
-                           inv:set_stack("src", 1, srcstack)
-                           -- Put result in "dst" list
-                           inv:add_item("dst", result.item)
-                           return 1
-                        else
-                           return 0 -- done
-                        end
-                     end
-                     return 0 -- done
-                  end
-
-minetest.register_abm(
-   {nodenames = {"technic:mv_alloy_furnace","technic:mv_alloy_furnace_active"},
-    interval = 1,
-    chance = 1,
-
-    action = function(pos, node, active_object_count, active_object_count_wider)
-               local meta         = minetest.env:get_meta(pos)
-               local eu_input     = meta:get_int("MV_EU_input")
-               local state        = meta:get_int("state")
-               local next_state   = state
-
-               -- Machine information
-               local machine_name         = "MV Alloy Furnace"
-               local machine_node         = "technic:mv_alloy_furnace"
-               local machine_state_demand = { 50, 2000, 1500, 1000 }
-               
-               -- Setup meta data if it does not exist. state is used as an indicator of this
-               if state == 0 then
-                  meta:set_int("state", 1)
-                  meta:set_int("MV_EU_demand", machine_state_demand[1])
-                  meta:set_int("MV_EU_input", 0)
-                  return
-               end
-               
-               -- Power off automatically if no longer connected to a switching station
-               technic.switching_station_timeout_count(pos, "MV")
-               
-               -- Execute always logic
-               -- CODE HERE --
-
-               -- State machine
-               if eu_input == 0 then
-                  -- Unpowered - go idle
-                  hacky_swap_node(pos, machine_node)
-                  meta:set_string("infotext", machine_name.." Unpowered")
-                  next_state = 1
-               elseif eu_input == machine_state_demand[state] then
-                  -- Powered - do the state specific actions
-                  
-                  -- Execute always if powered logic
-                  local meta=minetest.env:get_meta(pos) 
-                  
-                  -- Get the names of the upgrades
-                  local meta=minetest.env:get_meta(pos) 
-                  local inv = meta:get_inventory()
-                  local upg_item1
-                  local upg_item1_name=""
-                  local upg_item2
-                  local upg_item2_name=""
-                  local srcstack = inv:get_stack("upgrade1", 1)
-                  if  srcstack then upg_item1=srcstack:to_table() end
-                  srcstack = inv:get_stack("upgrade2", 1)
-                  if  srcstack then upg_item2=srcstack:to_table() end
-                  if upg_item1 then upg_item1_name=upg_item1.name end
-                  if upg_item2 then upg_item2_name=upg_item2.name end
-                  
-                  -- Save some power by installing battery upgrades. Fully upgraded makes this
-                  -- furnace use the same amount of power as the LV version
-                  local EU_saving_upgrade = 0
-                  if upg_item1_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
-                  if upg_item2_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
-                  
-                  -- Tube loading speed can be upgraded using control logic units
-                  local tube_speed_upgrade = 0
-                  if upg_item1_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
-                  if upg_item2_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
-                  
-                  -- Handle pipeworks (consumes tube_speed_upgrade)
-                  local pos1={x=pos.x, y=pos.y, z=pos.z}
-                  local x_velocity=0
-                  local z_velocity=0
-                  
-                  -- Output is on the left side of the furnace
-                  if node.param2==3 then pos1.z=pos1.z-1 z_velocity =-1 end
-                  if node.param2==2 then pos1.x=pos1.x-1 x_velocity =-1 end
-                  if node.param2==1 then pos1.z=pos1.z+1 z_velocity = 1 end
-                  if node.param2==0 then pos1.x=pos1.x+1 x_velocity = 1 end
-                  
-                  local output_tube_connected = false
-                  local meta1 = minetest.env:get_meta(pos1) 
-                  if meta1:get_int("tubelike") == 1 then
-                     output_tube_connected=true
-                  end
-                  tube_time = meta:get_int("tube_time")
-                  tube_time = tube_time + tube_speed_upgrade
-                  if tube_time > 3 then
-                     tube_time = 0
-                     if output_tube_connected then
-                        send_cooked_items(pos,x_velocity,z_velocity)
-                     end
-                  end
-                  meta:set_int("tube_time", tube_time)
-
-                  -- The machine shuts down if we have nothing to smelt and no tube is connected
-                  -- or if we have nothing to send with a tube connected.
-                  if    (not output_tube_connected and inv:is_empty("src"))
-                     or (    output_tube_connected and inv:is_empty("dst")) then
-                     next_state = 1
-                  end
-                  ----------------------
-                  local empty  = 1
-                  local recipe = nil
-                  local result = nil
-
-                  -- Get what to cook if anything
-                  local srcstack  = inv:get_stack("src", 1)
-                  local src2stack = inv:get_stack("src", 2)
-                  local src_item1 = nil
-                  local src_item2 = nil
-                  if srcstack and src2stack then
-                     src_item1 = srcstack:to_table()
-                     src_item2 = src2stack:to_table()
-                     empty     = 0
-                  end
-                  
-                  if src_item1 and src_item2 then
-                     recipe = technic.get_alloy_recipe(src_item1,src_item2)
-                  end
-                  if recipe then
-                     result = { name=recipe.dst_name, count=recipe.dst_count}
-                  end
-                  
-                  if state == 1 then
-                     hacky_swap_node(pos, machine_node)
-                     meta:set_string("infotext", machine_name.." Idle")
-                     
-                     local meta=minetest.env:get_meta(pos) 
-                     local inv = meta:get_inventory()
-                     if not inv:is_empty("src") then
-                        if empty == 0 and recipe and inv:room_for_item("dst", result) then
-                           meta:set_string("infotext", machine_name.." Active")
-                           meta:set_int("src_time",     0)
-                           next_state = 2+EU_saving_upgrade -- Next state is decided by the battery upgrade (state 2= 0 batteries, state 3 = 1 battery, 4 = 2 batteries)
-                        end
-                     end
-                     
-                  elseif state == 2 or state == 3 or state == 4 then
-                     hacky_swap_node(pos, machine_node.."_active")
-                     meta:set_int("src_time", meta:get_int("src_time") + 1)
-                     if meta:get_int("src_time") == 4 then -- 4 ticks per output
-                        meta:set_string("src_time", 0)
-                        -- check if there's room for output in "dst" list and that we have the materials
-                        if recipe and inv:room_for_item("dst", result) then
-                           -- Take stuff from "src" list
-                           srcstack:take_item(recipe.src1_count)
-                           inv:set_stack("src", 1, srcstack)
-                           src2stack:take_item(recipe.src2_count)
-                           inv:set_stack("src2", 1, src2stack)
-                           -- Put result in "dst" list
-                           inv:add_item("dst",result)
-                        else
-                           next_state = 1
-                        end
-                     end
-                  end
-               end
-               -- Change state?
-               if next_state ~= state then
-                  meta:set_int("MV_EU_demand", machine_state_demand[next_state])
-                  meta:set_int("state", next_state)
-               end
-
-
-
-            ------------------------------------
-
---          local pos1={}
---          pos1.x=pos.x
---          pos1.y=pos.y
---          pos1.z=pos.z
---          local x_velocity=0
---          local z_velocity=0
---
---          -- output is on the left side of the furnace
---          if node.param2==3 then pos1.z=pos1.z-1 z_velocity =-1 end
---          if node.param2==2 then pos1.x=pos1.x-1 x_velocity =-1 end
---          if node.param2==1 then pos1.z=pos1.z+1 z_velocity = 1 end
---          if node.param2==0 then pos1.x=pos1.x+1 x_velocity = 1 end
---
---          local output_tube_connected = false
---          local meta=minetest.env:get_meta(pos1) 
---          if meta:get_int("tubelike")==1 then output_tube_connected=true end
---          meta = minetest.env:get_meta(pos)
---          local inv = meta:get_inventory()
---          local upg_item1
---          local upg_item1_name=""
---          local upg_item2
---          local upg_item2_name=""
---          local srcstack = inv:get_stack("upgrade1", 1)
---          if srcstack then upg_item1=srcstack:to_table() end
---          srcstack = inv:get_stack("upgrade2", 1)
---          if srcstack then upg_item2=srcstack:to_table() end
---          if upg_item1 then upg_item1_name=upg_item1.name end
---          if upg_item2 then upg_item2_name=upg_item2.name end
---
---          local speed=0
---          if upg_item1_name=="technic:control_logic_unit" then speed=speed+1 end
---          if upg_item2_name=="technic:control_logic_unit" then speed=speed+1 end
---          tube_time=meta:get_float("tube_time")
---          tube_time=tube_time+speed
---          if tube_time>3 then 
---             tube_time=0
---             if output_tube_connected then send_cooked_items(pos,x_velocity,z_velocity) end
---          end
---          meta:set_float("tube_time", tube_time)
---
---          local extra_buffer_size = 0
---          if upg_item1_name=="technic:battery" then extra_buffer_size =extra_buffer_size + 10000 end
---          if upg_item2_name=="technic:battery" then extra_buffer_size =extra_buffer_size + 10000 end
---          local internal_EU_buffer_size=2000+extra_buffer_size
---          meta:set_float("internal_EU_buffer_size",internal_EU_buffer_size)
---
---          internal_EU_buffer=meta:get_float("internal_EU_buffer")
---          if internal_EU_buffer > internal_EU_buffer_size then internal_EU_buffer = internal_EU_buffer_size end
---          local meta = minetest.env:get_meta(pos)
---          local load = math.floor(internal_EU_buffer/internal_EU_buffer_size * 100)
---          meta:set_string("formspec",
---                          MV_alloy_furnace_formspec..
---                             "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
---                             (load)..":technic_power_meter_fg.png]")
---
---          local inv = meta:get_inventory()
---
---          local furnace_is_cookin = meta:get_int("furnace_is_cookin")
---
---          local srclist = inv:get_list("src")
---          local srclist2 = inv:get_list("src2")
---          
---          srcstack = inv:get_stack("src", 1)
---          if srcstack then src_item1=srcstack:to_table() end
---          srcstack = inv:get_stack("src", 2)
---          if srcstack then src_item2=srcstack:to_table() end
---          dst_index=nil
---
---          if src_item1 and src_item2 then 
---             dst_index=get_cook_result(src_item1,src_item2) 
---          end
---
---
---          if (furnace_is_cookin == 1) then
---             if internal_EU_buffer>=150 then
---                internal_EU_buffer=internal_EU_buffer-150;
---                meta:set_float("internal_EU_buffer",internal_EU_buffer)
---                meta:set_float("src_time", meta:get_float("src_time") + 1)
---                if dst_index and meta:get_float("src_time") >= 4 then
---                   -- check if there's room for output in "dst" list
---                   dst_stack={}
---                   dst_stack["name"]=alloy_recipes[dst_index].dst_name
---                   dst_stack["count"]=alloy_recipes[dst_index].dst_count
---                   if inv:room_for_item("dst",dst_stack) then
---                      -- Put result in "dst" list
---                      inv:add_item("dst",dst_stack)
---                      -- take stuff from "src" list
---                      for i=1,alloy_recipes[dst_index].src1_count,1 do
---                         srcstack = inv:get_stack("src", 1)
---                         srcstack:take_item()
---                         inv:set_stack("src", 1, srcstack)
---                      end
---                      for i=1,alloy_recipes[dst_index].src2_count,1 do
---                         srcstack = inv:get_stack("src", 2)
---                         srcstack:take_item()
---                         inv:set_stack("src", 2, srcstack)
---                      end
---
---                   else
---                      print("Furnace inventory full!")
---                   end
---                   meta:set_string("src_time", 0)
---                end
---             end
---          end
---
---          if dst_index and meta:get_int("furnace_is_cookin")==0 then
---             hacky_swap_node(pos,"technic:mv_alloy_furnace_active")
---             meta:set_string("infotext","MV Alloy Furnace active")
---             meta:set_int("furnace_is_cookin",1)
---             meta:set_string("src_time", 0)
---             return
---          end
---
---          if meta:get_int("furnace_is_cookin")==0 or dst_index==nil then
---             hacky_swap_node(pos,"technic:mv_alloy_furnace")
---             meta:set_string("infotext","MV Alloy Furnace inactive")
---             meta:set_int("furnace_is_cookin",0)
---             meta:set_string("src_time", 0)
---          end
---
-         end,
- })
-
-technic.register_MV_machine ("technic:mv_alloy_furnace","RE")
-technic.register_MV_machine ("technic:mv_alloy_furnace_active","RE")
diff --git a/technic/alloy_furnaces_commons.lua b/technic/alloy_furnaces_commons.lua
deleted file mode 100644 (file)
index 15996d0..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
--- Register alloy recipes
-technic.alloy_recipes = {}
-
--- Register recipe in a table
-technic.register_alloy_recipe = function(metal1, count1, metal2, count2, result, count3)
-                                  technic.alloy_recipes[metal1..metal2] = { src1_count = count1, src2_count = count2, dst_name = result, dst_count = count3 }
-                                  if unified_inventory then
-                                     unified_inventory.register_craft(
-                                        {
-                                           type = "alloy",
-                                           output = result.." "..count3,
-                                           items = {metal1.." "..count1,metal2.." "..count2},
-                                           width = 2,
-                                        })
-                                  end
-                               end
-
--- Retrieve a recipe given the input metals.
--- Input parameters are a table from a StackItem
-technic.get_alloy_recipe = function(metal1, metal2)
-                             -- Check for both combinations of metals and for the right amount in both
-                             if technic.alloy_recipes[metal1.name..metal2.name]
-                                and metal1.count >= technic.alloy_recipes[metal1.name..metal2.name].src1_count
-                                and metal2.count >= technic.alloy_recipes[metal1.name..metal2.name].src2_count then
-                                return technic.alloy_recipes[metal1.name..metal2.name]
-                             elseif technic.alloy_recipes[metal2.name..metal1.name]
-                                and metal2.count >= technic.alloy_recipes[metal2.name..metal1.name].src1_count
-                                and metal1.count >= technic.alloy_recipes[metal2.name..metal1.name].src2_count then
-                                return technic.alloy_recipes[metal2.name..metal1.name]
-                             else
-                                return nil
-                             end
-                          end
-
-technic.register_alloy_recipe("technic:copper_dust",  3, "technic:tin_dust",      1, "technic:bronze_dust",          4)
-technic.register_alloy_recipe("moreores:copper_ingot",3, "moreores:tin_ingot",    1, "moreores:bronze_ingot",        4)
-technic.register_alloy_recipe("technic:iron_dust",    3, "technic:chromium_dust", 1, "technic:stainless_steel_dust", 4)
-technic.register_alloy_recipe("default:steel_ingot",  3, "technic:chromium_ingot",1, "technic:stainless_steel_ingot",4)
-technic.register_alloy_recipe("technic:copper_dust",  2, "technic:zinc_dust",     1, "technic:brass_dust",           3)
-technic.register_alloy_recipe("moreores:copper_ingot",2, "technic:zinc_ingot",    1, "technic:brass_ingot",          3)
-technic.register_alloy_recipe("default:sand",         2, "technic:coal_dust",     2, "technic:silicon_wafer",        1)
-technic.register_alloy_recipe("technic:silicon_wafer",1, "technic:gold_dust",     1, "technic:doped_silicon_wafer",  1)
-
---------------------------------------
--- LEGACY CODE - some other mods might depend on this - Register the same recipes as above...
---------------------------------------
-alloy_recipes = {}
-registered_recipes_count = 1
-
-function register_alloy_recipe (string1,count1, string2,count2, string3,count3)
-   alloy_recipes[registered_recipes_count]={}
-   alloy_recipes[registered_recipes_count].src1_name=string1
-   alloy_recipes[registered_recipes_count].src1_count=count1
-   alloy_recipes[registered_recipes_count].src2_name=string2
-   alloy_recipes[registered_recipes_count].src2_count=count2
-   alloy_recipes[registered_recipes_count].dst_name=string3
-   alloy_recipes[registered_recipes_count].dst_count=count3
-   registered_recipes_count=registered_recipes_count+1
-   alloy_recipes[registered_recipes_count]={}
-   alloy_recipes[registered_recipes_count].src1_name=string2
-   alloy_recipes[registered_recipes_count].src1_count=count2
-   alloy_recipes[registered_recipes_count].src2_name=string1
-   alloy_recipes[registered_recipes_count].src2_count=count1
-   alloy_recipes[registered_recipes_count].dst_name=string3
-   alloy_recipes[registered_recipes_count].dst_count=count3
-   registered_recipes_count=registered_recipes_count+1
-   if unified_inventory then
-      unified_inventory.register_craft({
-                 type = "alloy",
-                 output = string3.." "..count3,
-                 items = {string1.." "..count1,string2.." "..count2},
-                 width = 2,
-              })
-   end
-end
-
-register_alloy_recipe ("technic:copper_dust",3, "technic:tin_dust",1, "technic:bronze_dust",4)
-register_alloy_recipe ("default:copper_ingot",3, "moreores:tin_ingot",1, "default:bronze_ingot",4)
-register_alloy_recipe ("technic:iron_dust",3, "technic:chromium_dust",1, "technic:stainless_steel_dust",4)
-register_alloy_recipe ("default:steel_ingot",3, "technic:chromium_ingot",1, "technic:stainless_steel_ingot",4)
-register_alloy_recipe ("technic:copper_dust",2, "technic:zinc_dust",1, "technic:brass_dust",3)
-register_alloy_recipe ("default:copper_ingot",2, "technic:zinc_ingot",1, "technic:brass_ingot",3)
-register_alloy_recipe ("default:sand",2, "technic:coal_dust",2, "technic:silicon_wafer",1)
-register_alloy_recipe ("technic:silicon_wafer",1, "technic:gold_dust",1, "technic:doped_silicon_wafer",1)
-
diff --git a/technic/alloy_furnaces_commons.lua~ b/technic/alloy_furnaces_commons.lua~
deleted file mode 100644 (file)
index 9c9c42a..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-alloy_recipes ={}
-
-registered_recipes_count=1
-
-function register_alloy_recipe (string1,count1, string2,count2, string3,count3)
-alloy_recipes[registered_recipes_count]={}
-alloy_recipes[registered_recipes_count].src1_name=string1
-alloy_recipes[registered_recipes_count].src1_count=count1
-alloy_recipes[registered_recipes_count].src2_name=string2
-alloy_recipes[registered_recipes_count].src2_count=count2
-alloy_recipes[registered_recipes_count].dst_name=string3
-alloy_recipes[registered_recipes_count].dst_count=count3
-registered_recipes_count=registered_recipes_count+1
-alloy_recipes[registered_recipes_count]={}
-alloy_recipes[registered_recipes_count].src1_name=string2
-alloy_recipes[registered_recipes_count].src1_count=count2
-alloy_recipes[registered_recipes_count].src2_name=string1
-alloy_recipes[registered_recipes_count].src2_count=count1
-alloy_recipes[registered_recipes_count].dst_name=string3
-alloy_recipes[registered_recipes_count].dst_count=count3
-registered_recipes_count=registered_recipes_count+1
-if unified_inventory then
-       unified_inventory.register_craft({
-       type = "alloy",
-       output = string3.." "..count3,
-       items = {string1.." "..count1,string2.." "..count2},
-       width = 2,
-       })
-       end
-end
-
-register_alloy_recipe ("technic:copper_dust",3, "technic:tin_dust",1, "technic:bronze_dust",4)
-register_alloy_recipe ("moreores:copper_ingot",3, "moreores:tin_ingot",1, "moreores:bronze_ingot",4)
-register_alloy_recipe ("technic:iron_dust",3, "technic:chromium_dust",1, "technic:stainless_steel_dust",4)
-register_alloy_recipe ("default:steel_ingot",3, "technic:chromium_ingot",1, "technic:stainless_steel_ingot",4)
-register_alloy_recipe ("technic:copper_dust",2, "technic:zinc_dust",1, "technic:brass_dust",3)
-register_alloy_recipe ("moreores:copper_ingot",2, "technic:zinc_ingot",1, "technic:brass_ingot",3)
-register_alloy_recipe ("default:sand",2, "technic:coal_dust",2, "technic:silicon_wafer",1)
-register_alloy_recipe ("technic:silicon_wafer",1, "technic:gold_dust",1, "technic:doped_silicon_wafer",1)
diff --git a/technic/battery_box.lua b/technic/battery_box.lua
deleted file mode 100644 (file)
index 3a2272a..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
--- 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)
-
-minetest.register_craft({
-       output = 'technic:battery 1',
-       recipe = {
-               {'default:wood', 'default:copper_ingot', 'default:wood'},
-               {'default:wood', 'moreores:tin_ingot',   'default:wood'},
-               {'default:wood', 'default:copper_ingot', 'default:wood'},
-       }
-})
-
-minetest.register_tool("technic:battery", {
-       description = "RE Battery",
-       inventory_image = "technic_battery.png",
-       tool_capabilities = {
-               load=0,
-               max_drop_level=0,
-               groupcaps={
-                       fleshy={times={}, uses=10000, maxlevel=0}
-               }
-       }
-})
-
---------------------------------------------
--- The Battery box
---------------------------------------------
-minetest.register_craftitem("technic:battery_box", {
-       description = "Battery box",
-       stack_max = 99,
-})
-
-minetest.register_craft({
-       output = 'technic:battery_box 1',
-       recipe = {
-               {'technic:battery',     'default:wood',         'technic:battery'},
-               {'technic:battery',     'default:copper_ingot', 'technic:battery'},
-               {'default:steel_ingot', 'default:steel_ingot',  'default:steel_ingot'},
-       }
-})
-
-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;Battery box]"..
-       "label[3,0;Charge]"..
-       "label[5,0;Discharge]"..
-       "label[1,3;Power level]"..
-       "list[current_player;main;0,5;8,4;]"
-
-minetest.register_node("technic:battery_box", {
-       description = "LV Battery Box",
-       tiles = {"technic_battery_box_top.png", "technic_battery_box_bottom.png",
-                "technic_battery_box_side0.png", "technic_battery_box_side0.png",
-                "technic_battery_box_side0.png", "technic_battery_box_side0.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       sounds = default.node_sound_wood_defaults(),
-       drop="technic:battery_box",
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               local inv = meta:get_inventory()
-               meta:set_string("infotext", "Battery box")
-               meta:set_float("technic_power_machine", 1)
-               meta:set_string("formspec", battery_box_formspec)
-               meta:set_int("LV_EU_demand", 0) -- How much can this node charge
-               meta:set_int("LV_EU_supply", 0) -- How much can this node discharge
-               meta:set_int("LV_EU_input",  0) -- How much power is this machine getting.
-               meta:set_float("internal_EU_charge", 0)
-               inv:set_size("src", 1)
-               inv:set_size("dst", 1)
-       end,
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               if not inv:is_empty("src") or not inv:is_empty("dst") then
-                       minetest.chat_send_player(player:get_player_name(),
-                               "Machine cannot be removed because it is not empty");
-                       return false
-               else
-                       return true
-               end
-       end,
-})
-
-
-for i=1,8,1 do
-   minetest.register_node(
-      "technic:battery_box"..i, {
-        description = "LV Battery Box",
-        tiles = {"technic_battery_box_top.png", "technic_battery_box_bottom.png",
-                 "technic_battery_box_side0.png^technic_power_meter"..i..".png",
-                 "technic_battery_box_side0.png^technic_power_meter"..i..".png",
-                 "technic_battery_box_side0.png^technic_power_meter"..i..".png",
-                 "technic_battery_box_side0.png^technic_power_meter"..i..".png"},
-        groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
-        sounds = default.node_sound_wood_defaults(),
-        drop="technic:battery_box",
-        can_dig = function(pos,player)
-                     local meta = minetest.env:get_meta(pos);
-                     local inv = meta:get_inventory()
-                     if not inv:is_empty("src") or not inv:is_empty("dst") then
-                        minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                        return false
-                     else
-                        return true
-                     end
-                  end,
-      })
-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"},
-    interval = 1,
-    chance = 1,
-    action = function(pos, node, active_object_count, active_object_count_wider)
-               local meta               = minetest.env:get_meta(pos)
-               local max_charge         = 60000 -- Set maximum charge for the device here
-               local max_charge_rate    = 1000  -- Set maximum rate of charging
-               local max_discharge_rate = 2000  -- Set maximum rate of discharging
-               local eu_input           = meta:get_int("LV_EU_input")
-               local current_charge     = meta:get_int("internal_EU_charge") -- Battery charge right now
-
-               -- Power off automatically if no longer connected to a switching station
-               technic.switching_station_timeout_count(pos, "LV")
-
-               -- Charge/discharge the battery with the input EUs
-               if eu_input >=0 then
-                  current_charge = math.min(current_charge+eu_input, max_charge)
-               else
-                  current_charge = math.max(current_charge+eu_input, 0)
-               end
-
-               -- Charging/discharging tools here
-               current_charge = charge_LV_tools(meta, current_charge)
-               current_charge = discharge_LV_tools(meta, current_charge, max_charge)
-
-               -- 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))
-               --print("BA:"..max_charge_rate.."|"..max_charge-current_charge.."|"..math.min(max_charge_rate, max_charge-current_charge))
-
-               -- Set how much we can supply
-               meta:set_int("LV_EU_supply", math.min(max_discharge_rate, current_charge))
-
-               meta:set_int("internal_EU_charge", current_charge)
-               --dprint("BA: input:"..eu_input.." supply="..meta:get_int("LV_EU_supply").." demand="..meta:get_int("LV_EU_demand").." current:"..current_charge)
-
-               -- Select node textures
-               local i=math.ceil((current_charge/max_charge)*8)
-               if i > 8 then i = 8 end
-               local j = meta:get_float("last_side_shown")
-               if i~=j then
-                  if i>0 then hacky_swap_node(pos,"technic:battery_box"..i)
-                  elseif i==0 then hacky_swap_node(pos,"technic:battery_box") end
-                  meta:set_float("last_side_shown",i)
-               end
-
-               local load = math.floor(current_charge/max_charge * 100)
-               meta:set_string("formspec",
-                               battery_box_formspec..
-                                  "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
-                                  (load)..":technic_power_meter_fg.png]"
-                            )
-
-               if eu_input == 0 then
-                  meta:set_string("infotext", "LV Battery box: "..current_charge.."/"..max_charge.." (idle)")
-               else
-                  meta:set_string("infotext", "LV Battery box: "..current_charge.."/"..max_charge)
-               end
-
-            end
- })
-
--- Register as a battery type
--- Battery type machines function as power reservoirs and can both receive and give back power
-technic.register_LV_machine("technic:battery_box","BA")
-for i=1,8,1 do
-   technic.register_LV_machine("technic:battery_box"..i,"BA")
-end
-
diff --git a/technic/battery_box_hv.lua b/technic/battery_box_hv.lua
deleted file mode 100644 (file)
index 979dc13..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
--- HV battery box
-minetest.register_craft(
-   {output = 'technic:hv_battery_box 1',
-    recipe = {
-       {'technic:mv_battery_box', 'technic:mv_battery_box', 'technic:mv_battery_box'},
-       {'technic:mv_battery_box', 'technic:hv_transformer', 'technic:mv_battery_box'},
-       {'', 'technic:hv_cable', ''},
-    }
- })
-
-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;]"
-
-minetest.register_node(
-   "technic:hv_battery_box", {
-      description = "HV Battery Box",
-      tiles = {"technic_hv_battery_box_top.png", "technic_hv_battery_box_bottom.png", "technic_hv_battery_box_side0.png",
-              "technic_hv_battery_box_side0.png", "technic_hv_battery_box_side0.png", "technic_hv_battery_box_side0.png"},
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-      sounds = default.node_sound_wood_defaults(),
-      drop="technic:hv_battery_box",
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       local inv = meta:get_inventory()
-                       meta:set_string("infotext", "HV Battery Box")
-                       meta:set_float("technic_hv_power_machine", 1)
-                       meta:set_string("formspec", battery_box_formspec)
-                       meta:set_int("HV_EU_demand", 0) -- How much can this node charge
-                       meta:set_int("HV_EU_supply", 0) -- How much can this node discharge
-                       meta:set_int("HV_EU_input",  0) -- How much power is this machine getting.
-                       meta:set_float("internal_EU_charge", 0)
-                       inv:set_size("src", 1)
-                       inv:set_size("dst", 1)
-                    end,
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") or not inv:is_empty("dst") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  else
-                     return true
-                  end
-               end,
-   })
-
-for i=1,8,1 do
-   minetest.register_node(
-      "technic:hv_battery_box"..i,
-      {description = "HV Battery Box",
-       tiles = {"technic_hv_battery_box_top.png", "technic_hv_battery_box_bottom.png", "technic_hv_battery_box_side0.png^technic_power_meter"..i..".png",
-               "technic_hv_battery_box_side0.png^technic_power_meter"..i..".png", "technic_hv_battery_box_side0.png^technic_power_meter"..i..".png", "technic_hv_battery_box_side0.png^technic_power_meter"..i..".png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
-       sounds = default.node_sound_wood_defaults(),
-       paramtype="light",
-       light_source=9,
-       drop="technic:hv_battery_box",
-       can_dig = function(pos,player)
-                   local meta = minetest.env:get_meta(pos);
-                   local inv = meta:get_inventory()
-                   if not inv:is_empty("src") or not inv:is_empty("dst") then
-                      minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                      return false
-                   else
-                      return true
-                   end
-                end,
-    })
-end
-
-local power_tools = technic.HV_power_tools
-
-local charge_HV_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_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 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_HV_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_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 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:hv_battery_box","technic:hv_battery_box1","technic:hv_battery_box2","technic:hv_battery_box3","technic:hv_battery_box4",
-                "technic:hv_battery_box5","technic:hv_battery_box6","technic:hv_battery_box7","technic:hv_battery_box8"
-             },
-    interval = 1,
-    chance   = 1,
-    action = function(pos, node, active_object_count, active_object_count_wider)
-               local meta               = minetest.env:get_meta(pos)
-               local max_charge         = 1500000 -- Set maximum charge for the device here
-               local max_charge_rate    = 3000    -- Set maximum rate of charging
-               local max_discharge_rate = 5000    -- Set maximum rate of discharging (16000)
-               local eu_input           = meta:get_int("HV_EU_input")
-               local current_charge     = meta:get_int("internal_EU_charge") -- Battery charge right now
-
-               -- Power off automatically if no longer connected to a switching station
-               technic.switching_station_timeout_count(pos, "HV")
-
-               -- Charge/discharge the battery with the input EUs
-               if eu_input >=0 then
-                  current_charge = math.min(current_charge+eu_input, max_charge)
-               else
-                  current_charge = math.max(current_charge+eu_input, 0)
-               end
-
-               -- Charging/discharging tools here
-               current_charge = charge_HV_tools(meta, current_charge)
-               current_charge = discharge_HV_tools(meta, current_charge, max_charge)
-
-               -- 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))
-
-               -- Set how much we can supply
-               meta:set_int("HV_EU_supply", math.min(max_discharge_rate, current_charge))
-
-               meta:set_int("internal_EU_charge", current_charge)
-               --dprint("BA: input:"..eu_input.." supply="..meta:get_int("HV_EU_supply").." demand="..meta:get_int("HV_EU_demand").." current:"..current_charge)
-
-               -- Select node textures
-               local i=math.ceil((current_charge/max_charge)*8)
-               if i > 8 then i = 8 end
-               local j = meta:get_float("last_side_shown")
-               if i~=j then
-                  if i>0 then hacky_swap_node(pos,"technic:hv_battery_box"..i)
-                  elseif i==0 then hacky_swap_node(pos,"technic:hv_battery_box") end
-                  meta:set_float("last_side_shown",i)
-               end
-
-               local load = math.floor(current_charge/max_charge * 100)
-               meta:set_string("formspec",
-                               battery_box_formspec..
-                                  "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
-                                  (load)..":technic_power_meter_fg.png]"
-                            )
-
-               if eu_input == 0 then
-                  meta:set_string("infotext", "HV Battery box: "..current_charge.."/"..max_charge.." (idle)")
-               else
-                  meta:set_string("infotext", "HV Battery box: "..current_charge.."/"..max_charge)
-               end
-            end
- })
-
--- Register as a battery type
--- Battery type machines function as power reservoirs and can both receive and give back power
-technic.register_HV_machine("technic:hv_battery_box","BA")
-for i=1,8,1 do
-   technic.register_HV_machine("technic:hv_battery_box"..i,"BA")
-end
-
diff --git a/technic/battery_box_mv.lua b/technic/battery_box_mv.lua
deleted file mode 100644 (file)
index e1295ce..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
--- MV Battery box
-minetest.register_craft(
-   {output = 'technic:mv_battery_box 1',
-    recipe = {
-       {'technic:battery_box', 'technic:battery_box', 'technic:battery_box'},
-       {'technic:battery_box', 'technic:mv_transformer', 'technic:battery_box'},
-       {'', 'technic:mv_cable', ''},
-    }
- })
-
-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;]"
-
-minetest.register_node(
-   "technic:mv_battery_box", {
-      description = "MV Battery Box",
-      tiles  = {"technic_mv_battery_box_top.png", "technic_mv_battery_box_bottom.png", "technic_mv_battery_box_side0.png",
-               "technic_mv_battery_box_side0.png", "technic_mv_battery_box_side0.png", "technic_mv_battery_box_side0.png"},
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-      sounds = default.node_sound_wood_defaults(),
-      drop   = "technic:mv_battery_box",
-      on_construct = function(pos)
-                       if pos==nil then return end
-                       local meta = minetest.env:get_meta(pos);
-                       local inv = meta:get_inventory()
-                       meta:set_string("infotext", "MV Battery box")
-                       meta:set_float("technic_mv_power_machine", 1)
-                       meta:set_string("formspec", battery_box_formspec)
-                       meta:set_int("MV_EU_demand", 0) -- How much can this node charge
-                       meta:set_int("MV_EU_supply", 0) -- How much can this node discharge
-                       meta:set_int("MV_EU_input",  0) -- How much power is this machine getting.
-                       meta:set_float("internal_EU_charge", 0)
-                       inv:set_size("src", 1)
-                       inv:set_size("dst", 1)
-                    end,
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") or not inv:is_empty("dst") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  else
-                     return true
-                  end
-               end,
-   })
-
-
-for i=1,8,1 do
-   minetest.register_node(
-      "technic:mv_battery_box"..i,
-      {
-        description = "MV Battery Box",
-        tiles  = {"technic_mv_battery_box_top.png", "technic_mv_battery_box_bottom.png", "technic_mv_battery_box_side0.png^technic_power_meter"..i..".png",
-                  "technic_mv_battery_box_side0.png^technic_power_meter"..i..".png", "technic_mv_battery_box_side0.png^technic_power_meter"..i..".png", "technic_mv_battery_box_side0.png^technic_power_meter"..i..".png"},
-        groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
-        sounds = default.node_sound_wood_defaults(),
-        drop   = "technic:mv_battery_box",
-        can_dig = function(pos,player)
-                     local meta = minetest.env:get_meta(pos);
-                     local inv = meta:get_inventory()
-                     if not inv:is_empty("src") or not inv:is_empty("dst") then
-                        minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                        return false
-                     else
-                        return true
-                     end
-                  end,
-      })
-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",
-                  "technic:mv_battery_box5","technic:mv_battery_box6","technic:mv_battery_box7","technic:mv_battery_box8"
-               },
-      interval = 1,
-      chance   = 1,
-      action = function(pos, node, active_object_count, active_object_count_wider)
-               local meta               = minetest.env:get_meta(pos)
-               local max_charge         = 300000 -- Set maximum charge for the device here
-               local max_charge_rate    = 2000   -- Set maximum rate of charging (4000)
-               local max_discharge_rate = 3000   -- Set maximum rate of discharging
-               local eu_input           = meta:get_int("MV_EU_input")
-               local current_charge     = meta:get_int("internal_EU_charge") -- Battery charge right now
-
-               -- Power off automatically if no longer connected to a switching station
-               technic.switching_station_timeout_count(pos, "MV")
-
-               -- Charge/discharge the battery with the input EUs
-               if eu_input >=0 then
-                  current_charge = math.min(current_charge+eu_input, max_charge)
-               else
-                  current_charge = math.max(current_charge+eu_input, 0)
-               end
-
-               -- Charging/discharging tools here
-               current_charge = charge_MV_tools(meta, current_charge)
-               current_charge = discharge_MV_tools(meta, current_charge, max_charge)
-
-               -- 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))
-
-               -- Set how much we can supply
-               meta:set_int("MV_EU_supply", math.min(max_discharge_rate, current_charge))
-
-               meta:set_int("internal_EU_charge", current_charge)
-               --dprint("BA: input:"..eu_input.." supply="..meta:get_int("MV_EU_supply").." demand="..meta:get_int("MV_EU_demand").." current:"..current_charge)
-
-               -- Select node textures
-               local i=math.ceil((current_charge/max_charge)*8)
-               if i > 8 then i = 8 end
-               local j = meta:get_float("last_side_shown")
-               if i~=j then
-                  if i>0 then hacky_swap_node(pos,"technic:mv_battery_box"..i)
-                  elseif i==0 then hacky_swap_node(pos,"technic:mv_battery_box") end
-                  meta:set_float("last_side_shown",i)
-               end
-
-               local load = math.floor(current_charge/max_charge * 100)
-               meta:set_string("formspec",
-                               battery_box_formspec..
-                                  "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
-                                  (load)..":technic_power_meter_fg.png]"
-                            )
-
-               if eu_input == 0 then
-                  meta:set_string("infotext", "MV Battery box: "..current_charge.."/"..max_charge.." (idle)")
-               else
-                  meta:set_string("infotext", "MV Battery box: "..current_charge.."/"..max_charge)
-               end
-            end
-   })
-
--- Register as a battery type
--- Battery type machines function as power reservoirs and can both receive and give back power
-technic.register_MV_machine("technic:mv_battery_box","BA")
-for i=1,8,1 do
-   technic.register_MV_machine("technic:mv_battery_box"..i,"BA")
-end
-
diff --git a/technic/cans.lua b/technic/cans.lua
deleted file mode 100644 (file)
index 6a98ce9..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-local water_can_max_load = 16
-local lava_can_max_load = 8
-
-minetest.register_craft({
-       output = 'technic:water_can 1',
-       recipe = {
-               {'technic:zinc_ingot', 'technic:rubber','technic:zinc_ingot'},
-               {'default:steel_ingot', '', 'default:steel_ingot'},
-               {'technic:zinc_ingot', 'default:steel_ingot', 'technic:zinc_ingot'},
-       }
-})
-
-minetest.register_craft({
-       output = 'technic:lava_can 1',
-       recipe = {
-               {'technic:zinc_ingot', 'technic:stainless_steel_ingot','technic:zinc_ingot'},
-               {'technic:stainless_steel_ingot', '', 'technic:stainless_steel_ingot'},
-               {'technic:zinc_ingot', 'technic:stainless_steel_ingot', 'technic:zinc_ingot'},
-       }
-})
-
-
-minetest.register_tool("technic:water_can", {
-       description = "Water Can",
-       inventory_image = "technic_water_can.png",
-       stack_max = 1,
-       liquids_pointable = true,
-       on_use = function(itemstack, user, pointed_thing)
-               
-               if pointed_thing.type ~= "node" then
-                                       return end
-               n = minetest.env:get_node(pointed_thing.under)
-               
-               item=itemstack:to_table()
-               local load=nil
-               if item["metadata"]=="" then load=0 
-               else load=tonumber(item["metadata"]) 
-               end
-               
-               if n.name == "default:water_source" then
-                       if load+1<17 then
-                       minetest.env:add_node(pointed_thing.under, {name="air"})
-                        load=load+1;   
-                       item["metadata"]=tostring(load)
-                       technic.set_RE_wear(item,load,water_can_max_load)
-                       itemstack:replace(item)
-                       end
-                       return itemstack
-               end
-               item=itemstack:to_table()
-               if load==0 then return end
-                       
-               if n.name == "default:water_flowing" then
-                       minetest.env:add_node(pointed_thing.under, {name="default:water_source"})
-                       load=load-1;    
-                       item["metadata"]=tostring(load)
-                       technic.set_RE_wear(item,load,water_can_max_load)
-                       itemstack:replace(item)
-                       return itemstack
-                       end
-
-               n = minetest.env:get_node(pointed_thing.above)
-               if n.name == "air" then
-                       minetest.env:add_node(pointed_thing.above, {name="default:water_source"})
-                       load=load-1;    
-                       item["metadata"]=tostring(load)
-                       technic.set_RE_wear(item,load,water_can_max_load)
-                       itemstack:replace(item)
-                       return itemstack
-                       end             
-       end,
-})
-
-minetest.register_tool("technic:lava_can", {
-       description = "Lava Can",
-       inventory_image = "technic_lava_can.png",
-       stack_max = 1,
-       liquids_pointable = true,
-       on_use = function(itemstack, user, pointed_thing)
-               if pointed_thing.type ~= "node" then return end
-               n = minetest.env:get_node(pointed_thing.under)
-               item=itemstack:to_table()
-               local load=nil
-               if item["metadata"]=="" then load=0 
-               else load=tonumber(item["metadata"]) 
-               end
-               
-               if n.name == "default:lava_source" then
-                       if load+1<17 then
-                       minetest.env:add_node(pointed_thing.under, {name="air"})
-                        load=load+1;
-                       item["metadata"]=tostring(load)
-                       technic.set_RE_wear(item,load,lava_can_max_load)
-                       itemstack:replace(item)
-                       end
-                       return itemstack
-               end
-               item=itemstack:to_table()
-               if load==0 then return end
-                       
-               if n.name == "default:lava_flowing" then
-                       minetest.env:add_node(pointed_thing.under, {name="default:lava_source"})
-                       load=load-1;    
-                       item["metadata"]=tostring(load)
-                       technic.set_RE_wear(item,load,lava_can_max_load)
-                       itemstack:replace(item)
-                       return itemstack
-                       end
-
-               n = minetest.env:get_node(pointed_thing.above)
-               if n.name == "air" then
-                       minetest.env:add_node(pointed_thing.above, {name="default:lava_source"})
-                       load=load-1;    
-                       item["metadata"]=tostring(load)
-                       technic.set_RE_wear(item,load,lava_can_max_load)
-                       itemstack:replace(item)
-                       return itemstack
-                       end     
-       end,
-})
diff --git a/technic/chainsaw.lua b/technic/chainsaw.lua
deleted file mode 100644 (file)
index ae0c30c..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
--- Configuration
-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)
-
-minetest.register_tool("technic:chainsaw", {
-        description = "Chainsaw",
-        inventory_image = "technic_chainsaw.png",
-        stack_max = 1,
-        on_use = function(itemstack, user, pointed_thing)
-                if pointed_thing.type=="node" then
-                        item=itemstack:to_table()
-                        local meta=get_item_meta(item["metadata"])
-                        if meta==nil then return end --tool not charged
-                        if meta["charge"]==nil then return end
-                        -- Send current charge to digging function so that the chainsaw will stop after digging a number of nodes.
-                        local charge=meta["charge"]
-                        if charge < chainsaw_charge_per_node then return end -- only cut if charged
-
-                        charge=chainsaw_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,charge)
-                        technic.set_RE_wear(item,charge,chainsaw_max_charge)
-                        meta["charge"]=charge
-                        item["metadata"]=set_item_meta(meta)
-                        itemstack:replace(item)
-                        return itemstack
-                end
-        end,
-})
-
-minetest.register_craft({
-        output = 'technic:chainsaw',
-        recipe = {
-                {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:battery'},
-                {'technic:stainless_steel_ingot', 'technic:motor',                 'technic:battery'},
-                {'',                               '',                             'default:copper_ingot'},
-        }
-})
-
--- The default stuff
-local timber_nodenames={["default:jungletree"] = true,
-                        ["default:papyrus"]    = true,
-                        ["default:cactus"]     = true,
-                        ["default:tree"]       = true,
-                        ["default:apple"]      = true
-}
-
-if chainsaw_leaves == true then
-        timber_nodenames["default:leaves"] = true
-end
-
--- Support moretrees if it is there
-if( minetest.get_modpath("moretrees") ~= nil ) then
-        timber_nodenames["moretrees:apple_tree_trunk"]                 = true
-        timber_nodenames["moretrees:apple_tree_trunk_sideways"]        = true
-        timber_nodenames["moretrees:beech_trunk"]                      = true
-        timber_nodenames["moretrees:beech_trunk_sideways"]             = true
-        timber_nodenames["moretrees:birch_trunk"]                      = true
-        timber_nodenames["moretrees:birch_trunk_sideways"]             = true
-        timber_nodenames["moretrees:fir_trunk"]                        = true
-        timber_nodenames["moretrees:fir_trunk_sideways"]               = true
-        timber_nodenames["moretrees:oak_trunk"]                        = true
-        timber_nodenames["moretrees:oak_trunk_sideways"]               = true
-        timber_nodenames["moretrees:palm_trunk"]                       = true
-        timber_nodenames["moretrees:palm_trunk_sideways"]              = true
-        timber_nodenames["moretrees:pine_trunk"]                       = true
-        timber_nodenames["moretrees:pine_trunk_sideways"]              = true
-        timber_nodenames["moretrees:rubber_tree_trunk"]                = true
-        timber_nodenames["moretrees:rubber_tree_trunk_sideways"]       = true
-        timber_nodenames["moretrees:rubber_tree_trunk_empty"]          = true
-        timber_nodenames["moretrees:rubber_tree_trunk_sideways_empty"] = true
-        timber_nodenames["moretrees:sequoia_trunk"]                    = true
-        timber_nodenames["moretrees:sequoia_trunk_sideways"]           = true
-        timber_nodenames["moretrees:spruce_trunk"]                     = true
-        timber_nodenames["moretrees:spruce_trunk_sideways"]            = true
-        timber_nodenames["moretrees:willow_trunk"]                     = true
-        timber_nodenames["moretrees:willow_trunk_sideways"]            = true
-        timber_nodenames["moretrees:jungletree_trunk"]                 = true
-        timber_nodenames["moretrees:jungletree_trunk_sideways"]        = true
-
-        if chainsaw_leaves == true then
-                timber_nodenames["moretrees:apple_tree_leaves"]        = true
-                timber_nodenames["moretrees:oak_leaves"]               = true
-                timber_nodenames["moretrees:sequoia_leaves"]           = true
-                timber_nodenames["moretrees:birch_leaves"]             = true
-                timber_nodenames["moretrees:birch_leaves"]             = true
-                timber_nodenames["moretrees:palm_leaves"]              = true
-                timber_nodenames["moretrees:spruce_leaves"]            = true
-                timber_nodenames["moretrees:spruce_leaves"]            = true
-                timber_nodenames["moretrees:pine_leaves"]              = true
-                timber_nodenames["moretrees:willow_leaves"]            = true
-                timber_nodenames["moretrees:rubber_tree_leaves"]       = true
-                timber_nodenames["moretrees:jungletree_leaves_green"]  = true
-                timber_nodenames["moretrees:jungletree_leaves_yellow"] = true
-                timber_nodenames["moretrees:jungletree_leaves_red"]    = true
-        end
-end
-
--- Support growing_trees if it is there
-if( minetest.get_modpath("growing_trees") ~= nil ) then
-        timber_nodenames["growing_trees:trunk"]         = true
-        timber_nodenames["growing_trees:medium_trunk"]  = true
-        timber_nodenames["growing_trees:big_trunk"]     = true
-        timber_nodenames["growing_trees:trunk_top"]     = true
-        timber_nodenames["growing_trees:trunk_sprout"]  = true
-        timber_nodenames["growing_trees:branch_sprout"] = true
-        timber_nodenames["growing_trees:branch"]        = true
-        timber_nodenames["growing_trees:branch_xmzm"]   = true
-        timber_nodenames["growing_trees:branch_xpzm"]   = true
-        timber_nodenames["growing_trees:branch_xmzp"]   = true
-        timber_nodenames["growing_trees:branch_xpzp"]   = true
-        timber_nodenames["growing_trees:branch_zz"]     = true
-        timber_nodenames["growing_trees:branch_xx"]     = true
-
-        if chainsaw_leaves == true then
-                timber_nodenames["growing_trees:leaves"] = true
-        end
-end
-
--- Support growing_cactus if it is there
-if( minetest.get_modpath("growing_cactus") ~= nil ) then
-        timber_nodenames["growing_cactus:sprout"]                       = true
-        timber_nodenames["growing_cactus:branch_sprout_vertical"]       = true
-        timber_nodenames["growing_cactus:branch_sprout_vertical_fixed"] = true
-        timber_nodenames["growing_cactus:branch_sprout_xp"]             = true
-        timber_nodenames["growing_cactus:branch_sprout_xm"]             = true
-        timber_nodenames["growing_cactus:branch_sprout_zp"]             = true
-        timber_nodenames["growing_cactus:branch_sprout_zm"]             = true
-        timber_nodenames["growing_cactus:trunk"]                        = true
-        timber_nodenames["growing_cactus:branch_trunk"]                 = true
-        timber_nodenames["growing_cactus:branch"]                       = true
-        timber_nodenames["growing_cactus:branch_xp"]                    = true
-        timber_nodenames["growing_cactus:branch_xm"]                    = true
-        timber_nodenames["growing_cactus:branch_zp"]                    = true
-        timber_nodenames["growing_cactus:branch_zm"]                    = true
-        timber_nodenames["growing_cactus:branch_zz"]                    = true
-        timber_nodenames["growing_cactus:branch_xx"]                    = true
-end
-
--- Support farming_plus if it is there
-if( minetest.get_modpath("farming_plus") ~= nil ) then
-   if chainsaw_leaves == true then
-      timber_nodenames["farming_plus:cocoa_leaves"] = true
-   end
-end
-
--- Table for saving what was sawed down
-local produced
-
--- Saw down trees entry point
-chainsaw_dig_it = function(pos, player,current_charge)
-        local remaining_charge=current_charge
-
-        -- Save the currently installed dropping mechanism so we can restore it.
-       local original_handle_node_drops = minetest.handle_node_drops
-
-        -- A bit of trickery here: use a different node drop callback
-        -- and restore the original afterwards.
-        minetest.handle_node_drops = chainsaw_handle_node_drops
-
-        -- clear result and start sawing things down
-        produced = {}
-        remaining_charge = recursive_dig(pos, remaining_charge, player)
-        minetest.sound_play("chainsaw", {pos = pos, gain = 1.0, max_hear_distance = 10,})
-
-        -- Restore the original noder drop handler
-        minetest.handle_node_drops = original_handle_node_drops
-
-        -- Now drop items for the player
-        local number, produced_item, p
-        for produced_item,number in pairs(produced) do
-                --print("ADDING ITEM: " .. produced_item .. " " .. number)
-                -- Drop stacks of 99 or less
-                p = {
-                        x = pos.x + math.random()*4,
-                        y = pos.y,
-                        z = pos.z + math.random()*4
-                }
-                while number > 99 do
-                        minetest.env:add_item(p, produced_item .. " 99")
-                        p = {
-                                x = pos.x + math.random()*4,
-                                y = pos.y,
-                                z = pos.z + math.random()*4
-                        }
-                        number = number - 99
-                end
-                minetest.env:add_item(p, produced_item .. " " .. number)
-        end
-        return remaining_charge
-end
-
--- Override the default handling routine to be able to count up the
--- items sawed down so that we can drop them i an nice single stack
-chainsaw_handle_node_drops = function(pos, drops, digger)
-        -- Add dropped items to list of collected nodes
-        local _, dropped_item
-        for _, dropped_item in ipairs(drops) do
-                if produced[dropped_item] == nil then
-                        produced[dropped_item] = 1
-                else
-                        produced[dropped_item] = produced[dropped_item] + 1
-                end
-        end
-end
-
--- This function does all the hard work. Recursively we dig the node at hand
--- if it is in the table and then search the surroundings for more stuff to dig.
-recursive_dig = function(pos, remaining_charge, player)
-        local node=minetest.env:get_node(pos)
-        local i=1
-        -- Lookup node name in timber table:
-        if timber_nodenames[node.name] ~= nil then
-                -- Return if we are out of power
-                if remaining_charge < chainsaw_charge_per_node then
-                        return 0
-                end
-                local np
-                -- wood found - cut it.
-                minetest.env:dig_node(pos)
-
-                remaining_charge=remaining_charge-chainsaw_charge_per_node
-                -- check surroundings and run recursively if any charge left
-                np={x=pos.x+1, y=pos.y, z=pos.z}
-                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
-                        remaining_charge = recursive_dig(np, remaining_charge)
-                end
-                np={x=pos.x+1, y=pos.y, z=pos.z+1}
-                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
-                        remaining_charge = recursive_dig(np, remaining_charge)
-                end
-                np={x=pos.x+1, y=pos.y, z=pos.z-1}
-                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
-                        remaining_charge = recursive_dig(np, remaining_charge)
-                end
-
-                np={x=pos.x-1, y=pos.y, z=pos.z}
-                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
-                        remaining_charge = recursive_dig(np, remaining_charge)
-                end
-                np={x=pos.x-1, y=pos.y, z=pos.z+1}
-                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
-                        remaining_charge = recursive_dig(np, remaining_charge)
-                end
-                np={x=pos.x-1, y=pos.y, z=pos.z-1}
-                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
-                        remaining_charge = recursive_dig(np, remaining_charge)
-                end
-
-                np={x=pos.x, y=pos.y+1, z=pos.z}
-                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
-                        remaining_charge = recursive_dig(np, remaining_charge)
-                end
-
-                np={x=pos.x, y=pos.y, z=pos.z+1}
-                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
-                        remaining_charge = recursive_dig(np, remaining_charge)
-                end
-                np={x=pos.x, y=pos.y, z=pos.z-1}
-                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
-                        remaining_charge = recursive_dig(np, remaining_charge)
-                end
-                return remaining_charge
-        end
-        -- Nothing sawed down
-        return remaining_charge
-end
-
diff --git a/technic/cnc.lua b/technic/cnc.lua
deleted file mode 100644 (file)
index 8e215ae..0000000
+++ /dev/null
@@ -1,293 +0,0 @@
--- Technic CNC v1.0 by kpoppel
--- Based on the NonCubic Blocks MOD v1.4 by yves_de_beck
-
--- Idea:
---   Somehow have a tabbed/paged panel if the number of shapes should expand
---   beyond what is available in the panel today.
---   I could imagine some form of API allowing modders to come with their own node
---   box definitions and easily stuff it in the this machine for production.
-
-
-local shape = {}
-local onesize_products = {
-   slope                    = 2,
-   slope_edge               = 1,
-   slope_inner_edge         = 1,
-   pyramid                  = 2,
-   spike                    = 1,
-   cylinder                 = 2,
-   sphere                   = 1,
-   stick                    = 8,
-   slope_upsdown            = 2,
-   slope_edge_upsdown       = 1,
-   slope_inner_edge_upsdown = 1,
-   cylinder_horizontal      = 2,
-   slope_lying              = 2,
-   onecurvededge            = 1,
-   twocurvededge            = 1,
-}
-local twosize_products = {
-   element_straight         = 4,
-   element_end              = 2,
-   element_cross            = 1,
-   element_t                = 1,
-   element_edge             = 2,
-}
-
-local cnc_formspec =
-   "invsize[9,11;]"..
-   "label[1,0;Choose Milling Program:]"..
-   "image_button[1,0.5;1,1;technic_cnc_slope.png;slope; ]"..
-   "image_button[2,0.5;1,1;technic_cnc_slope_edge.png;slope_edge; ]"..
-   "image_button[3,0.5;1,1;technic_cnc_slope_inner_edge.png;slope_inner_edge; ]"..
-   "image_button[4,0.5;1,1;technic_cnc_pyramid.png;pyramid; ]"..
-   "image_button[5,0.5;1,1;technic_cnc_spike.png;spike; ]"..
-   "image_button[6,0.5;1,1;technic_cnc_cylinder.png;cylinder; ]"..
-   "image_button[7,0.5;1,1;technic_cnc_sphere.png;sphere; ]"..
-   "image_button[8,0.5;1,1;technic_cnc_stick.png;stick; ]"..
-   
-   "image_button[1,1.5;1,1;technic_cnc_slope_upsdwn.png;slope_upsdown; ]"..
-   "image_button[2,1.5;1,1;technic_cnc_slope_edge_upsdwn.png;slope_edge_upsdown; ]"..
-   "image_button[3,1.5;1,1;technic_cnc_slope_inner_edge_upsdwn.png;slope_inner_edge_upsdown; ]"..
-   "image_button[4,1.5;1,1;technic_cnc_cylinder_horizontal.png;cylinder_horizontal; ]"..
-   
-   "image_button[1,2.5;1,1;technic_cnc_slope_lying.png;slope_lying; ]"..
-   "image_button[2,2.5;1,1;technic_cnc_onecurvededge.png;onecurvededge; ]"..
-   "image_button[3,2.5;1,1;technic_cnc_twocurvededge.png;twocurvededge; ]"..
-   
-   "label[1,3.5;Slim Elements half / normal height:]"..
-   
-   "image_button[1,4;1,0.5;technic_cnc_full.png;full; ]"..
-   "image_button[1,4.5;1,0.5;technic_cnc_half.png;half; ]"..
-   "image_button[2,4;1,1;technic_cnc_element_straight.png;element_straight; ]"..
-   "image_button[3,4;1,1;technic_cnc_element_end.png;element_end; ]"..
-   "image_button[4,4;1,1;technic_cnc_element_cross.png;element_cross; ]"..
-   "image_button[5,4;1,1;technic_cnc_element_t.png;element_t; ]"..
-   "image_button[6,4;1,1;technic_cnc_element_edge.png;element_edge; ]"..
-   
-   "label[0, 5.5;In:]"..
-   "list[current_name;src;0.5,5.5;1,1;]"..
-   "label[4, 5.5;Out:]"..
-   "list[current_name;dst;5,5.5;4,1;]"..
-   
-   "list[current_player;main;0,7;8,4;]"
-
-local size     = 1;
-
--- The form handler is declared here because we need it in both the inactive and active modes
--- in order to be able to change programs wile it is running.
-local form_handler = function(pos, formname, fields, sender)
-                       -- REGISTER MILLING PROGRAMS AND OUTPUTS:
-                       ------------------------------------------
-                       -- Program for half/full size
-                       if fields["full"] then
-                          size = 1
-                          return
-                       end
-                       
-                       if fields["half"] then
-                          size = 2
-                          return
-                       end
-                       
-                       -- Resolve the node name and the number of items to make
-                       local meta       = minetest.env:get_meta(pos)
-                       local inv        = meta:get_inventory()
-                       local inputstack = inv:get_stack("src", 1)
-                       local inputname  = inputstack:get_name()
-                       local multiplier = 0
-                       for k, _ in pairs(fields) do
-                          -- Set a multipier for the half/full size capable blocks
-                          if twosize_products[k] ~= nil then
-                             multiplier = size*twosize_products[k]
-                          else
-                             multiplier = onesize_products[k]
-                          end
-                          
-                          if onesize_products[k] ~= nil or twosize_products[k] ~= nil then
-                             meta:set_float( "cnc_multiplier", multiplier)
-                             meta:set_string("cnc_user", sender:get_player_name())
-                          end
-                          
-                          if onesize_products[k] ~= nil or (twosize_products[k] ~= nil and size==2) then
-                             meta:set_string("cnc_product",  inputname .. "_technic_cnc_" .. k)
-                             --print(inputname .. "_technic_cnc_" .. k)
-                             break
-                          end
-                          
-                          if twosize_products[k] ~= nil and size==1 then
-                             meta:set_string("cnc_product",  inputname .. "_technic_cnc_" .. k .. "_double")
-                             --print(inputname .. "_technic_cnc_" .. k .. "_double")
-                             break
-                          end
-                       end
-                       return
-                    end -- callback function
-
--- The actual block inactive state
-minetest.register_node(
-   "technic:cnc",
-   {
-      description = "CNC Milling Machine",
-      tiles       = {"technic_cnc_top.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
-                    "technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front.png"},
-      drawtype    = "nodebox",
-      paramtype   = "light",
-      paramtype2  = "facedir",
-      node_box    = {
-        type  = "fixed",
-        fixed = {
-           {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
-           
-        },
-      },
-      selection_box = {
-        type = "fixed",
-        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
-      },
-      groups = {cracky=2},
-      legacy_facedir_simple = true,
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       meta:set_string("infotext", "CNC Machine")
-                       meta:set_float("technic_power_machine", 1)
-                       meta:set_string("formspec", cnc_formspec)
-                       local inv = meta:get_inventory()
-                       inv:set_size("src", 1)
-                       inv:set_size("dst", 4)
-                    end,
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") or not inv:is_empty("dst") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  else
-                     return true
-                  end
-               end,
-      on_receive_fields = form_handler,
-   })
-
--- Active state block
-minetest.register_node("technic:cnc_active", {
-                         description = "CNC Machine",
-                         tiles       = {"technic_cnc_top_active.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
-                                        "technic_cnc_side.png",       "technic_cnc_side.png",   "technic_cnc_front_active.png"},
-                         paramtype2 = "facedir",
-                         groups = {cracky=2,not_in_creative_inventory=1},
-                         legacy_facedir_simple = true,
-                         can_dig = function(pos,player)
-                                      local meta = minetest.env:get_meta(pos);
-                                      local inv = meta:get_inventory()
-                                      if not inv:is_empty("src") or not inv:is_empty("dst") then
-                                         minetest.chat_send_player(player:get_player_name(), "CNC machine cannot be removed because it is not empty");
-                                         return false
-                                      end
-                                      return true
-                                   end,
-                         on_receive_fields = form_handler,
-                      })
-
--- Action code performing the transformation
-minetest.register_abm(
-   { nodenames = {"technic:cnc","technic:cnc_active"},
-     interval = 1,
-     chance   = 1,
-     action = function(pos, node, active_object_count, active_object_count_wider)
-                local meta         = minetest.env:get_meta(pos)
-                local eu_input     = meta:get_int("LV_EU_input")
-                local state        = meta:get_int("state")
-                local next_state   = state
-
-                -- Machine information
-                local machine_name         = "CNC"
-                local machine_node         = "technic:cnc"
-                local machine_state_demand = { 50, 450 }
-                        
-                -- Setup meta data if it does not exist. state is used as an indicator of this
-                if state == 0 then
-                   meta:set_int("state", 1)
-                   meta:set_int("LV_EU_demand", machine_state_demand[1])
-                   meta:set_int("LV_EU_input", 0)
-                   return
-                end
-                        
-                -- Power off automatically if no longer connected to a switching station
-                technic.switching_station_timeout_count(pos, "LV")
-                        
-                -- State machine
-                if eu_input == 0 then
-                   -- Unpowered - go idle
-                   hacky_swap_node(pos, machine_node)
-                   meta:set_string("infotext", machine_name.." Unpowered")
-                   next_state = 1
-                elseif eu_input == machine_state_demand[state] then
-                   -- Powered - do the state specific actions
-                           
-                   local inv   = meta:get_inventory()
-                   local empty = inv:is_empty("src")
-
-                   if state == 1 then
-                      hacky_swap_node(pos, machine_node)
-                      meta:set_string("infotext", machine_name.." Idle")
-
-                      local result = meta:get_string("cnc_product")
-                      if not empty and minetest.registered_nodes[result] ~= nil and inv:room_for_item("dst",result) then
-                         next_state = 2
-                      else
-                         meta:set_string("cnc_product", "") -- Reset the program
-                      end
-                      --minetest.chat_send_player(meta:get_string("cnc_user"), "CNC machine does not know how to handle this material. Please remove it.");
-
-                   elseif state == 2 then
-                      hacky_swap_node(pos, machine_node.."_active")
-                      meta:set_string("infotext", machine_name.." Active")
-
-                      if empty then
-                         next_state = 1
-                      else
-                         meta:set_int("src_time", meta:get_int("src_time") + 1)
-                         if meta:get_int("src_time") >= 3 then -- 3 ticks per output
-                            local result = meta:get_string("cnc_product")
-                            -- check if there's room for output in "dst" list
-                            if inv:room_for_item("dst",result) then
-                               -- CNC does the transformation
-                               ------------------------------
-                               meta:set_int("src_time", 0)
-                               -- take stuff from "src" list
-                               srcstack = inv:get_stack("src", 1)
-                               srcstack:take_item()
-                               inv:set_stack("src", 1, srcstack)
-                               -- Put result in "dst" list
-                               inv:add_item("dst",result .. " " .. meta:get_int("cnc_multiplier"))
-                            else
-                               next_state = 1
-                            end
-                         end
-                      end
-                   end
-                end
-                -- Change state?
-                if next_state ~= state then
-                   meta:set_int("LV_EU_demand", machine_state_demand[next_state])
-                   meta:set_int("state", next_state)
-                end
-             end
-  }) 
-
-technic.register_LV_machine ("technic:cnc","RE")
-technic.register_LV_machine ("technic:cnc_active","RE")
-
--------------------------
--- CNC Machine Recipe
--------------------------
-minetest.register_craft({
-       output = 'technic:cnc',
-       recipe = {
-               {'default:glass',              'technic:diamond_drill_head', 'default:glass'},
-               {'technic:control_logic_unit', 'technic:motor',              'default:steel_ingot'},
-               {'default:steel_ingot',        'default:copper_ingot',       'default:steel_ingot'},         
-       },
-})
-
diff --git a/technic/cnc_api.lua b/technic/cnc_api.lua
deleted file mode 100644 (file)
index 2d5e305..0000000
+++ /dev/null
@@ -1,372 +0,0 @@
--- API for the technic CNC machine
--- Again code is adapted from the NonCubic Blocks MOD v1.4 by yves_de_beck
-technic_cnc_api = {}
-
--- HERE YOU CAN CHANGE THE DETAIL-LEVEL:
-----------------------------------------
-technic_cnc_api.detail_level = 16 -- 16; 1-32
-
--- REGISTER NONCUBIC FORMS, CREATE MODELS AND RECIPES:
-------------------------------------------------------
-local cnc_sphere =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level
-      local sehne
-      for i = 1, detail-1 do
-        sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
-        nodebox[i]={-sehne, (i/detail)-0.5, -sehne, sehne, (i/detail)+(1/detail)-0.5, sehne}
-      end
-      return nodebox
-   end
-
-local cnc_cylinder_horizontal =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level
-      local sehne
-      for i = 1, detail-1 do
-        sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
-        nodebox[i]={-0.5, (i/detail)-0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, sehne}
-      end
-      return nodebox
-   end
-
-local cnc_cylinder =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level
-      local sehne
-      for i = 1, detail-1 do
-        sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
-        nodebox[i]={(i/detail)-0.5, -0.5, -sehne, (i/detail)+(1/detail)-0.5, 0.5, sehne}
-      end
-      return nodebox
-   end
-
-local cnc_twocurvededge =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level*2
-      local sehne
-      for i = (detail/2)-1, detail-1 do
-        sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
-        nodebox[i]={-sehne, -0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, 0.5}
-      end
-      return nodebox
-   end
-
-local cnc_onecurvededge =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level*2
-      local sehne
-      for i = (detail/2)-1, detail-1 do
-        sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
-        nodebox[i]={-0.5, -0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, 0.5}
-      end 
-     return nodebox
-   end
-
-local cnc_spike =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level
-      for i = 0, detail-1 do
-        nodebox[i+1]={(i/detail/2)-0.5, (i/detail/2)-0.5, (i/detail/2)-0.5, 0.5-(i/detail/2), (i/detail)-0.5+(1/detail), 0.5-(i/detail/2)}
-end
-      return nodebox
-   end
-
-local cnc_pyramid =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level/2
-      for i = 0, detail-1 do
-        nodebox[i+1]={(i/detail/2)-0.5, (i/detail/2)-0.5, (i/detail/2)-0.5, 0.5-(i/detail/2), (i/detail/2)-0.5+(1/detail), 0.5-(i/detail/2)}
-      end
-      return nodebox
-   end
-
-local cnc_slope_inner_edge_upsdown =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level
-      for i = 0, detail-1 do
-        nodebox[i+1]={0.5-(i/detail)-(1/detail), (i/detail)-0.5, -0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
-        nodebox[i+detail+1]={-0.5, (i/detail)-0.5, 0.5-(i/detail)-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
-      end
-      return nodebox
-   end
-
-local cnc_slope_edge_upsdown =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level
-      for i = 0, detail-1 do
-        nodebox[i+1]={(-1*(i/detail))+0.5-(1/detail), (i/detail)-0.5, (-1*(i/detail))+0.5-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
-      end
-      return nodebox
-   end
-
-local cnc_slope_inner_edge =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level
-      for i = 0, detail-1 do
-        nodebox[i+1]={(i/detail)-0.5, -0.5, -0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
-        nodebox[i+detail+1]={-0.5, -0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
-      end
-      return nodebox
-   end
-
-local cnc_slope_edge =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level
-      for i = 0, detail-1 do
-        nodebox[i+1]={(i/detail)-0.5, -0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
-      end
-      return nodebox
-   end
-
-local cnc_slope_upsdown =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level
-      for i = 0, detail-1 do
-        nodebox[i+1]={-0.5, (i/detail)-0.5, (-1*(i/detail))+0.5-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
-      end
-      return nodebox
-   end
-
-local cnc_slope_lying =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level
-      for i = 0, detail-1 do
-        nodebox[i+1]={(i/detail)-0.5, -0.5, (i/detail)-0.5, (i/detail)-0.5+(1/detail), 0.5 , 0.5}
-      end
-      return nodebox
-   end
-
-local cnc_slope =
-   function()
-      local nodebox = {}
-      local detail = technic_cnc_api.detail_level
-      for i = 0, detail-1 do
-        nodebox[i+1]={-0.5, (i/detail)-0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
-      end
-      return nodebox
-   end
-
--- Define slope boxes for the various nodes
--------------------------------------------
-technic_cnc_api.cnc_programs = {
-   {suffix  = "technic_cnc_stick",
-    nodebox = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15},
-    desc    = "Stick"},
-
-   {suffix  = "technic_cnc_element_end_double",
-    nodebox = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.5},
-    desc    = "Element End Double"},
-
-   {suffix  = "technic_cnc_element_cross_double",
-    nodebox = {
-       {0.3, -0.5, -0.3, 0.5, 0.5, 0.3},
-       {-0.3, -0.5, -0.5, 0.3, 0.5, 0.5},
-       {-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}},
-    desc    = "Element Cross Double"},
-
-   {suffix  = "technic_cnc_element_t_double",
-    nodebox = {
-       {-0.3, -0.5, -0.5, 0.3, 0.5, 0.3},
-       {-0.5, -0.5, -0.3, -0.3, 0.5, 0.3},
-       {0.3, -0.5, -0.3, 0.5, 0.5, 0.3}},
-    desc    = "Element T Double"},
-
-   {suffix  = "technic_cnc_element_edge_double",
-    nodebox = {
-       {-0.3, -0.5, -0.5, 0.3, 0.5, 0.3},
-       {-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}},
-    desc    = "Element Edge Double"},
-
-   {suffix  = "technic_cnc_element_straight_double",
-    nodebox = {-0.3, -0.5, -0.5, 0.3, 0.5, 0.5},
-    desc    = "Element Straight Double"},
-
-   {suffix  = "technic_cnc_element_end",
-    nodebox = {-0.3, -0.5, -0.3, 0.3, 0, 0.5},
-    desc    = "Element End"},
-
-   {suffix  = "technic_cnc_element_cross",
-    nodebox = {
-       {0.3, -0.5, -0.3, 0.5, 0, 0.3},
-       {-0.3, -0.5, -0.5, 0.3, 0, 0.5},
-       {-0.5, -0.5, -0.3, -0.3, 0, 0.3}},
-    desc    = "Element Cross"},
-
-   {suffix  = "technic_cnc_element_t",
-    nodebox = {
-       {-0.3, -0.5, -0.5, 0.3, 0, 0.3},
-       {-0.5, -0.5, -0.3, -0.3, 0, 0.3},
-       {0.3, -0.5, -0.3, 0.5, 0, 0.3}},
-    desc    = "Element T"},
-
-   {suffix  = "technic_cnc_element_edge",
-    nodebox = {
-       {-0.3, -0.5, -0.5, 0.3, 0, 0.3},
-       {-0.5, -0.5, -0.3, -0.3, 0, 0.3}},
-    desc    = "Element Edge"},
-
-   {suffix  = "technic_cnc_element_straight",
-    nodebox = {-0.3, -0.5, -0.5, 0.3, 0, 0.5},
-    desc    = "Element Straight"},
-
-   {suffix  = "technic_cnc_sphere",
-    nodebox = cnc_sphere(),
-    desc    = "Sphere"},
-
-   {suffix  = "technic_cnc_cylinder_horizontal",
-    nodebox = cnc_cylinder_horizontal(),
-    desc    = "Cylinder Horizontal"},
-
-   {suffix  = "technic_cnc_cylinder",
-    nodebox = cnc_cylinder(),
-    desc    = ""},
-
-   {suffix  = "technic_cnc_twocurvededge",
-    nodebox = cnc_twocurvededge(),
-    desc    = "One Curved Edge Block"},
-
-   {suffix  = "technic_cnc_onecurvededge",
-    nodebox = cnc_onecurvededge(),
-    desc    = "Two Curved Edge Block"},
-
-   {suffix  = "technic_cnc_spike",
-    nodebox = cnc_spike(),
-    desc    = "Spike"},
-
-   {suffix  = "technic_cnc_pyramid",
-    nodebox = cnc_pyramid(),
-    desc    = "Pyramid"},
-
-   {suffix  = "technic_cnc_slope_inner_edge_upsdown",
-    nodebox = cnc_slope_inner_edge_upsdown(),
-    desc    = "Slope Upside Down Inner Edge"},
-
-   {suffix  = "technic_cnc_slope_edge_upsdown",
-    nodebox = cnc_slope_edge_upsdown(),
-    desc    = "Slope Upside Down Edge"},
-
-   {suffix  = "technic_cnc_slope_inner_edge",
-    nodebox = cnc_slope_inner_edge(),
-    desc    = "Slope Inner Edge"},
-
-   {suffix  = "technic_cnc_slope_edge",
-    nodebox = cnc_slope_edge(),
-    desc    = "Slope Edge"},
-
-   {suffix  = "technic_cnc_slope_upsdown",
-    nodebox = cnc_slope_upsdown(),
-    desc    = "Slope Upside Down"},
-
-   {suffix  = "technic_cnc_slope_lying",
-    nodebox = cnc_slope_lying(),
-    desc    = "Slope Lying"},
-
-   {suffix  = "technic_cnc_slope",
-    nodebox = cnc_slope(),
-    desc    = "Slope"},
---   {suffix  = "",
---    nodebox =},
-}
-
--- Allow disabling certain programs for some node. Default is allowing all types for all nodes
-technic_cnc_api.cnc_programs_disable = {
-   -- ["default:brick"] = {"technic_cnc_stick"}, -- Example: Disallow the stick for brick
-   -- ...
-   ["default:dirt"] = {"technic_cnc_sphere", "technic_cnc_slope_upsdown", "technic_cnc_edge",
-                      "technic_cnc_inner_edge", "technic_cnc_slope_edge_upsdown", "technic_cnc_slope_inner_edge_upsdown",
-                      "technic_cnc_stick", "technic_cnc_cylinder_horizontal"}
-}
-
--- Generic function for registering all the different node types
-function technic_cnc_api.register_cnc_program(recipeitem, suffix, nodebox, groups, images, description)
-   minetest.register_node(":" .. recipeitem .. "_" .. suffix, {
-                            description   = description,
-                            drawtype      = "nodebox",
-                            tiles         = images,
-                            paramtype     = "light",
-                            paramtype2    = "facedir",
-                            walkable      = true,
-                            selection_box = {
-                               type  = "fixed",
-                               fixed = nodebox
-                            },
-                            node_box      = {
-                               type  = "fixed",
-                               fixed = nodebox
-                            },
-                            groups        = groups,
-                         })
-end
-
--- function to iterate over all the programs the CNC machine knows
-function technic_cnc_api.register_all(recipeitem, groups, images, description)
-   for _, data in ipairs(technic_cnc_api.cnc_programs) do
-      -- Disable node creation for disabled node types for some material
-      local do_register = true
-      if technic_cnc_api.cnc_programs_disable[recipeitem] ~= nil then
-        for __, disable in ipairs(technic_cnc_api.cnc_programs_disable[recipeitem]) do
-           if disable == data.suffix then
-              do_register = false
-           end
-        end
-      end
-      -- Create the node if it passes the test
-      if do_register then
-        technic_cnc_api.register_cnc_program(recipeitem, data.suffix, data.nodebox, groups, images, description.." "..data.desc)
-      end
-   end
-end
-
-
--- REGISTER NEW TECHNIC_CNC_API's PART 2: technic_cnc_api.register_element_end(subname, recipeitem, groups, images, desc_element_xyz)
------------------------------------------------------------------------------------------------------------------------
-function technic_cnc_api.register_slope_edge_etc(recipeitem, groups, images, desc_slope, desc_slope_lying, desc_slope_upsdown, desc_slope_edge, desc_slope_inner_edge, desc_slope_upsdwn_edge, desc_slope_upsdwn_inner_edge, desc_pyramid, desc_spike, desc_onecurvededge, desc_twocurvededge, desc_cylinder, desc_cylinder_horizontal, desc_sphere, desc_element_straight, desc_element_edge, desc_element_t, desc_element_cross, desc_element_end)
-
-         technic_cnc_api.register_slope(recipeitem, groups, images, desc_slope)
-         technic_cnc_api.register_slope_lying(recipeitem, groups, images, desc_slope_lying)
-         technic_cnc_api.register_slope_upsdown(recipeitem, groups, images, desc_slope_upsdown)
-         technic_cnc_api.register_slope_edge(recipeitem, groups, images, desc_slope_edge)
-         technic_cnc_api.register_slope_inner_edge(recipeitem, groups, images, desc_slope_inner_edge)
-         technic_cnc_api.register_slope_edge_upsdown(recipeitem, groups, images, desc_slope_upsdwn_edge)
-         technic_cnc_api.register_slope_inner_edge_upsdown(recipeitem, groups, images, desc_slope_upsdwn_inner_edge)
-         technic_cnc_api.register_pyramid(recipeitem, groups, images, desc_pyramid)
-         technic_cnc_api.register_spike(recipeitem, groups, images, desc_spike)
-         technic_cnc_api.register_onecurvededge(recipeitem, groups, images, desc_onecurvededge)
-         technic_cnc_api.register_twocurvededge(recipeitem, groups, images, desc_twocurvededge)
-         technic_cnc_api.register_cylinder(recipeitem, groups, images, desc_cylinder)
-         technic_cnc_api.register_cylinder_horizontal(recipeitem, groups, images, desc_cylinder_horizontal)
-         technic_cnc_api.register_sphere(recipeitem, groups, images, desc_sphere)
-         technic_cnc_api.register_element_straight(recipeitem, groups, images, desc_element_straight)
-         technic_cnc_api.register_element_edge(recipeitem, groups, images, desc_element_edge)
-         technic_cnc_api.register_element_t(recipeitem, groups, images, desc_element_t)
-         technic_cnc_api.register_element_cross(recipeitem, groups, images, desc_element_cross)
-         technic_cnc_api.register_element_end(recipeitem, groups, images, desc_element_end)
-end
-
--- REGISTER STICKS: noncubic.register_xyz(recipeitem, groups, images, desc_element_xyz)
-------------------------------------------------------------------------------------------------------------
-function technic_cnc_api.register_stick_etc(recipeitem, groups, images, desc_stick)
-         technic_cnc_api.register_stick(recipeitem, groups, images, desc_stick)
-end
-
-function technic_cnc_api.register_elements(recipeitem, groups, images, desc_element_straight_double, desc_element_edge_double, desc_element_t_double, desc_element_cross_double, desc_element_end_double)
-         technic_cnc_api.register_element_straight_double(recipeitem, groups, images, desc_element_straight_double)
-         technic_cnc_api.register_element_edge_double(recipeitem, groups, images, desc_element_edge_double)
-         technic_cnc_api.register_element_t_double(recipeitem, groups, images, desc_element_t_double)
-         technic_cnc_api.register_element_cross_double(recipeitem, groups, images, desc_element_cross_double)
-         technic_cnc_api.register_element_end_double(recipeitem, groups, images, desc_element_end_double)
-end
diff --git a/technic/cnc_nodes.lua b/technic/cnc_nodes.lua
deleted file mode 100644 (file)
index 3d263b9..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
--- REGISTER MATERIALS AND PROPERTIES FOR NONCUBIC ELEMENTS:
------------------------------------------------------------
--- DIRT
--------
-technic_cnc_api.register_all("default:dirt",
-                {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
-                {"default_grass.png", "default_dirt.png", "default_grass.png"},
-                "Dirt")
-technic_cnc_api.cnc_programs_disable["default:dirt"] = {"technic_cnc_sphere", "technic_cnc_slope_upsdown",
-                                                       "technic_cnc_edge",   "technic_cnc_inner_edge",
-                                                       "technic_cnc_slope_edge_upsdown", "technic_cnc_slope_inner_edge_upsdown",
-                                                       "technic_cnc_stick", "technic_cnc_cylinder_horizontal"}
-
--- TREE
--------
-technic_cnc_api.register_all("default:tree",
-                {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
-                {"default_tree.png"},
-                "Wooden")
-
--- WOOD
--------
-technic_cnc_api.register_all("default:wood",
-                {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
-                {"default_wood.png"},
-                "Wooden")
--- STONE
---------
-technic_cnc_api.register_all("default:stone",
-                {cracky=3,not_in_creative_inventory=1},
-                {"default_stone.png"},
-                "Stone")
--- COBBLE
----------
-technic_cnc_api.register_all("default:cobble",
-                {cracky=3,not_in_creative_inventory=1},
-                {"default_cobble.png"},
-                "Cobble")
--- BRICK
---------
-technic_cnc_api.register_all("default:brick",
-                {cracky=3,not_in_creative_inventory=1},
-                {"default_brick.png"},
-                "Brick")
-
--- SANDSTONE
-------------
-technic_cnc_api.register_all("default:sandstone",
-                {crumbly=2,cracky=2,not_in_creative_inventory=1},
-                {"default_sandstone.png"},
-                "Sandstone")
-
--- LEAVES
----------
-technic_cnc_api.register_all("default:leaves",
-                {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
-                {"default_leaves.png"},
-                "Leaves")
--- TREE
--------
-technic_cnc_api.register_all("default:tree",
-                {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1,not_in_creative_inventory=1},
-                {"default_tree.png"},
-                "Tree")
--- STEEL
---------
-technic_cnc_api.register_all("default:steel",
-                {snappy=1,bendy=2,cracky=1,melty=2,level=2,not_in_creative_inventory=1},
-                {"default_steel_block.png"},
-                "Steel")
diff --git a/technic/constructor.lua b/technic/constructor.lua
deleted file mode 100644 (file)
index 2b031e5..0000000
+++ /dev/null
@@ -1,344 +0,0 @@
-
-minetest.register_craft({
-       type = "shapeless",
-       output = 'technic:constructor_mk1_off 1',
-       recipe = {'technic:nodebreaker_off', 'technic:deployer_off'},
-
-})
-minetest.register_craft({
-       type = "shapeless",
-       output = 'technic:constructor_mk2_off 1',
-       recipe = {'technic:constructor_mk1_off', 'technic:constructor_mk1_off'},
-
-})
-
-minetest.register_craft({
-       type = "shapeless",
-       output = 'technic:constructor_mk3_off 1',
-       recipe = {'technic:constructor_mk2_off', 'technic:constructor_mk2_off'},
-
-})
-
-mk1_on = function(pos, node)
-       local meta = minetest.env:get_meta(pos)
-       local inv = meta:get_inventory()
-       local pos1={}
-       pos1.x=pos.x
-       pos1.y=pos.y
-       pos1.z=pos.z
-       if node.param2==3 then pos1.x=pos1.x+1 end
-       if node.param2==2 then pos1.z=pos1.z+1 end
-       if node.param2==1 then pos1.x=pos1.x-1 end
-       if node.param2==0 then pos1.z=pos1.z-1 end
-
-       if node.name == "technic:constructor_mk1_off" then
-               hacky_swap_node(pos,"technic:constructor_mk1_on")
-               nodeupdate(pos)
-               local node1=minetest.env:get_node(pos1)
-               deploy_node (inv,"slot1",pos1,node1,node)
-       end
-end
-
-mk1_off = function(pos, node)
-       if node.name == "technic:constructor_mk1_on" then
-               hacky_swap_node(pos,"technic:constructor_mk1_off")
-               nodeupdate(pos)
-       end
-end
-
-
-minetest.register_node("technic:constructor_mk1_off", {
-       description = "Constructor MK1",
-       tile_images = {"technic_constructor_mk1_top_off.png","technic_constructor_mk1_bottom_off.png","technic_constructor_mk1_side2_off.png","technic_constructor_mk1_side1_off.png",
-                       "technic_constructor_back.png","technic_constructor_front_off.png"},
-       is_ground_content = true,
-       paramtype2 = "facedir",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2},
-       mesecons= {effector={action_on=mk1_on}},
-       sounds = default.node_sound_stone_defaults(),
-       on_construct = function(pos)
-       local meta = minetest.env:get_meta(pos)
-       meta:set_string("formspec",
-                               "invsize[8,9;]"..
-                               "label[0,0;Constructor MK1]"..
-                               "label[5,0;Slot 1]"..
-                               "list[current_name;slot1;6,0;1,1;]"..
-                               "list[current_player;main;0,5;8,4;]")
-               meta:set_string("infotext", "Constructor MK1")
-               local inv = meta:get_inventory()
-               inv:set_size("slot1", 1)
-       end,
-
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos)
-               local inv = meta:get_inventory()
-               return inv:is_empty("slot1")
-       end,    
-})
-
-minetest.register_node("technic:constructor_mk1_on", {
-       description = "Constructor MK1",
-       tile_images = {"technic_constructor_mk1_top_on.png","technic_constructor_mk1_bottom_on.png","technic_constructor_mk1_side2_on.png","technic_constructor_mk1_side1_on.png",
-                       "technic_constructor_back.png","technic_constructor_front_on.png"},
-       is_ground_content = true,
-       paramtype2 = "facedir",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon = 2,not_in_creative_inventory=1},
-       mesecons= {effector={action_off=mk1_off}},
-       sounds = default.node_sound_stone_defaults(),
-})
-
-
---Constructor MK2
-
-mk2_on = function(pos, node)
-       local meta = minetest.env:get_meta(pos)
-       local inv = meta:get_inventory()
-       local pos1={}
-       local pos2={}
-       pos1.x=pos.x
-       pos1.y=pos.y
-       pos1.z=pos.z
-       pos2.x=pos.x
-       pos2.y=pos.y
-       pos2.z=pos.z
-       if node.param2==3 then pos1.x=pos1.x+1 pos2.x=pos2.x+2 end
-       if node.param2==2 then pos1.z=pos1.z+1 pos2.z=pos2.z+2 end
-       if node.param2==1 then pos1.x=pos1.x-1 pos2.x=pos2.x-2 end
-       if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 end
-
-       if node.name == "technic:constructor_mk2_off" then
-               hacky_swap_node(pos,"technic:constructor_mk2_on")
-               nodeupdate(pos)
-               local node1=minetest.env:get_node(pos1)
-               deploy_node (inv,"slot1",pos1,node1,node)
-               local node1=minetest.env:get_node(pos2) 
-               deploy_node (inv,"slot2",pos2,node1,node)
-       end
-end
-
-mk2_off = function(pos, node)
-       if node.name == "technic:constructor_mk2_on" then
-               hacky_swap_node(pos,"technic:constructor_mk2_off")
-               nodeupdate(pos)
-       end
-end
-
-minetest.register_node("technic:constructor_mk2_off", {
-       description = "Constructor MK2",
-       tile_images = {"technic_constructor_mk2_top_off.png","technic_constructor_mk2_bottom_off.png","technic_constructor_mk2_side2_off.png","technic_constructor_mk2_side1_off.png",
-                       "technic_constructor_back.png","technic_constructor_front_off.png"},
-       is_ground_content = true,
-       paramtype2 = "facedir",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2},
-       mesecons= {effector={action_on=mk2_on}},
-       sounds = default.node_sound_stone_defaults(),
-       on_construct = function(pos)
-       local meta = minetest.env:get_meta(pos)
-       meta:set_string("formspec",
-                               "invsize[8,9;]"..
-                               "label[0,0;Constructor MK2]"..
-                               "label[5,0;Slot 1]"..
-                               "list[current_name;slot1;6,0;1,1;]"..
-                               "label[5,1;Slot 2]"..
-                               "list[current_name;slot2;6,1;1,1;]"..
-                               "list[current_player;main;0,5;8,4;]")
-               meta:set_string("infotext", "Constructor MK2")
-               local inv = meta:get_inventory()
-               inv:set_size("slot1", 1)
-               inv:set_size("slot2", 1)
-       end,
-
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos)
-               local inv = meta:get_inventory()
-               if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false then return false end
-               return true
-       end,    
-})
-
-minetest.register_node("technic:constructor_mk2_on", {
-       description = "Constructor MK2",
-       tile_images = {"technic_constructor_mk2_top_on.png","technic_constructor_mk2_bottom_on.png","technic_constructor_mk2_side2_on.png","technic_constructor_mk2_side1_on.png",
-                       "technic_constructor_back.png","technic_constructor_front_on.png"},
-       is_ground_content = true,
-       paramtype2 = "facedir",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2, not_in_creative_inventory=1},
-       mesecons= {effector={action_off=mk2_off}},
-       sounds = default.node_sound_stone_defaults(),
-})
-
-
--- Constructor MK3
-mk3_on = function(pos, node)
-       local meta = minetest.env:get_meta(pos)
-       local inv = meta:get_inventory()
-       
-       local pos1={}
-       local pos2={}
-       local pos3={}
-       local pos4={}
-       
-       pos1.x=pos.x
-       pos1.y=pos.y
-       pos1.z=pos.z
-       
-       pos2.x=pos.x
-       pos2.y=pos.y
-       pos2.z=pos.z
-       
-       pos3.x=pos.x
-       pos3.y=pos.y
-       pos3.z=pos.z
-
-       pos4.x=pos.x
-       pos4.y=pos.y
-       pos4.z=pos.z
-
-       if node.param2==3 then pos1.x=pos1.x+1 pos2.x=pos2.x+2 pos3.x=pos3.x+3 pos4.x=pos4.x+4 end
-       if node.param2==2 then pos1.z=pos1.z+1 pos2.z=pos2.z+2 pos3.z=pos3.z+3 pos4.z=pos4.z+4 end
-       if node.param2==1 then pos1.x=pos1.x-1 pos2.x=pos2.x-2 pos3.x=pos3.x-3 pos4.x=pos4.x-4 end
-       if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 pos3.z=pos3.z-3 pos4.z=pos4.z-4 end
-
-       if node.name == "technic:constructor_mk3_off" then
-               hacky_swap_node(pos,"technic:constructor_mk3_on")
-               nodeupdate(pos)
-               local node1=minetest.env:get_node(pos1)
-               deploy_node (inv,"slot1",pos1,node1,node)
-               local node1=minetest.env:get_node(pos2) 
-               deploy_node (inv,"slot2",pos2,node1,node)
-               local node1=minetest.env:get_node(pos3) 
-               deploy_node (inv,"slot3",pos3,node1,node)
-               local node1=minetest.env:get_node(pos4) 
-               deploy_node (inv,"slot4",pos4,node1,node)
-       end
-end
-
-mk3_off = function(pos, node)
-       if node.name == "technic:constructor_mk3_on" then
-               hacky_swap_node(pos,"technic:constructor_mk3_off")
-               nodeupdate(pos)
-       end
-end
-
-minetest.register_node("technic:constructor_mk3_off", {
-       description = "Constructor MK3",
-       tile_images = {"technic_constructor_mk3_top_off.png","technic_constructor_mk3_bottom_off.png","technic_constructor_mk3_side2_off.png","technic_constructor_mk3_side1_off.png",
-                       "technic_constructor_back.png","technic_constructor_front_off.png"},
-       is_ground_content = true,
-       paramtype2 = "facedir",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2},
-       mesecons= {effector={action_on=mk3_on}},
-       sounds = default.node_sound_stone_defaults(),
-       on_construct = function(pos)
-       local meta = minetest.env:get_meta(pos)
-       meta:set_string("formspec",
-                               "invsize[8,9;]"..
-                               "label[0,0;Constructor MK2]"..
-                               "label[5,0;Slot 1]"..
-                               "list[current_name;slot1;6,0;1,1;]"..
-                               "label[5,1;Slot 2]"..
-                               "list[current_name;slot2;6,1;1,1;]"..
-                               "label[5,2;Slot 3]"..
-                               "list[current_name;slot3;6,2;1,1;]"..
-                               "label[5,3;Slot 4]"..
-                               "list[current_name;slot4;6,3;1,1;]"..
-                               "list[current_player;main;0,5;8,4;]")
-               meta:set_string("infotext", "Constructor MK3")
-               local inv = meta:get_inventory()
-               inv:set_size("slot1", 1)
-               inv:set_size("slot2", 1)
-               inv:set_size("slot3", 1)
-               inv:set_size("slot4", 1)
-
-       end,
-
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos)
-               local inv = meta:get_inventory()
-               if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false or inv:is_empty("slot3")==false or inv:is_empty("slot4")==false then return false end
-               return true
-       end,    
-})
-
-minetest.register_node("technic:constructor_mk3_on", {
-       description = "Constructor MK3",
-       tile_images = {"technic_constructor_mk3_top_on.png","technic_constructor_mk3_bottom_on.png","technic_constructor_mk3_side2_on.png","technic_constructor_mk3_side1_on.png",
-                       "technic_constructor_back.png","technic_constructor_front_on.png"},
-       is_ground_content = true,
-       paramtype2 = "facedir",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,not_in_creative_inventory=1},
-       mesecons= {effector={action_off=mk3_off}},
-       sounds = default.node_sound_stone_defaults(),
-})
-
-
-deploy_node =function (inv, slot_name, pos1, node1, node)
-       if node1.name == "air" then 
-               if not inv:is_empty(slot_name) then
-                       stack1=inv:get_list(slot_name)
-                       local def = stack1[1]:get_definition()
-                       if def.type == "node" then
-                               node_to_be_placed={name=stack1[1]:get_name(), param1=0, param2=node.param2}
-                               minetest.env:set_node(pos1,node_to_be_placed)
-                               stack1[1]:take_item()
-                               inv:set_stack(slot_name, 1, stack1[1])
-                       elseif def.type == "craft" then
-                               if def.on_place then
-                                       -- print("deploy_node: item has on_place. trying...")
-                                       local ok, stk = pcall(def.on_place, stack1[1], nil, {
-                                               -- Fake pointed_thing
-                                               type = "node",
-                                               above = pos1,
-                                               under = { x=pos1.x, y=pos1.y-1, z=pos1.z },
-                                       })
-                                       if ok then
-                                               -- print("deploy_node: on_place succeeded!")
-                                               inv:set_stack(slot_name, 1, stk or stack1[1])
-                                               return
-                                       -- else
-                                               -- print("deploy_node: WARNING: error while running on_place: "..tostring(stk))
-                                       end
-                               end
-                               minetest.item_place_object(stack1[1], nil, {
-                                       -- Fake pointed_thing
-                                       type = "node",
-                                       above = pos1,
-                                       under = pos1,
-                               })
-                               inv:set_stack(slot_name, 1, nil)
-                       end
-               end
-               return 
-       end
-       if node1.name == "ignore" or
-          node1.name == "default:lava_source" or
-          node1.name == "default:lava_flowing" or
-          node1.name == "default:water_source" or
-          node1.name == "default:water_flowing" 
-          then return end
-       if inv:room_for_item(slot_name,node1) then
-               local def = minetest.registered_nodes[node1.name]
-               if not def then return end
-               local drop = def.drop or node1.name
-               if type(drop) == "table" then
-                       local pr = PseudoRandom(math.random())
-                       local c = 0
-                       local loop = 0 -- Prevent infinite loop
-                       while (c < (drop.max_items or 1)) and (loop < 1000) do
-                               local i = math.floor(pr:next(1, #drop.items))
-                               if pr:next(1, drop.items[i].rarity or 1) == 1 then
-                                       for _,item in ipairs(drop.items[i].items) do
-                                               inv:add_item(slot_name,item)
-                                       end
-                                       c = c + 1
-                               end
-                               loop = loop + 1
-                       end
-                       minetest.env:remove_node(pos1)
-               elseif type(drop) == "string" then
-                       inv:add_item(slot_name,drop)
-                       minetest.env:remove_node(pos1)
-               end
-       end
-
-end
diff --git a/technic/creative.lua b/technic/creative.lua
deleted file mode 100644 (file)
index 7b4c493..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-technic.creative_inventory_size = 0
-technic.creative_list = {}
-
--- Create detached creative inventory after loading all mods
-minetest.after(0, function()
-       local inv = minetest.create_detached_inventory("technic_creative", {})
-       technic.creative_list = {}
-       for name,def in pairs(minetest.registered_items) do
-               if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0)
-                               and def.description and def.description ~= "" then
-                       table.insert(technic.creative_list, name)
-               end
-       end
-       table.sort(technic.creative_list)
-       --inv:set_size("main", #technic.creative_list)
-       --for _,itemstring in ipairs(technic.creative_list) do
-       --      local stack = ItemStack(itemstring)
-       --      inv:add_item("main", stack)
-       --end
-       --technic.creative_inventory_size = #technic.creative_list
-end)
diff --git a/technic/deployer.lua b/technic/deployer.lua
deleted file mode 100644 (file)
index c5dba2a..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-minetest.register_craft({
-       output = 'technic:deployer_off 1',
-       recipe = {
-               {'default:wood', 'default:chest','default:wood'},
-               {'default:stone', 'mesecons:piston','default:stone'},
-               {'default:stone', 'mesecons:mesecon','default:stone'},
-
-       }
-})
-
-deployer_signal_on = function(pos, node)
-       local pos1={}
-       pos1.x=pos.x
-       pos1.y=pos.y
-       pos1.z=pos.z
-       if node.param2==3 then pos1.x=pos1.x+1 end
-       if node.param2==2 then pos1.z=pos1.z+1 end
-       if node.param2==1 then pos1.x=pos1.x-1 end
-       if node.param2==0 then pos1.z=pos1.z-1 end
-
-       if node.name == "technic:deployer_off" then
-               local node1=minetest.env:get_node(pos1)
-               if node1.name == "air" then 
-                       hacky_swap_node(pos,"technic:deployer_on")
-                       nodeupdate(pos)
-                       local meta = minetest.env:get_meta(pos);
-                       local inv = meta:get_inventory()
-                       local i=0
-                       for _,stack in ipairs(inv:get_list("main")) do
-                       i=i+1
-                       if stack:get_name() ~=nil and minetest.registered_nodes[stack:get_name()]~=nil then 
-                               node1={name=stack:get_name(), param1=0, param2=node.param2}
-                               minetest.env:place_node(pos1,node1)
-                               stack:take_item(1);
-                               inv:set_stack("main", i, stack)
-                               return
-                               end
-                       end
-       end
-       end
-end
-
-deployer_signal_off = function(pos, node)
-       if node.name == "technic:deployer_on" then
-               hacky_swap_node(pos,"technic:deployer_off")
-               nodeupdate(pos)
-       end
-end
-
-minetest.register_node("technic:deployer_off", {
-       description = "Deployer",
-       tile_images = {"technic_deployer_top.png","technic_deployer_bottom.png","technic_deployer_side2.png","technic_deployer_side1.png",
-                       "technic_deployer_back.png","technic_deployer_front_off.png"},
-       is_ground_content = true,
-       paramtype2 = "facedir",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, tubedevice_receiver=1},
-       mesecons = {effector={action_on=deployer_signal_on}},
-       tube={insert_object=function(pos,node,stack,direction)
-                       local meta=minetest.env:get_meta(pos)
-                       local inv=meta:get_inventory()
-                       return inv:add_item("main",stack)
-               end,
-               can_insert=function(pos,node,stack,direction)
-                       local meta=minetest.env:get_meta(pos)
-                       local inv=meta:get_inventory()
-                       return inv:room_for_item("main",stack)
-               end,
-               input_inventory="main"},
-       sounds = default.node_sound_stone_defaults(),
-       on_construct = function(pos)
-       local meta = minetest.env:get_meta(pos)
-       meta:set_string("formspec",
-                               "invsize[8,9;]"..
-                               "label[0,0;Deployer]"..
-                               "list[current_name;main;4,1;3,3;]"..
-                               "list[current_player;main;0,5;8,4;]")
-               meta:set_string("infotext", "Deployer")
-               local inv = meta:get_inventory()
-               inv:set_size("main", 3*3)
-       end,
-
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               if not inv:is_empty("main") then
-                       return false
-               end
-               return true
-               end,
-       
-})
-
-minetest.register_node("technic:deployer_on", {
-       description = "Deployer",
-       tile_images = {"technic_deployer_top.png","technic_deployer_bottom.png","technic_deployer_side2.png","technic_deployer_side1.png",
-                       "technic_deployer_back.png","technic_deployer_front_on.png"},
-       is_ground_content = true,
-       paramtype2 = "facedir",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, tubedevice_receiver=1,not_in_creative_inventory=1},
-       mesecons = {effector={action_off=deployer_signal_off}},
-               tube={insert_object=function(pos,node,stack,direction)
-                       local meta=minetest.env:get_meta(pos)
-                       local inv=meta:get_inventory()
-                       return inv:add_item("main",stack)
-               end,
-               can_insert=function(pos,node,stack,direction)
-                       local meta=minetest.env:get_meta(pos)
-                       local inv=meta:get_inventory()
-                       return inv:room_for_item("main",stack)
-               end,
-               input_inventory="main"},
-       sounds = default.node_sound_stone_defaults(),
-})
diff --git a/technic/down_converter_hv.lua b/technic/down_converter_hv.lua
deleted file mode 100644 (file)
index 0e2e16d..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
--- The HV down converter will step down HV EUs to MV EUs
--- If we take the solar panel as calibration then the
--- 1 HVEU = 5 MVEU as we stack 5 MV arrays to get a HV array.
--- The downconverter does of course have a conversion loss.
--- This loses 30% of the power.
--- The converter does not store any energy by itself.
-minetest.register_node("technic:down_converter_hv", {
-        description = "HV Down Converter",
-       tiles  = {"technic_hv_down_converter_top.png", "technic_hv_down_converter_bottom.png", "technic_hv_down_converter_side.png",
-                 "technic_hv_down_converter_side.png", "technic_hv_down_converter_side.png", "technic_hv_down_converter_side.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       sounds = default.node_sound_wood_defaults(),
-       drawtype = "nodebox",
-       paramtype = "light",
-       is_ground_content = true,
-       node_box = {
-          type = "fixed",
-          fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
-       },
-       selection_box = {
-          type = "fixed",
-          fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
-       },
-       on_construct = function(pos)
-                         local meta = minetest.env:get_meta(pos)
-                         meta:set_float("technic_hv_power_machine", 1)
-                         meta:set_float("technic_mv_power_machine", 1)
-                         meta:set_float("internal_EU_buffer",0)
-                         meta:set_float("internal_EU_buffer_size",0)
-                         meta:set_string("infotext", "HV Down Converter")
-                         meta:set_float("active", false)
-                      end,
-     })
-
-minetest.register_craft({
-       output = 'technic:down_converter_hv 1',
-       recipe = {
-               {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot','technic:stainless_steel_ingot'},
-               {'technic:hv_transformer',        'technic:hv_cable',             'technic:mv_transformer'},
-               {'technic:hv_cable',              'technic:rubber',               'technic:mv_cable'},
-       }
-})
-
-minetest.register_abm(
-       {nodenames = {"technic:down_converter_hv"},
-       interval   = 1,
-       chance     = 1,
-       action = function(pos, node, active_object_count, active_object_count_wider)
-                   -- HV->MV conversion factor
-                   local hv_mv_factor = 5
-                   -- The maximun charge a single converter can handle. Let's set this to
-                   -- what 5 HV solar arrays can produce - 30% loss (2880*5*0.7)
-                   local max_charge = 10080*hv_mv_factor
-
-                   local meta             = minetest.env:get_meta(pos)
-                   local meta1            = nil
-                   local pos1             = {}
-                   local available_charge = 0 -- counted in MV units
-                   local used_charge      = 0 -- counted in MV units
-
-                   -- Index all HV nodes connected to the network
-                   -- HV cable comes in through the bottom
-                   pos1.y = pos.y-1
-                   pos1.x = pos.x
-                   pos1.z = pos.z
-                   meta1  = minetest.env:get_meta(pos1)
-                   if meta1:get_float("hv_cablelike")~=1 then return end
-
-                   local HV_nodes    = {} -- HV type
-                   local HV_PR_nodes = {} -- HV type
-                   local HV_BA_nodes = {} -- HV type
-
-                   HV_nodes[1]         = {}
-                   HV_nodes[1].x       = pos1.x
-                   HV_nodes[1].y       = pos1.y
-                   HV_nodes[1].z       = pos1.z
-
-                   local table_index = 1
-                   repeat
-                      check_HV_node(HV_PR_nodes,nil,HV_BA_nodes,HV_nodes,table_index)
-                      table_index = table_index + 1
-                      if HV_nodes[table_index] == nil then break end
-                   until false
-
-                   --print("HV_nodes: PR="..table.getn(HV_PR_nodes).." BA="..table.getn(HV_BA_nodes))
-
-                   -- Index all MV nodes connected to the network
-                   -- MV cable comes out of the top
-                   pos1.y = pos.y+1
-                   pos1.x = pos.x
-                   pos1.z = pos.z
-                   meta1  = minetest.env:get_meta(pos1)
-                   if meta1:get_float("mv_cablelike")~=1 then return end
-
-                   local MV_nodes    = {} -- MV type
-                   local MV_RE_nodes = {} -- MV type
-                   local MV_BA_nodes = {} -- MV type
-
-                   MV_nodes[1]         = {}
-                   MV_nodes[1].x       = pos1.x
-                   MV_nodes[1].y       = pos1.y
-                   MV_nodes[1].z       = pos1.z
-
-                   table_index = 1
-                   repeat
-                      check_MV_node(nil,MV_RE_nodes,MV_BA_nodes,MV_nodes,table_index)
-                      table_index = table_index + 1
-                      if MV_nodes[table_index] == nil then break end
-                   until false
-
-                   --print("MV_nodes: RE="..table.getn(MV_RE_nodes).." BA="..table.getn(MV_BA_nodes))
-
-                   -- First get available power from all the attached HV suppliers
-                   -- Get the supplier internal EU buffer and read the EUs from it
-                   -- No update yet!
-                   local pos1
--- FIXME: Until further leave the producers out of it and just let the batteries be the hub
---                 for _,pos1 in ipairs(HV_PR_nodes) do
---                    meta1  = minetest.env:get_meta(pos1)
---                    local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
---                    available_charge = available_charge + meta1:get_float("internal_EU_buffer") * hv_mv_factor
---                    -- Limit conversion capacity
---                    if available_charge > max_charge then
---                       available_charge = max_charge
---                       break
---                    end
---                 end
---                 --print("Available_charge PR:"..available_charge)
-
-                   for _,pos1 in ipairs(HV_BA_nodes) do
-                      meta1  = minetest.env:get_meta(pos1)
-                      local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
-                      available_charge = available_charge + meta1:get_float("internal_EU_buffer") * hv_mv_factor
-                      -- Limit conversion capacity
-                      if available_charge > max_charge then
-                         available_charge = max_charge
-                         break
-                      end
-                   end
-                   --print("Available_charge PR+BA:"..available_charge)
-
-                   -- Calculate total number of receivers:
-                   local MV_receivers = table.getn(MV_RE_nodes)+table.getn(MV_BA_nodes)
-
-                   -- Next supply power to all connected MV machines
-                   -- Get the power receiver internal EU buffer and give EUs to it
-                   -- Note: for now leave out RE type machines until producers distribute power themselves even without a battery
---                 for _,pos1 in ipairs(MV_RE_nodes) do
---                    local meta1                   = minetest.env:get_meta(pos1)
---                    local internal_EU_buffer      = meta1:get_float("internal_EU_buffer")
---                    local internal_EU_buffer_size = meta1:get_float("internal_EU_buffer_size")
---                    local charge_to_give = math.min(4000, available_charge/MV_receivers) -- power rating limit on the MV wire
---                    -- How much can this unit take?
---                    if internal_EU_buffer+charge_to_give > internal_EU_buffer_size then
---                       charge_to_give=internal_EU_buffer_size-internal_EU_buffer
---                    end
---                    -- If we are emptying the supply take the remainder
---                    if available_charge<used_charge+charge_to_give then charge_to_give=available_charge-used_charge end
---                    -- Update the unit supplied to
---                    internal_EU_buffer = internal_EU_buffer + charge_to_give
---                    meta1:set_float("internal_EU_buffer",internal_EU_buffer)
---                    -- Do the accounting
---                    used_charge = used_charge + charge_to_give
---                    if available_charge == used_charge then break end -- bail out if supply depleted
---                 end
-                   --print("used_charge RE:"..used_charge)
-
-                   for _,pos1 in ipairs(MV_BA_nodes) do
-                      local meta1 = minetest.env:get_meta(pos1)
-                      local internal_EU_buffer      = meta1:get_float("internal_EU_buffer")
-                      local internal_EU_buffer_size = meta1:get_float("internal_EU_buffer_size")
-                      --print("internal_EU_buffer:"..internal_EU_buffer)
-                      --print("internal_EU_buffer_size:"..internal_EU_buffer_size)
-                      local charge_to_give = math.min(math.floor(available_charge/MV_receivers), 4000) -- power rating limit on the MV wire
-                      --print("charge_to_give:"..charge_to_give)
-                      -- How much can this unit take?
-                      if internal_EU_buffer+charge_to_give > internal_EU_buffer_size then
-                         charge_to_give=internal_EU_buffer_size-internal_EU_buffer
-                      end
-                      --print("charge_to_give2:"..charge_to_give)
-                      -- If we are emptying the supply take the remainder
-                      if available_charge<used_charge+charge_to_give then charge_to_give=available_charge-used_charge end
-                      -- Update the unit supplied to
-                      --print("charge_to_give3:"..charge_to_give)
-                      internal_EU_buffer = internal_EU_buffer + charge_to_give
-                      --print("internal_EU_buffer:"..internal_EU_buffer)
-                      meta1:set_float("internal_EU_buffer",internal_EU_buffer)
-                      -- Do the accounting
-                      used_charge = used_charge + charge_to_give
-                      --print("used_charge:"..used_charge)
-                      if available_charge == used_charge then break end -- bail out if supply depleted
-                   end
-                   --print("used_charge RE+BA:"..used_charge)
-
-                   -- Last update the HV suppliers with the actual demand.
-                   -- Get the supplier internal EU buffer and update the EUs from it
-                   -- Note: So far PR nodes left out and only BA nodes are updated
-                   local HV_BA_size = table.getn(HV_BA_nodes)
-                   for _,pos1 in ipairs(HV_BA_nodes) do
-                      meta1  = minetest.env:get_meta(pos1)
-                      local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
-                      local charge_to_take = math.floor(used_charge/HV_BA_size/hv_mv_factor) -- HV units
-                      if internal_EU_buffer-charge_to_take <= 0 then
-                         charge_to_take = internal_EU_buffer
-                      end
-                      if charge_to_take > 0 then
-                         internal_EU_buffer = internal_EU_buffer-charge_to_take
-                         meta1:set_float("internal_EU_buffer",internal_EU_buffer)
-                      end
-                   end
-
-                   if used_charge>0 then
-                      meta:set_string("infotext", "HV Down Converter is active (HV:"..available_charge.."/MV:"..used_charge..")");
-                      meta:set_float("active",1) -- used for setting textures someday maybe
-                   else
-                      meta:set_string("infotext", "HV Down Converter is inactive (HV:"..available_charge.."/MV:"..used_charge..")");
-                      meta:set_float("active",0) -- used for setting textures someday maybe
-                      return
-                   end
-       end,
-})
-
--- This machine does not store energy it receives energy from the HV side and outputs it on the MV side
-register_HV_machine ("technic:down_converter_hv","RE")
-register_MV_machine ("technic:down_converter_hv","PR")
diff --git a/technic/down_converter_mv.lua b/technic/down_converter_mv.lua
deleted file mode 100644 (file)
index 1d26630..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
--- The MV down converter will step down MV EUs to LV EUs
--- If we take the solar panel as calibration then the
--- 1 MVEU = 5 LVEU as we stack 5 LV arrays to get an MV array.
--- The downconverter does of course have a conversion loss.
--- This loses 30% of the power.
--- The converter does not store any energy by itself.
-minetest.register_node(
-   "technic:down_converter_mv", {
-      description = "MV Down Converter",
-      tiles  = {"technic_mv_down_converter_top.png", "technic_mv_down_converter_bottom.png", "technic_mv_down_converter_side.png",
-               "technic_mv_down_converter_side.png", "technic_mv_down_converter_side.png", "technic_mv_down_converter_side.png"},
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-      sounds = default.node_sound_wood_defaults(),
-      drawtype = "nodebox",
-      paramtype = "light",
-      is_ground_content = true,
-      node_box = {
-        type = "fixed",
-        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
-      },
-      selection_box = {
-        type = "fixed",
-        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
-      },
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       meta:set_float("technic_mv_power_machine", 1)
-                       meta:set_float("technic_power_machine", 1)
-                       meta:set_float("internal_EU_buffer",0)
-                       meta:set_float("internal_EU_buffer_size",0)
-                       meta:set_string("infotext", "MV Down Converter")
-                         meta:set_float("active", false)
-                      end,
-   })
-
-minetest.register_craft({
-       output = 'technic:down_converter_mv 1',
-       recipe = {
-               {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot','technic:stainless_steel_ingot'},
-               {'technic:mv_transformer',        'technic:mv_cable',             'technic:lv_transformer'},
-               {'technic:mv_cable',              'technic:rubber',               'technic:lv_cable'},
-       }
-})
-
-minetest.register_abm(
-       {nodenames = {"technic:down_converter_mv"},
-       interval   = 1,
-       chance     = 1,
-       action = function(pos, node, active_object_count, active_object_count_wider)
-                   -- MV->LV conversion factor
-                   local mv_lv_factor = 5
-                   -- The maximun charge a single converter can handle. Let's set this to
-                   -- what 5 MV solar arrays can produce - 30% loss (720*5*0.7)
-                   local max_charge = 2520*mv_lv_factor
-
-                   local meta             = minetest.env:get_meta(pos)
-                   local meta1            = nil
-                   local pos1             = {}
-                   local available_charge = 0 -- counted in LV units
-                   local used_charge      = 0 -- counted in LV units
-
-                   -- Index all MV nodes connected to the network
-                   -- MV cable comes in through the bottom
-                   pos1.y = pos.y-1
-                   pos1.x = pos.x
-                   pos1.z = pos.z
-                   meta1  = minetest.env:get_meta(pos1)
-                   if meta1:get_float("mv_cablelike")~=1 then return end
-
-                   local MV_nodes    = {} -- MV type
-                   local MV_PR_nodes = {} -- MV type
-                   local MV_BA_nodes = {} -- MV type
-
-                   MV_nodes[1]         = {}
-                   MV_nodes[1].x       = pos1.x
-                   MV_nodes[1].y       = pos1.y
-                   MV_nodes[1].z       = pos1.z
-
-                   local table_index = 1
-                   repeat
-                      check_MV_node(MV_PR_nodes,nil,MV_BA_nodes,MV_nodes,table_index)
-                      table_index = table_index + 1
-                      if MV_nodes[table_index] == nil then break end
-                   until false
-
-                   --print("MV_nodes: PR="..table.getn(MV_PR_nodes).." BA="..table.getn(MV_BA_nodes))
-
-                   -- Index all LV nodes connected to the network
-                   -- LV cable comes out of the top
-                   pos1.y = pos.y+1
-                   pos1.x = pos.x
-                   pos1.z = pos.z
-                   meta1  = minetest.env:get_meta(pos1)
-                   if meta1:get_float("cablelike")~=1 then return end
-
-                   local LV_nodes    = {} -- LV type
-                   local LV_RE_nodes = {} -- LV type
-                   local LV_BA_nodes = {} -- LV type
-
-                   LV_nodes[1]         = {}
-                   LV_nodes[1].x       = pos1.x
-                   LV_nodes[1].y       = pos1.y
-                   LV_nodes[1].z       = pos1.z
-
-                   table_index = 1
-                   repeat
-                      check_LV_node(nil,LV_RE_nodes,LV_BA_nodes,LV_nodes,table_index)
-                      table_index = table_index + 1
-                      if LV_nodes[table_index] == nil then break end
-                   until false
-
-                   --print("LV_nodes: RE="..table.getn(LV_RE_nodes).." BA="..table.getn(LV_BA_nodes))
-
-                   -- First get available power from all the attached MV suppliers
-                   -- Get the supplier internal EU buffer and read the EUs from it
-                   -- No update yet!
-                   local pos1
--- FIXME: Until further leave the producers out of it and just let the batteries be the hub
---                 for _,pos1 in ipairs(MV_PR_nodes) do
---                    meta1  = minetest.env:get_meta(pos1)
---                    local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
---                    available_charge = available_charge + meta1:get_float("internal_EU_buffer") * mv_lv_factor
---                    -- Limit conversion capacity
---                    if available_charge > max_charge then
---                       available_charge = max_charge
---                       break
---                    end
---                 end
---                 print("Available_charge PR:"..available_charge)
-
-                   for _,pos1 in ipairs(MV_BA_nodes) do
-                      meta1  = minetest.env:get_meta(pos1)
-                      local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
-                      available_charge = available_charge + meta1:get_float("internal_EU_buffer") * mv_lv_factor
-                      -- Limit conversion capacity
-                      if available_charge > max_charge then
-                         available_charge = max_charge
-                         break
-                      end
-                   end
-                   --print("Available_charge PR+BA:"..available_charge)
-
-                   -- Calculate total number of receivers:
-                   local LV_receivers = table.getn(LV_RE_nodes)+table.getn(LV_BA_nodes)
-
-                   -- Next supply power to all connected LV machines
-                   -- Get the power receiver internal EU buffer and give EUs to it
-                   -- Note: for now leave out RE type machines until producers distribute power themselves even without a battery
---                 for _,pos1 in ipairs(LV_RE_nodes) do
---                    local meta1                   = minetest.env:get_meta(pos1)
---                    local internal_EU_buffer      = meta1:get_float("internal_EU_buffer")
---                    local internal_EU_buffer_size = meta1:get_float("internal_EU_buffer_size")
---                    local charge_to_give = math.min(1000, available_charge/LV_receivers) -- power rating limit on the LV wire
---                    -- How much can this unit take?
---                    if internal_EU_buffer+charge_to_give > internal_EU_buffer_size then
---                       charge_to_give=internal_EU_buffer_size-internal_EU_buffer
---                    end
---                    -- If we are emptying the supply take the remainder
---                    if available_charge<used_charge+charge_to_give then charge_to_give=available_charge-used_charge end
---                    -- Update the unit supplied to
---                    internal_EU_buffer = internal_EU_buffer + charge_to_give
---                    meta1:set_float("internal_EU_buffer",internal_EU_buffer)
---                    -- Do the accounting
---                    used_charge = used_charge + charge_to_give
---                    if available_charge == used_charge then break end -- bail out if supply depleted
---                 end
-                   --print("used_charge RE:"..used_charge)
-
-                   for _,pos1 in ipairs(LV_BA_nodes) do
-                      local meta1 = minetest.env:get_meta(pos1)
-                      local internal_EU_buffer      = meta1:get_float("internal_EU_buffer")
-                      local internal_EU_buffer_size = meta1:get_float("internal_EU_buffer_size")
-                      --print("internal_EU_buffer:"..internal_EU_buffer)
-                      --print("internal_EU_buffer_size:"..internal_EU_buffer_size)
-                      local charge_to_give = math.min(math.floor(available_charge/LV_receivers), 1000) -- power rating limit on the LV wire
-                      --print("charge_to_give:"..charge_to_give)
-                      -- How much can this unit take?
-                      if internal_EU_buffer+charge_to_give > internal_EU_buffer_size then
-                         charge_to_give=internal_EU_buffer_size-internal_EU_buffer
-                      end
-                      --print("charge_to_give2:"..charge_to_give)
-                      -- If we are emptying the supply take the remainder
-                      if available_charge<used_charge+charge_to_give then charge_to_give=available_charge-used_charge end
-                      -- Update the unit supplied to
-                      --print("charge_to_give3:"..charge_to_give)
-                      internal_EU_buffer = internal_EU_buffer + charge_to_give
-                      --print("internal_EU_buffer:"..internal_EU_buffer)
-                      meta1:set_float("internal_EU_buffer",internal_EU_buffer)
-                      -- Do the accounting
-                      used_charge = used_charge + charge_to_give
-                      --print("used_charge:"..used_charge)
-                      if available_charge == used_charge then break end -- bail out if supply depleted
-                   end
-                   --print("used_charge RE+BA:"..used_charge)
-
-                   -- Last update the MV suppliers with the actual demand.
-                   -- Get the supplier internal EU buffer and update the EUs from it
-                   -- Note: So far PR nodes left out and only BA nodes are updated
-                   local MV_BA_size = table.getn(MV_BA_nodes)
-                   for _,pos1 in ipairs(MV_BA_nodes) do
-                      meta1  = minetest.env:get_meta(pos1)
-                      local internal_EU_buffer = meta1:get_float("internal_EU_buffer")
-                      local charge_to_take = math.floor(used_charge/MV_BA_size/mv_lv_factor) -- MV units
-                      if internal_EU_buffer-charge_to_take <= 0 then
-                         charge_to_take = internal_EU_buffer
-                      end
-                      if charge_to_take > 0 then
-                         internal_EU_buffer = internal_EU_buffer-charge_to_take
-                         meta1:set_float("internal_EU_buffer",internal_EU_buffer)
-                      end
-                   end
-
-                   if used_charge>0 then
-                      meta:set_string("infotext", "MV Down Converter is active (MV:"..available_charge.."/LV:"..used_charge..")");
-                      meta:set_float("active",1) -- used for setting textures someday maybe
-                   else
-                      meta:set_string("infotext", "MV Down Converter is inactive (MV:"..available_charge.."/LV:"..used_charge..")");
-                      meta:set_float("active",0) -- used for setting textures someday maybe
-                      return
-                   end
-       end,
-})
-
--- This machine does not store energy it receives energy from the MV side and outputs it on the LV side
-register_MV_machine ("technic:down_converter_mv","RE")
-register_LV_machine ("technic:down_converter_mv","PR")
diff --git a/technic/electric.lua b/technic/electric.lua
deleted file mode 100644 (file)
index fc519de..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-power_tools ={}
-
-registered_power_tools_count=1
-
-function register_power_tool (string1,max_charge)
-power_tools[registered_power_tools_count]={}
-power_tools[registered_power_tools_count].tool_name=string1
-power_tools[registered_power_tools_count].max_charge=max_charge
-registered_power_tools_count=registered_power_tools_count+1
-end
-
-register_power_tool ("technic:mining_drill",60000)
-register_power_tool ("technic:laser_mk1",40000)
-register_power_tool ("technic:battery",10000)
-
-minetest.register_alias("battery", "technic:battery")
-minetest.register_alias("battery_box", "technic:battery_box")
-minetest.register_alias("electric_furnace", "technic:electric_furnace")
-
-
-minetest.register_craft({
-       output = 'technic:battery 1',
-       recipe = {
-               {'default:wood', 'default:copper_ingot', 'default:wood'},
-               {'default:wood', 'moreores:tin_ingot', 'default:wood'},
-               {'default:wood', 'default:copper_ingot', 'default:wood'},
-       }
-}) 
-
-minetest.register_craft({
-       output = 'technic:battery_box 1',
-       recipe = {
-               {'technic:battery', 'default:wood', 'technic:battery'},
-               {'technic:battery', 'default:copper_ingot', 'technic:battery'},
-               {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
-       }
-}) 
-
-minetest.register_craft({
-       output = 'technic:electric_furnace',
-       recipe = {
-               {'default:brick', 'default:brick', 'default:brick'},
-               {'default:brick', '', 'default:brick'},
-               {'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
-       }
-})
-
-
-minetest.register_tool("technic:battery",
-{description = "RE Battery",
-inventory_image = "technic_battery.png",
-energy_charge = 0,
-tool_capabilities = {max_drop_level=0, groupcaps={fleshy={times={}, uses=10000, maxlevel=0}}}}) 
-
-minetest.register_craftitem("technic:battery_box", {
-       description = "Battery box",
-       stack_max = 99,
-}) 
-
-
-
-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;Battery box]"..
-       "label[3,0;Charge]"..
-       "label[5,0;Discharge]"..
-       "label[1,3;Power level]"..
-       "list[current_player;main;0,5;8,4;]"
-
-minetest.register_node("technic:battery_box", {
-       description = "Battery box",
-       tiles = {"technic_battery_box_top.png", "technic_battery_box_bottom.png", "technic_battery_box_side.png",
-               "technic_battery_box_side.png", "technic_battery_box_side.png", "technic_battery_box_side.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       sounds = default.node_sound_wood_defaults(),
-       technic_power_machine=1,
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_string("infotext", "Battery box")
-               meta:set_float("technic_power_machine", 1)
-               meta:set_string("formspec", battery_box_formspec)
-               local inv = meta:get_inventory()
-               inv:set_size("src", 1)
-               inv:set_size("dst", 1)
-               battery_charge = 0
-               max_charge = 60000
-               end,    
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               if not inv:is_empty("dst") then
-                       return false
-               elseif not inv:is_empty("src") then
-                       return false
-               end
-               return true
-       end,
-})
-
-electric_furnace_formspec =
-       "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;2,2;]"..
-       "list[current_player;main;0,5;8,4;]"..
-       "label[0,0;Electric Furnace]"..
-       "label[1,3;Power level]"
-       
-minetest.register_node("technic:electric_furnace", {
-       description = "Electric furnace",
-       tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
-               "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front.png"},
-       paramtype2 = "facedir",
-       groups = {cracky=2},
-       legacy_facedir_simple = true,
-       sounds = default.node_sound_stone_defaults(),
-       technic_power_machine=1,
-       internal_EU_buffer=0;
-       interal_EU_buffer_size=2000;
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_float("technic_power_machine", 1)
-               meta:set_string("formspec", electric_furnace_formspec)
-               meta:set_string("infotext", "Electric furnace")
-               local inv = meta:get_inventory()
-               inv:set_size("src", 1)
-               inv:set_size("dst", 4)
-               local EU_used  = 0
-               local furnace_is_cookin = 0
-               local cooked = nil
-               meta:set_float("internal_EU_buffer",0)
-               meta:set_float("internal_EU_buffer_size",2000)
-
-       end,
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               if not inv:is_empty("dst") then
-                       return false
-               elseif not inv:is_empty("src") then
-                       return false
-               end
-               return true
-       end,
-})
-
-minetest.register_node("technic:electric_furnace_active", {
-       description = "Electric Furnace",
-       tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
-               "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front_active.png"},
-       paramtype2 = "facedir",
-       light_source = 8,
-       drop = "technic:electric_furnace",
-       groups = {cracky=2, not_in_creative_inventory=1},
-       legacy_facedir_simple = true,
-       sounds = default.node_sound_stone_defaults(),
-       internal_EU_buffer=0;
-       interal_EU_buffer_size=2000;
-       technic_power_machine=1,
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_float("technic_power_machine", 1)
-               meta:set_string("formspec", electric_furnace_formspec)
-               meta:set_string("infotext", "Electric furnace");
-               local inv = meta:get_inventory()
-               inv:set_size("src", 1)
-               inv:set_size("dst", 4)
-               local EU_used  = 0
-               local furnace_is_cookin = 0
-               local cooked = nil
-       end,
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               if not inv:is_empty("dst") then
-                       return false
-               elseif not inv:is_empty("src") then
-                       return false
-               end
-               return true
-       end,
-})
-
-minetest.register_abm({
-       nodenames = {"technic:electric_furnace","technic:electric_furnace_active"},
-       interval = 1,
-       chance = 1,
-       
-       action = function(pos, node, active_object_count, active_object_count_wider)
-
-               local meta = minetest.env:get_meta(pos)
-               internal_EU_buffer=meta:get_float("internal_EU_buffer")
-               internal_EU_buffer_size=meta:get_float("internal_EU_buffer")
-               local load = math.floor(internal_EU_buffer/2000 * 100)
-               meta:set_string("formspec",
-                               "invsize[8,9;]"..
-                               "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
-                                               (load)..":technic_power_meter_fg.png]"..
-                               "list[current_name;src;3,1;1,1;]"..
-                               "list[current_name;dst;5,1;2,2;]"..
-                               "list[current_player;main;0,5;8,4;]"..
-                               "label[0,0;Electric Furnace]"..
-                               "label[1,3;Power level]")
-
-               local inv = meta:get_inventory()
-               
-               local furnace_is_cookin = meta:get_float("furnace_is_cookin")
-               
-               
-               local srclist = inv:get_list("src")
-               local cooked=nil 
-
-               if srclist then
-                cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
-               end
-               
-               
-               if (furnace_is_cookin == 1) then
-                       if internal_EU_buffer>=150 then
-                       internal_EU_buffer=internal_EU_buffer-150;
-                       meta:set_float("internal_EU_buffer",internal_EU_buffer)
-                       meta:set_float("src_time", meta:get_float("src_time") + 3)
-                       if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
-                               -- check if there's room for output in "dst" list
-                               if inv:room_for_item("dst",cooked.item) then
-                                       -- Put result in "dst" list
-                                       inv:add_item("dst", cooked.item)
-                                       -- take stuff from "src" list
-                                       srcstack = inv:get_stack("src", 1)
-                                       srcstack:take_item()
-                                       inv:set_stack("src", 1, srcstack)
-                               else
-                                       print("Furnace inventory full!")
-                               end
-                               meta:set_string("src_time", 0)
-                       end
-                       end             
-               end
-               
-               
-
-               
-               if srclist then
-                       cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
-                       if cooked.time>0 then 
-                       hacky_swap_node(pos,"technic:electric_furnace_active")
-                       meta:set_string("infotext","Furnace active")
-                       meta:set_string("furnace_is_cookin",1)
-               --      meta:set_string("formspec", electric_furnace_formspec)
-                       meta:set_string("src_time", 0)
-                       return
-                       end
-
-               end
-       
-                               hacky_swap_node(pos,"technic:electric_furnace")
-                               meta:set_string("infotext","Furnace inactive")
-                               meta:set_string("furnace_is_cookin",0)
-               --              meta:set_string("formspec", electric_furnace_formspec)
-                               meta:set_string("src_time", 0)
-               
-       
-end,           
-})
diff --git a/technic/electric_furnace.lua b/technic/electric_furnace.lua
deleted file mode 100644 (file)
index 0c1f43e..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
--- LV Electric Furnace
--- This is a faster version of the stone furnace which runs on EUs
-
--- FIXME: kpoppel I'd like to introduce an induction heating element here also
-minetest.register_craft(
-   {output = 'technic:electric_furnace',
-    recipe = {
-       {'default:cobble',      'default:cobble',        'default:cobble'},
-       {'default:cobble',      '',                      'default:cobble'},
-       {'default:steel_ingot', 'moreores:copper_ingot', 'default:steel_ingot'},
-    }
- })
-
-local electric_furnace_formspec =
-   "invsize[8,9;]"..
-   "list[current_name;src;3,1;1,1;]"..
-   "list[current_name;dst;5,1;2,2;]"..
-   "list[current_player;main;0,5;8,4;]"..
-   "label[0,0;Electric Furnace]"..
-   "label[1,3;Power level]"
-
-minetest.register_node(
-   "technic:electric_furnace",
-   {description = "Electric furnace",
-    tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
-            "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front.png"},
-    paramtype2 = "facedir",
-    groups = {cracky=2},
-    legacy_facedir_simple = true,
-    sounds = default.node_sound_stone_defaults(),
-    on_construct = function(pos)
-                     local meta = minetest.env:get_meta(pos)
-                     meta:set_string("infotext", "Electric Furnace")
-                     meta:set_float("technic_power_machine", 1)
-                     meta:set_string("formspec", electric_furnace_formspec)
-                     local inv = meta:get_inventory()
-                     inv:set_size("src", 1)
-                     inv:set_size("dst", 4)
-                  end,
-    can_dig = function(pos,player)
-                local meta = minetest.env:get_meta(pos);
-                local inv = meta:get_inventory()
-                if not inv:is_empty("src") or not inv:is_empty("dst") then
-                   minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                   return false
-                else
-                   return true
-                end
-             end,
- })
-
-minetest.register_node(
-   "technic:electric_furnace_active",
-   {description = "Electric Furnace",
-    tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
-            "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front_active.png"},
-    paramtype2 = "facedir",
-    light_source = 8,
-    drop = "technic:electric_furnace",
-    groups = {cracky=2, not_in_creative_inventory=1},
-    legacy_facedir_simple = true,
-    sounds = default.node_sound_stone_defaults(),
-    can_dig = function(pos,player)
-                local meta = minetest.env:get_meta(pos);
-                local inv = meta:get_inventory()
-                if not inv:is_empty("src") or not inv:is_empty("dst") then
-                   minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                   return false
-                else
-                   return true
-                end
-             end,
- })
-
-minetest.register_abm(
-   { nodenames = {"technic:electric_furnace","technic:electric_furnace_active"},
-     interval = 1,
-     chance   = 1,
-     action = function(pos, node, active_object_count, active_object_count_wider)
-                local meta         = minetest.env:get_meta(pos)
-                local eu_input     = meta:get_int("LV_EU_input")
-                local state        = meta:get_int("state")
-                local next_state   = state
-
-                -- Machine information
-                local machine_name         = "Electric furnace"
-                local machine_node         = "technic:electric_furnace"
-                local machine_state_demand = { 50, 1000 }
-                        
-                -- Setup meta data if it does not exist. state is used as an indicator of this
-                if state == 0 then
-                   meta:set_int("state", 1)
-                   meta:set_int("LV_EU_demand", machine_state_demand[1])
-                   meta:set_int("LV_EU_input", 0)
-                   return
-                end
-                        
-                -- Power off automatically if no longer connected to a switching station
-                technic.switching_station_timeout_count(pos, "LV")
-                        
-                -- State machine
-                if eu_input == 0 then
-                   -- Unpowered - go idle
-                   hacky_swap_node(pos, machine_node)
-                   meta:set_string("infotext", machine_name.." Unpowered")
-                   next_state = 1
-                elseif eu_input == machine_state_demand[state] then
-                   -- Powered - do the state specific actions
-                           
-                   -- Execute always if powered logic
-                   local inv    = meta:get_inventory()
-                   local empty  = inv:is_empty("src")
-
-                   if state == 1 then
-                      hacky_swap_node(pos, machine_node)
-                      meta:set_string("infotext", machine_name.." Idle")
-
-                      local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
-                      if not empty and result and inv:room_for_item("dst",result) then
-                         next_state = 2
-                      end
-
-                   elseif state == 2 then
-                      hacky_swap_node(pos, machine_node.."_active")
-                      meta:set_string("infotext", machine_name.." Active")
-
-                      if empty then
-                         next_state = 1
-                      else
-                         meta:set_int("src_time", meta:get_int("src_time") + 3) -- Cooking time 3x
-                         local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
-                         if result and result.item and meta:get_int("src_time") >= result.time then
-                            -- check if there's room for output in "dst" list
-                            meta:set_int("src_time", 0)
-                            if inv:room_for_item("dst",result.item) then
-                               -- take stuff from "src" list
-                               srcstack = inv:get_stack("src", 1)
-                               srcstack:take_item()
-                               inv:set_stack("src", 1, srcstack)
-                               -- Put result in "dst" list
-                               inv:add_item("dst", result.item)
-                            else
-                               -- all full: go idle
-                               next_state = 1
-                            end
-                         end
-                      end
-                   end
-                end
-                -- Change state?
-                if next_state ~= state then
-                   meta:set_int("LV_EU_demand", machine_state_demand[next_state])
-                   meta:set_int("state", next_state)
-                end
-             end,
-  })
-
-technic.register_LV_machine ("technic:electric_furnace","RE")
-technic.register_LV_machine ("technic:electric_furnace_active","RE")
-
diff --git a/technic/electric_furnace_mv.lua b/technic/electric_furnace_mv.lua
deleted file mode 100644 (file)
index 7f205b5..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
--- MV Electric Furnace
--- This is a faster version of the stone furnace which runs on EUs
--- In addition to this it can be upgraded with microcontrollers and batteries
--- This new version uses the batteries to lower the power consumption of the machine
--- Also in addition this furnace can be attached to the pipe system from the pipeworks mod.
-
--- FIXME: kpoppel I'd like to introduce an induction heating element here also
-minetest.register_craft(
-   {output = 'technic:mv_electric_furnace',
-    recipe = {
-       {'technic:stainless_steel_ingot', 'technic:electric_furnace', 'technic:stainless_steel_ingot'},
-       {'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
-       {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
-    }
- })
-
-local mv_electric_furnace_formspec =
-   "invsize[8,10;]"..
-   "list[current_name;src;3,1;1,1;]"..
-   "list[current_name;dst;5,1;2,2;]"..
-   "list[current_player;main;0,6;8,4;]"..
-   "label[0,0;MV Electric Furnace]"..
-   "list[current_name;upgrade1;1,4;1,1;]"..
-   "list[current_name;upgrade2;2,4;1,1;]"..
-   "label[1,5;Upgrade Slots]"
-
-minetest.register_node(
-   "technic:mv_electric_furnace",
-   {description = "MV Electric furnace",
-    tiles = {"technic_mv_electric_furnace_top.png", "technic_mv_electric_furnace_bottom.png", "technic_mv_electric_furnace_side_tube.png",
-            "technic_mv_electric_furnace_side_tube.png", "technic_mv_electric_furnace_side.png", "technic_mv_electric_furnace_front.png"},
-    paramtype2 = "facedir",
-    groups = {cracky=2, tubedevice=1,tubedevice_receiver=1,},
-    tube={insert_object=function(pos,node,stack,direction)
-                          local meta=minetest.env:get_meta(pos)
-                          local inv=meta:get_inventory()
-                          return inv:add_item("src",stack)
-                       end,
-         can_insert=function(pos,node,stack,direction)
-                       local meta=minetest.env:get_meta(pos)
-                       local inv=meta:get_inventory()
-                       return inv:room_for_item("src",stack)
-                    end,
-       },
-    legacy_facedir_simple = true,
-    sounds = default.node_sound_stone_defaults(),
-    on_construct = function(pos)
-                     local meta = minetest.env:get_meta(pos)
-                     meta:set_string("infotext", "MV Electric furnace")
-                     meta:set_float("technic_mv_power_machine", 1)
-                     meta:set_int("tube_time",  0)
-                     meta:set_string("formspec", mv_electric_furnace_formspec)
-                     local inv = meta:get_inventory()
-                     inv:set_size("src", 1)
-                     inv:set_size("dst", 4)
-                     inv:set_size("upgrade1", 1)
-                     inv:set_size("upgrade2", 1)
-                  end,
-    can_dig = function(pos,player)
-                local meta = minetest.env:get_meta(pos);
-                local inv = meta:get_inventory()
-                if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
-                   minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                   return false
-                else
-                   return true
-                end
-             end,
- })
-
-minetest.register_node(
-   "technic:mv_electric_furnace_active",
-   {description = "MV Electric Furnace",
-    tiles = {"technic_mv_electric_furnace_top.png", "technic_mv_electric_furnace_bottom.png", "technic_mv_electric_furnace_side_tube.png",
-            "technic_mv_electric_furnace_side_tube.png", "technic_mv_electric_furnace_side.png", "technic_mv_electric_furnace_front_active.png"},
-    paramtype2 = "facedir",
-    light_source = 8,
-    drop = "technic:mv_electric_furnace",
-    groups = {cracky=2, tubedevice=1,tubedevice_receiver=1,not_in_creative_inventory=1},
-    tube={insert_object=function(pos,node,stack,direction)
-                          local meta=minetest.env:get_meta(pos)
-                          local inv=meta:get_inventory()
-                          return inv:add_item("src",stack)
-                       end,
-         can_insert=function(pos,node,stack,direction)
-                       local meta=minetest.env:get_meta(pos)
-                       local inv=meta:get_inventory()
-                       return inv:room_for_item("src",stack)
-                    end,
-       },
-    legacy_facedir_simple = true,
-    sounds = default.node_sound_stone_defaults(),
-    can_dig = function(pos,player)
-                local meta = minetest.env:get_meta(pos);
-                local inv = meta:get_inventory()
-                if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
-                   minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                   return false
-                else
-                   return true
-                end
-             end,
-    -- These three makes sure upgrades are not moved in or out while the furnace is active.
-    allow_metadata_inventory_put = function(pos, listname, index, stack, player)
-                                      if listname == "src" or listname == "dst" then
-                                         return 99
-                                      else
-                                         return 0 -- Disallow the move
-                                      end
-                                  end,
-    allow_metadata_inventory_take = function(pos, listname, index, stack, player)
-                                      if listname == "src" or listname == "dst" then
-                                         return 99
-                                      else
-                                         return 0 -- Disallow the move
-                                      end
-                                   end,
-    allow_metadata_inventory_move = function(pos, from_list, to_list, to_list, to_index, count, player)
-                                   return 0
-                                end,
- })
-
-local send_cooked_items = function(pos,x_velocity,z_velocity)
-                            -- Send items on their way in the pipe system.
-                            local meta=minetest.env:get_meta(pos) 
-                            local inv = meta:get_inventory()
-                            local i=0
-                            for _,stack in ipairs(inv:get_list("dst")) do
-                               i=i+1
-                               if stack then
-                                  local item0=stack:to_table()
-                               if item0 then 
-                                  item0["count"]="1"
-                                  local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
-                                  item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
-                                  item1:setvelocity({x=x_velocity, y=0, z=z_velocity})
-                                  item1:setacceleration({x=0, y=0, z=0})
-                                  stack:take_item(1);
-                                  inv:set_stack("dst", i, stack)
-                                  return
-                               end
-                            end
-                         end
-                      end
-
-local smelt_item = function(pos)
-                     local meta=minetest.env:get_meta(pos) 
-                     local inv = meta:get_inventory()
-                     meta:set_int("src_time", meta:get_int("src_time") + 3) -- Cooking time 3x faster
-                     local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
-                     if result and result.item and meta:get_int("src_time") >= result.time then
-                        meta:set_int("src_time", 0)
-                        -- check if there's room for output in "dst" list
-                        if inv:room_for_item("dst",result) then
-                           -- take stuff from "src" list
-                           srcstack = inv:get_stack("src", 1)
-                           srcstack:take_item()
-                           inv:set_stack("src", 1, srcstack)
-                           -- Put result in "dst" list
-                           inv:add_item("dst", result.item)
-                           return 1
-                        else
-                           return 0 -- done
-                        end
-                     end
-                     return 0 -- done
-                  end
-
-minetest.register_abm(
-   {nodenames = {"technic:mv_electric_furnace","technic:mv_electric_furnace_active"},
-    interval = 1,
-    chance   = 1,
-    action = function(pos, node, active_object_count, active_object_count_wider)
-               local meta         = minetest.env:get_meta(pos)
-               local eu_input     = meta:get_int("MV_EU_input")
-               local state        = meta:get_int("state")
-               local next_state   = state
-
-               -- Machine information
-               local machine_name         = "MV Electric Furnace"
-               local machine_node         = "technic:mv_electric_furnace"
-               local machine_state_demand = { 50, 2000, 1500, 1000 }
-                        
-               -- Setup meta data if it does not exist. state is used as an indicator of this
-               if state == 0 then
-                  meta:set_int("state", 1)
-                  meta:set_int("MV_EU_demand", machine_state_demand[1])
-                  meta:set_int("MV_EU_input", 0)
-                  return
-               end
-                        
-               -- Power off automatically if no longer connected to a switching station
-               technic.switching_station_timeout_count(pos, "MV")
-               
-               -- Execute always logic
-               -- CODE HERE --
-               
-               -- State machine
-               if eu_input == 0 then
-                  -- Unpowered - go idle
-                  hacky_swap_node(pos, machine_node)
-                  meta:set_string("infotext", machine_name.." Unpowered")
-                  next_state = 1
-               elseif eu_input == machine_state_demand[state] then
-                  -- Powered - do the state specific actions
-                           
-                  -- Execute always if powered logic
-                  local meta=minetest.env:get_meta(pos) 
-                         
-                  -- Get the names of the upgrades
-                  local meta=minetest.env:get_meta(pos) 
-                  local inv = meta:get_inventory()
-                  local upg_item1
-                  local upg_item1_name=""
-                  local upg_item2
-                  local upg_item2_name=""
-                  local srcstack = inv:get_stack("upgrade1", 1)
-                  if  srcstack then upg_item1=srcstack:to_table() end
-                  srcstack = inv:get_stack("upgrade2", 1)
-                  if  srcstack then upg_item2=srcstack:to_table() end
-                  if upg_item1 then upg_item1_name=upg_item1.name end
-                  if upg_item2 then upg_item2_name=upg_item2.name end
-                  
-                  -- Save some power by installing battery upgrades. Fully upgraded makes this
-                  -- furnace use the same amount of power as the LV version
-                  local EU_saving_upgrade = 0
-                  if upg_item1_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
-                  if upg_item2_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
-                  
-                  -- Tube loading speed can be upgraded using control logic units
-                  local tube_speed_upgrade = 0
-                  if upg_item1_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
-                  if upg_item2_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
-                  
-                  -- Handle pipeworks (consumes tube_speed_upgrade)
-                  local pos1={x=pos.x, y=pos.y, z=pos.z}
-                  local x_velocity=0
-                  local z_velocity=0
-                  
-                  -- Output is on the left side of the furnace
-                  if node.param2==3 then pos1.z=pos1.z-1 z_velocity =-1 end
-                  if node.param2==2 then pos1.x=pos1.x-1 x_velocity =-1 end
-                  if node.param2==1 then pos1.z=pos1.z+1 z_velocity = 1 end
-                  if node.param2==0 then pos1.x=pos1.x+1 x_velocity = 1 end
-                  
-                  local output_tube_connected = false
-                  local meta1 = minetest.env:get_meta(pos1) 
-                  if meta1:get_int("tubelike") == 1 then
-                     output_tube_connected=true
-                  end
-                  tube_time = meta:get_int("tube_time")
-                  tube_time = tube_time + tube_speed_upgrade
-                  if tube_time > 3 then
-                     tube_time = 0
-                     if output_tube_connected then
-                        send_cooked_items(pos,x_velocity,z_velocity)
-                     end
-                  end
-                  meta:set_int("tube_time", tube_time)
-                  
-                  -- The machine shuts down if we have nothing to smelt and no tube is connected
-                  -- or if we have nothing to send with a tube connected.
-                  if    (not output_tube_connected and inv:is_empty("src"))
-                  or (    output_tube_connected and inv:is_empty("dst")) then
-                  next_state = 1
-               end
-               ----------------------
-               
-               if state == 1 then
-                  hacky_swap_node(pos, machine_node)
-                  meta:set_string("infotext", machine_name.." Idle")
-                  
-                  local meta=minetest.env:get_meta(pos) 
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") then
-                     local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
-                     if result then
-                        meta:set_string("infotext", machine_name.." Active")
-                        meta:set_int("src_time",     0)
-                        next_state = 2+EU_saving_upgrade -- Next state is decided by the battery upgrade (state 2= 0 batteries, state 3 = 1 battery, 4 = 2 batteries)
-                     end
-                  else
-                     meta:set_string("infotext", "Electric Furnace Idle")
-                  end
-                  
-               elseif state == 2 or state == 3 or state == 4 then
-                  hacky_swap_node(pos, machine_node.."_active")
-                  meta:set_string("infotext", machine_name.." Active")
-                  result = smelt_item(pos, data)
-                  if result == 0 then
-                     next_state = 1
-                  end
-               end
-            end
-            -- Change state?
-            if next_state ~= state then
-               meta:set_int("MV_EU_demand", machine_state_demand[next_state])
-               meta:set_int("state", next_state)
-            end
-         end,
- })
-
-technic.register_MV_machine ("technic:mv_electric_furnace","RE")
-technic.register_MV_machine ("technic:mv_electric_furnace_active","RE")
diff --git a/technic/extractor.lua b/technic/extractor.lua
deleted file mode 100644 (file)
index d4fe1cc..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-technic.extractor_recipes ={}
-
-technic.register_extractor_recipe = function(src, src_count, dst, dst_count)
-                                  technic.extractor_recipes[src] = {src_count = src_count, dst_name = dst, dst_count = dst_count}
-                                  if unified_inventory then
-                                     unified_inventory.register_craft(
-                                        {
-                                           type = "extracting",
-                                           output = dst.." "..dst_count,
-                                           items = {src.." "..src_count},
-                                           width = 0,
-                                        })
-                                  end
-                               end
-
--- Receive an ItemStack of result by an ItemStack input
-technic.get_extractor_recipe = function(item)
-                               if technic.extractor_recipes[item.name]
-                                  and item.count >= technic.extractor_recipes[item.name].src_count then
-                                  return technic.extractor_recipes[item.name]
-                               else
-                                  return nil
-                               end
-                            end
-
-
-
-technic.register_extractor_recipe("technic:coal_dust", 1, "dye:black", 2)
-technic.register_extractor_recipe("default:cactus", 1, "dye:green", 2)
-technic.register_extractor_recipe("default:dry_shrub", 1, "dye:brown", 2)
-technic.register_extractor_recipe("flowers:geranium", 1, "dye:blue", 2)
-technic.register_extractor_recipe("flowers:dandelion_white", 1, "dye:white", 2)
-technic.register_extractor_recipe("flowers:dandelion_yellow", 1, "dye:yellow", 2)
-technic.register_extractor_recipe("flowers:tulip", 1, "dye:orange", 2)
-technic.register_extractor_recipe("flowers:rose", 1, "dye:red", 2)
-technic.register_extractor_recipe("flowers:viola", 1, "dye:violet", 2)
-technic.register_extractor_recipe("technic:raw_latex", 1, "technic:rubber", 3)
-technic.register_extractor_recipe("moretrees:rubber_tree_trunk_empty", 1, "technic:rubber", 1)
-technic.register_extractor_recipe("moretrees:rubber_tree_trunk", 1, "technic:rubber", 1)
-technic.register_extractor_recipe("technic:uranium", 5, "technic:enriched_uranium", 1)
-
-minetest.register_alias("extractor", "technic:extractor")
-minetest.register_craft({
-                          output = 'technic:extractor',
-                          recipe = {
-                             {'technic:treetap', 'technic:motor', 'technic:treetap'},
-                             {'technic:treetap', 'technic:lv_cable', 'technic:treetap'},
-                             {'','',''},
-                          }
-                       })
-
-minetest.register_craftitem("technic:extractor", {
-                              description = "Extractor",
-                              stack_max = 99,
-                           })
-
-local extractor_formspec =
-   "invsize[8,9;]"..
-   "label[0,0;Extractor]"..
-   "list[current_name;src;3,1;1,1;]"..
-   "list[current_name;dst;5,1;2,2;]"..
-   "list[current_player;main;0,5;8,4;]"
-
-minetest.register_node(
-   "technic:extractor",
-   {
-      description = "Extractor",
-      tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
-              "technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
-      paramtype2 = "facedir",
-      groups = {cracky=2},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_wood_defaults(),
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       meta:set_string("infotext", "Extractor")
-                       meta:set_float("technic_power_machine", 1)
-                       meta:set_string("formspec", extractor_formspec)
-                       local inv = meta:get_inventory()
-                       inv:set_size("src", 1)
-                       inv:set_size("dst", 4)
-                    end,
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") or not inv:is_empty("dst") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  else
-                     return true
-                  end
-               end,
-   })
-
-minetest.register_node(
-   "technic:extractor_active",
-   {
-      description = "Extractor",
-      tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
-              "technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front_active.png"},
-      paramtype2 = "facedir",
-      groups = {cracky=2,not_in_creative_inventory=1},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_wood_defaults(),
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") or not inv:is_empty("dst") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  else
-                     return true
-                  end
-               end,
-   })
-
-minetest.register_abm(
-   { nodenames = {"technic:extractor","technic:extractor_active"},
-     interval = 1,
-     chance   = 1,
-     action = function(pos, node, active_object_count, active_object_count_wider)
-                -- Run a machine through its states. Takes the same arguments as the ABM action
-                -- and adds the machine's states and any extra data which is needed by the machine.
-                -- A machine is characterized by running through a set number of states (usually 2:
-                -- Idle and active) in some order. A state decides when to move to the next one
-                -- and the machine only changes state if it is powered correctly.
-                -- The machine will automatically shut down if disconnected from power in some fashion.
-                local meta         = minetest.env:get_meta(pos)
-                local eu_input     = meta:get_int("LV_EU_input")
-                local state        = meta:get_int("state")
-                local next_state   = state
-
-                -- Machine information
-                local machine_name         = "Extractor"
-                local machine_node         = "technic:extractor"
-                local machine_state_demand = { 50, 300 }
-                        
-                -- Setup meta data if it does not exist. state is used as an indicator of this
-                if state == 0 then
-                   meta:set_int("state", 1)
-                   meta:set_int("LV_EU_demand", machine_state_demand[1])
-                   meta:set_int("LV_EU_input", 0)
-                   return
-                end
-                        
-                -- Power off automatically if no longer connected to a switching station
-                technic.switching_station_timeout_count(pos, "LV")
-                        
-                -- State machine
-                if eu_input == 0 then
-                   -- unpowered - go idle
-                   hacky_swap_node(pos, machine_node)
-                   meta:set_string("infotext", machine_name.." Unpowered")
-                   next_state = 1
-                elseif eu_input == machine_state_demand[state] then
-                   -- Powered - do the state specific actions
-                           
-                   local inv    = meta:get_inventory()
-                   local empty  = inv:is_empty("src")
-                   local srcstack  = inv:get_stack("src", 1)
-                   local src_item = nil
-                   local recipe = nil
-                   local result = nil
-                   
-                   if srcstack then
-                      src_item = srcstack:to_table()
-                   end
-                   if src_item then
-                      recipe = technic.get_extractor_recipe(src_item)
-                   end
-                   if recipe then
-                      result = {name=recipe.dst_name, count=recipe.dst_count}
-                   end 
-                   
-                   if state == 1 then
-                      hacky_swap_node(pos, machine_node)
-                      meta:set_string("infotext", machine_name.." Idle")
-
-                      if not empty and result and inv:room_for_item("dst",result) then
-                         meta:set_int("src_time", 0)
-                         next_state = 2
-                      end
-
-                   elseif state == 2 then
-                      hacky_swap_node(pos, machine_node.."_active")
-                      meta:set_string("infotext", machine_name.." Active")
-
-                      if empty then
-                         next_state = 1
-                      else
-                         meta:set_int("src_time", meta:get_int("src_time") + 1)
-                         if meta:get_int("src_time") == 4 then -- 4 ticks per output
-                            -- check if there's room for output in "dst" list
-
-                            meta:set_int("src_time", 0)
-                            if recipe and inv:room_for_item("dst",result) then
-                               -- take stuff from "src" list
-                               srcstack:take_item(recipe.src_count)
-                               inv:set_stack("src", 1, srcstack)
-                               -- Put result in "dst" list
-                               inv:add_item("dst", result)
-                            else
-                               -- all full: go idle
-                               next_state = 1
-                            end
-                         end
-                      end
-                   end
-                end
-                -- Change state?
-                if next_state ~= state then
-                   meta:set_int("LV_EU_demand", machine_state_demand[next_state])
-                   meta:set_int("state", next_state)
-                end
-             end
-  })
-
-technic.register_LV_machine ("technic:extractor","RE")
-technic.register_LV_machine ("technic:extractor_active","RE")
-
diff --git a/technic/flashlight.lua b/technic/flashlight.lua
deleted file mode 100644 (file)
index 5f3ea96..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
--- 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)
-      
-minetest.register_tool("technic:flashlight", {
-       description = "Flashlight",
-       inventory_image = "technic_flashlight.png",
-       stack_max = 1,
-       on_use = function(itemstack, user, pointed_thing)
-       end,
-       })
-minetest.register_craft({
-output = "technic:flashlight",
-recipe = {
-       {"technic:rubber","glass","technic:rubber"},
-       {"technic:stainless_steel_ingot","technic:battery","technic:stainless_steel_ingot"},
-       {"","technic:battery",""}
-       }
-})
-
-local players = {}
-local player_positions = {}
-local last_wielded = {}
-
-function round(num) 
-       return math.floor(num + 0.5) 
-end
-
-minetest.register_on_joinplayer(function(player)
-       local player_name = player:get_player_name()
-       table.insert(players, player_name)
-       local pos = player:getpos()
-       local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
-       player_positions[player_name] = {}
-       player_positions[player_name]["x"] = rounded_pos.x;
-       player_positions[player_name]["y"] = rounded_pos.y;
-       player_positions[player_name]["z"] = rounded_pos.z;
-end)
-
-minetest.register_on_leaveplayer(function(player)
-       local player_name = player:get_player_name()
-       for i,v in ipairs(players) do
-               if v == player_name then 
-                       table.remove(players, i)
-                       last_wielded[player_name] = nil
-                       -- Neuberechnung des Lichts erzwingen
-                       local pos = player:getpos()
-                       local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
-                       minetest.env:add_node(rounded_pos,{type="node",name="technic:light_off"})
-                       minetest.env:add_node(rounded_pos,{type="node",name="air"})
-                       player_positions[player_name]["x"] = nil
-                       player_positions[player_name]["y"] = nil
-                       player_positions[player_name]["z"] = nil
-                       player_positions[player_name]["m"] = nil
-                       player_positions[player_name] = nil
-               end
-       end
-end)
-
-minetest.register_globalstep(function(dtime)
-       for i,player_name in ipairs(players) do
-               local player = minetest.env:get_player_by_name(player_name)
-               if player then
-               flashlight_weared=check_for_flashlight(player)
-               local pos = player:getpos()
-               local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
-               local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]}
-               
-               if last_wielded[player_name] and not flashlight_weared then --remove light, flashlight weared out or was removed from hotbar
-                       local node=minetest.env:get_node_or_nil(old_pos)
-                       if node then
-                       if node.name=="technic:light" then 
-                               minetest.env:add_node(old_pos,{type="node",name="technic:light_off"})
-                               minetest.env:add_node(old_pos,{type="node",name="air"})         
-                         last_wielded[player_name]=false
-                         end
-                       end
-                       end
-
-               player_moved=not(old_pos.x==rounded_pos.x and old_pos.y==rounded_pos.y and old_pos.z==rounded_pos.z)
-               if player_moved and last_wielded[player_name] and flashlight_weared  then
-                       
-                       local node=minetest.env:get_node_or_nil(rounded_pos)
-                       if node then
-                       if node.name=="air" then 
-                               minetest.env:add_node(rounded_pos,{type="node",name="technic:light"})
-                         end
-                       end
-                       local node=minetest.env:get_node_or_nil(old_pos)
-                       if node then
-                         if node.name=="technic:light" then 
-                               minetest.env:add_node(old_pos,{type="node",name="technic:light_off"})
-                               minetest.env:add_node(old_pos,{type="node",name="air"})         
-                         end
-                       end
-                       player_positions[player_name]["x"] = rounded_pos.x
-                       player_positions[player_name]["y"] = rounded_pos.y
-                       player_positions[player_name]["z"] = rounded_pos.z
-                       
-               else if not last_wielded[player_name] and flashlight_weared then
-                       local node=minetest.env:get_node_or_nil(rounded_pos)
-                       if node then
-                       if node.name=="air" then 
-                               minetest.env:add_node(rounded_pos,{type="node",name="technic:light"})
-                         end
-                       end
-                       player_positions[player_name]["x"] = rounded_pos.x
-                       player_positions[player_name]["y"] = rounded_pos.y
-                       player_positions[player_name]["z"] = rounded_pos.z
-                       last_wielded[player_name]=true
-                       end                     
-                       
-       end
-       end
-       end
-end)
-
-minetest.register_node("technic:light", {
-       drawtype = "glasslike",
-       tile_images = {"technic_light.png"},
-       paramtype = "light",
-       walkable = false,
-       buildable_to = true,
-       is_ground_content = true,
-       light_propagates = true,
-       sunlight_propagates = true,
-       light_source = 15,
-       selection_box = {
-        type = "fixed",
-        fixed = {0, 0, 0, 0, 0, 0},
-    },
-})
-minetest.register_node("technic:light_off", {
-       drawtype = "glasslike",
-       tile_images = {"technic_light.png"},
-       paramtype = "light",
-       walkable = false,
-       buildable_to = true,
-       is_ground_content = true,
-       light_propagates = true,
-       sunlight_propagates = true,
-       selection_box = {
-        type = "fixed",
-        fixed = {0, 0, 0, 0, 0, 0},
-    },
-})
-
-function check_for_flashlight (player)
-if player==nil then return false end
-local inv = player:get_inventory()
-local hotbar=inv:get_list("main")
-               for i=1,8,1 do
-                       
-                       if hotbar[i]:get_name() == "technic:flashlight" then
-                       local item=hotbar[i]:to_table()
-                       local meta=get_item_meta(item["metadata"])
-                       if meta==nil then return false end --flashlight not charghed
-                       if meta["charge"]==nil then return false end
-                       charge=meta["charge"]
-                       if charge-2>0 then
-                        charge =charge-2;      
-                       technic.set_RE_wear(item,charge,flashlight_max_charge)
-                       meta["charge"]=charge
-                       item["metadata"]=set_item_meta(meta)
-                       hotbar[i]:replace(item)
-                       inv:set_stack("main",i,hotbar[i])
-                       return true
-                       end
-                       end
-               end
-return false
-end    
diff --git a/technic/flashlight_old.lua b/technic/flashlight_old.lua
deleted file mode 100644 (file)
index 8a2c338..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
--- original code comes from walkin_light mod by Echo http://minetest.net/forum/viewtopic.php?id=2621
-
-flashlight_max_charge=30000
-      
-       minetest.register_tool("technic:flashlight", {
-            description = "Flashlight",
-            inventory_image = "technic_flashlight.png",
-       stack_max = 1,
-            on_use = function(itemstack, user, pointed_thing)
-       end,            
-    })
-     
-    minetest.register_craft({
-            output = "technic:flashlight",
-            recipe = {
-                   {"glass","glass","glass"},
-                    {"technic:stainless_steel_ingot","technic:battery","technic:stainless_steel_ingot"},
-                    {"","technic:battery",""}
-            }
-    })
-local players = {}
-local player_positions = {}
-local last_wielded = {}
-
-function round(num) 
-       return math.floor(num + 0.5) 
-end
-
-minetest.register_on_joinplayer(function(player)
-       local player_name = player:get_player_name()
-       table.insert(players, player_name)
-       last_wielded[player_name] = flashlight_weared(player)
-       local pos = player:getpos()
-       local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
-       local wielded_item = player:get_wielded_item():get_name()
-       if flashlight_weared(player)==true then
-               -- Neuberechnung des Lichts erzwingen
-               minetest.env:add_node(rounded_pos,{type="node",name="technic:light_off"})
-               minetest.env:add_node(rounded_pos,{type="node",name="air"})
-       end
-       player_positions[player_name] = {}
-       player_positions[player_name]["x"] = rounded_pos.x;
-       player_positions[player_name]["y"] = rounded_pos.y;
-       player_positions[player_name]["z"] = rounded_pos.z;
-end)
-
-minetest.register_on_leaveplayer(function(player)
-       local player_name = player:get_player_name()
-       for i,v in ipairs(players) do
-               if v == player_name then 
-                       table.remove(players, i)
-                       last_wielded[player_name] = nil
-                       -- Neuberechnung des Lichts erzwingen
-                       local pos = player:getpos()
-                       local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
-                       minetest.env:add_node(rounded_pos,{type="node",name="technic:light_off"})
-                       minetest.env:add_node(rounded_pos,{type="node",name="air"})
-                       player_positions[player_name]["x"] = nil
-                       player_positions[player_name]["y"] = nil
-                       player_positions[player_name]["z"] = nil
-                       player_positions[player_name]["m"] = nil
-                       player_positions[player_name] = nil
-               end
-       end
-end)
-
-minetest.register_globalstep(function(dtime)
-       for i,player_name in ipairs(players) do
-               local player = minetest.env:get_player_by_name(player_name)
-               if flashlight_weared(player)==true then
-                       -- Fackel ist in der Hand
-                       local pos = player:getpos()
-                       local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
-                       if (last_wielded[player_name] ~= true) or (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then
-                               -- Fackel gerade in die Hand genommen oder zu neuem Node bewegt
-                               local is_air  = minetest.env:get_node_or_nil(rounded_pos)
-                               if is_air == nil or (is_air ~= nil and (is_air.name == "air" or is_air.name == "technic:light")) then
-                                       -- wenn an aktueller Position "air" ist, Fackellicht setzen
-                                       minetest.env:add_node(rounded_pos,{type="node",name="technic:light"})
-                               end
-                               if (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then
-                                       -- wenn Position geänder, dann altes Licht löschen
-                                       local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]}
-                                       -- Neuberechnung des Lichts erzwingen
-                                       local is_light = minetest.env:get_node_or_nil(old_pos)
-                                       if is_light ~= nil and is_light.name == "technic:light" then
-                                               minetest.env:add_node(old_pos,{type="node",name="technic:light_off"})
-                                               minetest.env:add_node(old_pos,{type="node",name="air"})
-                                       end
-                               end
-                               -- gemerkte Position ist nun die gerundete neue Position
-                               player_positions[player_name]["x"] = rounded_pos.x
-                               player_positions[player_name]["y"] = rounded_pos.y
-                               player_positions[player_name]["z"] = rounded_pos.z
-                       end
-
-                       last_wielded[player_name] = true;
-               elseif last_wielded[player_name] == true  then
-                       -- Fackel nicht in der Hand, aber beim letzten Durchgang war die Fackel noch in der Hand
-                       local pos = player:getpos()
-                       local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
-                       repeat
-                               local is_light  = minetest.env:get_node_or_nil(rounded_pos)
-                               if is_light ~= nil and is_light.name == "technic:light" then
-                                       -- minetest.env:remove_node(rounded_pos)
-                                       -- Erzwinge Neuberechnung des Lichts
-                                       minetest.env:add_node(rounded_pos,{type="node",name="technic:light_off"})
-                                       minetest.env:add_node(rounded_pos,{type="node",name="air"})
-                               end
-                       until minetest.env:get_node_or_nil(rounded_pos) ~= "technic:light"
-                       local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]}
-                       repeat
-                               is_light  = minetest.env:get_node_or_nil(old_pos)
-                               if is_light ~= nil and is_light.name == "technic:light" then
-                                       -- minetest.env:remove_node(old_pos)
-                                       -- Erzwinge Neuberechnung des Lichts
-                                       minetest.env:add_node(old_pos,{type="node",name="technic:light_off"})
-                                       minetest.env:add_node(old_pos,{type="node",name="air"})
-                               end
-                       until minetest.env:get_node_or_nil(old_pos) ~= "technic:light"
-                       last_wielded[player_name] = true
-               end
-       end
-end)
-
-minetest.register_node("technic:light", {
-       drawtype = "glasslike",
-       tile_images = {"technic_light.png"},
-       paramtype = "light",
-       walkable = false,
-       is_ground_content = true,
-       light_propagates = true,
-       sunlight_propagates = true,
-       light_source = 15,
-       selection_box = {
-        type = "fixed",
-        fixed = {0, 0, 0, 0, 0, 0},
-    },
-})
-minetest.register_node("technic:light_off", {
-       drawtype = "glasslike",
-       tile_images = {"technic_light.png"},
-       paramtype = "light",
-       walkable = false,
-       is_ground_content = true,
-       light_propagates = true,
-       sunlight_propagates = true,
-       selection_box = {
-        type = "fixed",
-        fixed = {0, 0, 0, 0, 0, 0},
-    },
-})
-
-function flashlight_weared (player)
-flashlight_on=false
-local inv = player:get_inventory()
-local hotbar=inv:get_list("main")
-               for i=1,8,1 do
-                       
-                       if hotbar[i]:get_name() == "technic:flashlight" then
-                       item=hotbar[i]:to_table()
-                       if item["metadata"]=="" or item["metadata"]=="0" then return flashlight_on end --flashlight not charghed
-                       charge=tonumber(item["metadata"]) 
-                       if charge-2>0 then
-                        flashlight_on=true     
-                        charge =charge-2;      
-                       set_RE_wear(item,charge,flashlight_max_charge)
-                       item["metadata"]=tostring(charge)
-                       hotbar[i]:replace(item)
-                       inv:set_stack("main",i,hotbar[i])
-                       return true
-                       end
-                       end
-               end
-return flashlight_on
-end    
\ No newline at end of file
diff --git a/technic/forcefield.lua b/technic/forcefield.lua
deleted file mode 100644 (file)
index 8ad5410..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
--- Forcefield mod by ShadowNinja
--- Modified by kpoppel
---
--- Forcefields are powerful barriers but they consume huge amounts of power.
--- Forcefield Generator is a HV machine.
-
--- How expensive is the generator? Leaves room for upgrades lowering the power drain?
-local forcefield_power_drain     = 10 -- default 10
-local forcefield_update_interval = 1
-
-minetest.register_craft({
-       output = 'technic:forcefield_emitter_off',
-       recipe = {
-                       {'default:mese',         'technic:deployer_off', 'default:mese'        },
-                       {'technic:deployer_off', 'technic:motor',        'technic:deployer_off'},
-                       {'default:mese',         'technic:deployer_off', 'default:mese'        },
-       }
-})
-
--- Idea: Let forcefields have different colors by upgrade slot.
--- Idea: Let forcefields add up by detecting if one hits another.
---    ___   __
---   /   \/   \
---  |          |
---   \___/\___/
---
-local function add_forcefield(pos, range)
-       for x=-range,range do
-       for y=-range,range do
-       for z=-range,range do
-               if ((x*x+y*y+z*z) <= (range * range + range)) then
-                       if ((range-1) * (range-1) + (range-1) <= x*x+y*y+z*z) then
-                               local np={x=pos.x+x,y=pos.y+y,z=pos.z+z}
-                               local n = minetest.env:get_node(np).name
-                               if (n == "air") then
-                                       minetest.env:add_node(np, {name = "technic:forcefield"})
-                               end
-                       end
-               end
-       end
-       end
-       end
-       return true
-end
-
-local function remove_forcefield(p, range)
-       for x=-range,range do
-       for y=-range,range do
-       for z=-range,range do
-               if ((x*x+y*y+z*z) <= (range * range + range)) then
-                       if ((range-1) * (range-1) + (range-1) <= x*x+y*y+z*z) then
-                               local np={x=p.x+x,y=p.y+y,z=p.z+z}
-                               local n = minetest.env:get_node(np).name
-                               if (n == "technic:forcefield") then
-                                       minetest.env:remove_node(np)
-                               end
-                       end
-               end
-       end
-       end
-       end
-end
-
-local get_forcefield_formspec = function(range)
-   --  return "invsize[8,9;]"..  (if upgrades added later - colors for instance)
-       return "invsize[3,4;]"..
-       "label[0,0;Forcefield emitter]"..
-       "label[1,1;Range]"..
-       "label[1,2;"..range.."]"..
-       "button[0,2;1,1;subtract;-]"..
-       "button[2,2;1,1;add;+]"..
-       "button[0,3;3,1;toggle;Enable/Disable]" -- ..
---     "list[current_player;main;0,5;8,4;]"
-end
-
-local forcefield_receive_fields = function(pos, formname, fields, sender)
-                                    local meta = minetest.env:get_meta(pos)
-                                    local range = meta:get_int("range")
-                                    if fields.add then range = range + 1 end
-                                    if fields.subtract then range = range - 1 end
-                                    if fields.toggle then
-                                       if meta:get_int("enabled") == 1 then
-                                          meta:set_int("enabled", 0)
-                                       else
-                                          meta:set_int("enabled", 1)
-                                       end
-                                    end
-                                    -- Smallest field is 5. Anything less is asking for trouble.
-                                    -- Largest is 20. It is a matter of pratical node handling.
-                                    if range < 5  then range = 5 end
-                                    if range > 20 then range = 20 end
-
-                                    if range <= 20 and range >= 5 and meta:get_int("range") ~= range then
-                                       remove_forcefield(pos, meta:get_int("range"))
-                                       meta:set_int("range", range)
-                                       meta:set_string("formspec", get_forcefield_formspec(range))
-                                    end
-                                 end
-
-local forcefield_check = function(pos)
-                           local meta = minetest.env:get_meta(pos)
-                           local node = minetest.env:get_node(pos)
-                           local eu_input   = meta:get_int("HV_EU_input")
-                           local eu_demand  = meta:get_int("HV_EU_demand")
-                           local enabled    = meta:get_int("enabled")
-                           
-                           -- Power off automatically if no longer connected to a switching station
-                           technic.switching_station_timeout_count(pos, "HV")
-
-                           local power_requirement
-                           if enabled == 1 then
-                              power_requirement = math.floor(4*math.pi*math.pow(meta:get_int("range"), 2)) * forcefield_power_drain
-                           else
-                              power_requirement = eu_demand
-                           end
-
-                           if eu_input == 0 then
-                              meta:set_string("infotext", "Forcefield Generator Unpowered")
-                              meta:set_int("HV_EU_demand", 100)
-                              meta:set_int("enabled", 0)
-                              if node.name == "technic:forcefield_emitter_on" then
-                                 remove_forcefield(pos, meta:get_int("range"))
-                                 hacky_swap_node(pos, "technic:forcefield_emitter_off")
-                              end
-                           elseif eu_input == power_requirement then
-                              if meta:get_int("enabled") == 1 then
-                                 if node.name == "technic:forcefield_emitter_off" then
-                                    hacky_swap_node(pos, "technic:forcefield_emitter_on")
-                                    meta:set_string("infotext", "Forcefield Generator Active")
-                                    add_forcefield(pos, meta:get_int("range"))
-                                 else
-                                    -- Range updated. Move the forcefield.
-                                    add_forcefield(pos, meta:get_int("range"))
-                                 end
-                              else
-                                 if node.name == "technic:forcefield_emitter_on" then
-                                    remove_forcefield(pos, meta:get_int("range"))
-                                    hacky_swap_node(pos, "technic:forcefield_emitter_off")
-                                    meta:set_int("HV_EU_demand", 100)
-                                    meta:set_string("infotext", "Forcefield Generator Idle")
-                                 end
-                              end
-                           else
-                              meta:set_int("HV_EU_demand", power_requirement)
-                           end
-                           return true
-                        end
-
-local mesecons = {effector = {
-       action_on = function(pos, node)
-               minetest.env:get_meta(pos):set_int("enabled", 0)
-       end,
-       action_off = function(pos, node)
-               minetest.env:get_meta(pos):set_int("enabled", 1)
-       end
-}}
-
-minetest.register_node("technic:forcefield_emitter_off", {
-       description = "Forcefield emitter",
-       inventory_image = minetest.inventorycube("technic_forcefield_emitter_off.png"),
-       tiles = {"technic_forcefield_emitter_off.png"},
-       is_ground_content = true,
-       groups = {cracky = 1},
-       on_timer = forcefield_check,
-       on_receive_fields = forcefield_receive_fields,
-       on_construct = function(pos)
-               minetest.env:get_node_timer(pos):start(forcefield_update_interval)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_float("technic_hv_power_machine", 1)
-               meta:set_int("HV_EU_input", 0)
-               meta:set_int("HV_EU_demand", 0)
-               meta:set_int("range", 10)
-               meta:set_int("enabled", 0)
-               meta:set_string("formspec", get_forcefield_formspec(meta:get_int("range")))
-               meta:set_string("infotext", "Forcefield emitter");
-       end,
-       mesecons = mesecons
-})
-
-minetest.register_node("technic:forcefield_emitter_on", {
-       description = "Forcefield emitter on (you hacker you)",
-       tiles = {"technic_forcefield_emitter_on.png"},
-       is_ground_content = true,
-       groups = {cracky = 1, not_in_creative_inventory=1},
-       drop='"technic:forcefield_emitter_off" 1',
-       on_timer = forcefield_check,
-       on_receive_fields = forcefield_receive_fields,
-       on_construct = function(pos) 
-               minetest.env:get_node_timer(pos):start(forcefield_update_interval)
-               local meta = minetest.env:get_meta(pos)
---             meta:set_float("technic_hv_power_machine", 1)
---             meta:set_float("HV_EU_input", 0)
---             meta:set_float("HV_EU_demand", 0)
---             meta:set_int("range", 10)
---             meta:set_int("enabled", 1)
-               meta:set_string("formspec", get_forcefield_formspec(meta:get_int("range")))
---             meta:set_string("infotext", "Forcefield emitter");
-       end,
-       on_dig = function(pos, node, digger)    
-               remove_forcefield(pos, minetest.env:get_meta(pos):get_int("range"))
-               return minetest.node_dig(pos, node, digger)
-       end,
-       mesecons = mesecons
-})
-
-minetest.register_node("technic:forcefield", {
-       description = "Forcefield (you hacker you)",
-       sunlight_propagates = true,
-       drop = '',
-        light_source = 8,
-       tiles = {{name="technic_forcefield_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}}},
-       is_ground_content = true,
-       groups = {not_in_creative_inventory=1, unbreakable=1},
-       paramtype = "light",
-       drawtype = "nodebox",
-       node_box = {  --hacky way to get the field blue and not see through the ground
-               type = "fixed",
-               fixed={
-                       {-.5,-.5,-.5,.5,.5,.5},
-               },
-       },
-})
-
-technic.register_HV_machine("technic:forcefield_emitter_on","RE")
-technic.register_HV_machine("technic:forcefield_emitter_off","RE")
diff --git a/technic/frames.lua b/technic/frames.lua
deleted file mode 100644 (file)
index 7d141dc..0000000
+++ /dev/null
@@ -1,439 +0,0 @@
-frames={}
-
-function get_face(pos,ppos,pvect)
-       ppos={x=ppos.x-pos.x,y=ppos.y-pos.y+1.5,z=ppos.z-pos.z}
-       if pvect.x>0 then
-               local t=(-0.5-ppos.x)/pvect.x
-               local y_int=ppos.y+t*pvect.y
-               local z_int=ppos.z+t*pvect.z
-               if y_int>-0.4 and y_int<0.4 and z_int>-0.4 and z_int<0.4 then return 1 end 
-       elseif pvect.x<0 then
-               local t=(0.5-ppos.x)/pvect.x
-               local y_int=ppos.y+t*pvect.y
-               local z_int=ppos.z+t*pvect.z
-               if y_int>-0.4 and y_int<0.4 and z_int>-0.4 and z_int<0.4 then return 2 end 
-       end
-       if pvect.y>0 then
-               local t=(-0.5-ppos.y)/pvect.y
-               local x_int=ppos.x+t*pvect.x
-               local z_int=ppos.z+t*pvect.z
-               if x_int>-0.4 and x_int<0.4 and z_int>-0.4 and z_int<0.4 then return 3 end 
-       elseif pvect.y<0 then
-               local t=(0.5-ppos.y)/pvect.y
-               local x_int=ppos.x+t*pvect.x
-               local z_int=ppos.z+t*pvect.z
-               if x_int>-0.4 and x_int<0.4 and z_int>-0.4 and z_int<0.4 then return 4 end 
-       end
-       if pvect.z>0 then
-               local t=(-0.5-ppos.z)/pvect.z
-               local x_int=ppos.x+t*pvect.x
-               local y_int=ppos.y+t*pvect.y
-               if x_int>-0.4 and x_int<0.4 and y_int>-0.4 and y_int<0.4 then return 5 end 
-       elseif pvect.z<0 then
-               local t=(0.5-ppos.z)/pvect.z
-               local x_int=ppos.x+t*pvect.x
-               local y_int=ppos.y+t*pvect.y
-               if x_int>-0.4 and x_int<0.4 and y_int>-0.4 and y_int<0.4 then return 6 end 
-       end
-end
-
-
-for xm=0,1 do
-for xp=0,1 do
-for ym=0,1 do
-for yp=0,1 do
-for zm=0,1 do
-for zp=0,1 do
-
-local a=8/16
-local b=7/16
-local nodeboxes= {
-       { -a, -a, -a, -b,  a, -b },
-       { -a, -a,  b, -b,  a,  a },
-       {  b, -a,  b,  a,  a,  a },
-       {  b, -a, -a,  a,  a, -b },
-
-       { -b,  b, -a,  b,  a, -b },
-       { -b, -a, -a,  b, -b, -b },
-       
-       { -b,  b,  b,  b,  a,  a },
-       { -b, -a,  b,  b, -b,  a },
-
-       {  b,  b, -b,  a,  a,  b },
-       {  b, -a, -b,  a, -b,  b },
-
-       { -a,  b, -b, -b,  a,  b },
-       { -a, -a, -b, -b, -b,  b },
-       }
-       
-       if yp==0 then
-               table.insert(nodeboxes, {-b,b,-b, b,a,b})
-       end
-       if ym==0 then
-               table.insert(nodeboxes, {-b,-a,-b, b,-b,b})
-       end
-       if xp==0 then
-               table.insert(nodeboxes, {b,b,b,a,-b,-b})
-       end
-       if xm==0 then
-               table.insert(nodeboxes, {-a,-b,-b,-b,b,b})
-       end
-       if zp==0 then
-               table.insert(nodeboxes, {-b,-b,b, b,b,a})
-       end
-       if zm==0 then
-               table.insert(nodeboxes, {-b,-b,-a, b,b,-b})
-       end
-       
-       local nameext=tostring(xm)..tostring(xp)..tostring(ym)..tostring(yp)..tostring(zm)..tostring(zp)
-       local groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}
-       if nameext~="111111" then groups.not_in_creative_inventory=1 end
-       
-
-       minetest.register_node("technic:frame_"..nameext,{
-               description = "Frame",
-               tiles = {"technic_frame.png"},
-               groups=groups,
-               drawtype = "nodebox",
-               node_box = {
-                       type = "fixed",
-               fixed=nodeboxes,
-               },
-               selection_box = {
-                       type="fixed",
-                       fixed={-0.5,-0.5,-0.5,0.5,0.5,0.5}
-               },
-               paramtype = "light",
-               frame=1,
-               drop="technic:frame_111111",
-               frame_connect_all=function(pos)
-                       local nodename=minetest.env:get_node(pos).name
-                       l2={}
-                       l1={{x=-1,y=0,z=0},{x=1,y=0,z=0},{x=0,y=-1,z=0},{x=0,y=1,z=0},{x=0,y=0,z=-1},{x=0,y=0,z=1}}
-                       for i,dir in ipairs(l1) do
-                               if string.sub(nodename,-7+i,-7+i)=="1" then
-                                       l2[#(l2)+1]=dir
-                               end
-                       end
-                       return l2
-               end,
-               on_punch=function(pos,node,puncher)
-                       local ppos=puncher:getpos()
-                       local pvect=puncher:get_look_dir()
-                       local pface=get_face(pos,ppos,pvect)
-                       if pface==nil then return end
-                       local nodename=node.name
-                       local newstate=tostring(1-tonumber(string.sub(nodename,-7+pface,-7+pface)))
-                       if pface<=5 then
-                               nodename=string.sub(nodename,1,-7+pface-1)..newstate..string.sub(nodename,-7+pface+1)
-                       else
-                               nodename=string.sub(nodename,1,-2)..newstate
-                       end
-                       node.name=nodename
-                       minetest.env:set_node(pos,node)
-               end
-       })
-
-end
-end
-end
-end
-end
-end
-
-
-function frame_motor1_on(pos,node)
-       local npos={x=pos.x,y=pos.y+1,z=pos.z}
-       local nnode=minetest.env:get_node(npos)
-       if node.param2==0 then
-               dir={x=1,y=0,z=0}
-       elseif node.param2==1 then
-               dir={x=0,y=0,z=-1}
-       elseif node.param2==2 then
-               dir={x=-1,y=0,z=0}
-       else
-               dir={x=0,y=0,z=1}
-       end
-       if minetest.registered_nodes[nnode.name].frame==1 then
-               local connected_nodes=get_connected_nodes(npos)
-               move_nodes_vect(connected_nodes,dir)
-       end
-end
-
-function frame_motor2_on(pos,node)
-       local npos={x=pos.x,y=pos.y-1,z=pos.z}
-       local nnode=minetest.env:get_node(npos)
-       if node.param2==0 then
-               dir={x=1,y=0,z=0}
-       elseif node.param2==1 then
-               dir={x=0,y=0,z=-1}
-       elseif node.param2==2 then
-               dir={x=-1,y=0,z=0}
-       else
-               dir={x=0,y=0,z=1}
-       end
-       if minetest.registered_nodes[nnode.name].frame==1 then
-               local connected_nodes=get_connected_nodes(npos)
-               move_nodes_vect(connected_nodes,dir)
-       end
-end
-
-function frame_motor3_on(pos,node)
-       local npos={x=pos.x,y=pos.y,z=pos.z}
-       if node.param2==0 then
-               dir={x=1,y=0,z=0}
-               npos.z=npos.z-1
-       elseif node.param2==1 then
-               dir={x=0,y=0,z=-1}
-               npos.x=npos.x-1
-       elseif node.param2==2 then
-               dir={x=-1,y=0,z=0}
-               npos.z=npos.z+1
-       else
-               dir={x=0,y=0,z=1}
-               npos.x=npos.x+1
-       end
-       local nnode=minetest.env:get_node(npos)
-       if minetest.registered_nodes[nnode.name].frame==1 then
-               local connected_nodes=get_connected_nodes(npos)
-               move_nodes_vect(connected_nodes,dir)
-       end
-end
-
-function frame_motor4_on(pos,node)
-       local npos={x=pos.x,y=pos.y,z=pos.z}
-       if node.param2==0 then
-               dir={x=-1,y=0,z=0}
-               npos.z=npos.z-1
-       elseif node.param2==1 then
-               dir={x=0,y=0,z=1}
-               npos.x=npos.x-1
-       elseif node.param2==2 then
-               dir={x=1,y=0,z=0}
-               npos.z=npos.z+1
-       else
-               dir={x=0,y=0,z=-1}
-               npos.x=npos.x+1
-       end
-       local nnode=minetest.env:get_node(npos)
-       if minetest.registered_nodes[nnode.name].frame==1 then
-               local connected_nodes=get_connected_nodes(npos)
-               move_nodes_vect(connected_nodes,dir)
-       end
-end
-
-function frame_motor5_on(pos,node)
-       local npos={x=pos.x,y=pos.y,z=pos.z}
-       if node.param2==0 then
-               npos.z=npos.z-1
-       elseif node.param2==1 then
-               npos.x=npos.x-1
-       elseif node.param2==2 then
-               npos.z=npos.z+1
-       else
-               npos.x=npos.x+1
-       end
-       dir={x=0,y=1,z=0}
-       local nnode=minetest.env:get_node(npos)
-       if minetest.registered_nodes[nnode.name].frame==1 then
-               local connected_nodes=get_connected_nodes(npos)
-               move_nodes_vect(connected_nodes,dir)
-       end
-end
-
-function frame_motor6_on(pos,node)
-       local npos={x=pos.x,y=pos.y,z=pos.z}
-       if node.param2==0 then
-               npos.z=npos.z-1
-       elseif node.param2==1 then
-               npos.x=npos.x-1
-       elseif node.param2==2 then
-               npos.z=npos.z+1
-       else
-               npos.x=npos.x+1
-       end
-       dir={x=0,y=-1,z=0}
-       local nnode=minetest.env:get_node(npos)
-       if minetest.registered_nodes[nnode.name].frame==1 then
-               local connected_nodes=get_connected_nodes(npos)
-               move_nodes_vect(connected_nodes,dir)
-       end
-end
-
-
-minetest.register_node("technic:frame_motor1",{
-       description = "Frame motor 1",
-       tiles = {"pipeworks_filter_top.png", "technic_lv_cable.png", "technic_lv_cable.png",
-               "technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
-       paramtype2 = "facedir",
-       mesecons={effector={action_on=frame_motor1_on}},
-       frames_can_connect=function(pos,dir)
-               return dir.y~=-1
-       end
-})
-
-minetest.register_node("technic:frame_motor2",{
-       description = "Frame motor 2",
-       tiles = {"technic_lv_cable.png", "pipeworks_filter_top.png", "technic_lv_cable.png",
-               "technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
-       paramtype2 = "facedir",
-       mesecons={effector={action_on=frame_motor2_on}},
-       frames_can_connect=function(pos,dir)
-               return dir.y~=1
-       end
-})
-
-minetest.register_node("technic:frame_motor3",{
-       description = "Frame motor 3",
-       tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
-               "technic_lv_cable.png", "technic_lv_cable.png", "pipeworks_filter_top.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
-       paramtype2 = "facedir",
-       mesecons={effector={action_on=frame_motor3_on}},
-       frames_can_connect=function(pos,dir)
-               local node=minetest.env:get_node(pos)
-               if node.param2==0 then return dir.z~=1
-               elseif node.param2==1 then return dir.x~=1
-               elseif node.param2==2 then return dir.z~=-1
-               else return dir.x~=-1 end
-       end
-})
-
-minetest.register_node("technic:frame_motor4",{
-       description = "Frame motor 4",
-       tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
-               "technic_lv_cable.png", "technic_lv_cable.png", "pipeworks_filter_top.png^[transformR180"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
-       paramtype2 = "facedir",
-       mesecons={effector={action_on=frame_motor4_on}},
-       frames_can_connect=function(pos,dir)
-               local node=minetest.env:get_node(pos)
-               if node.param2==0 then return dir.z~=1
-               elseif node.param2==1 then return dir.x~=1
-               elseif node.param2==2 then return dir.z~=-1
-               else return dir.x~=-1 end
-       end
-})
-
-minetest.register_node("technic:frame_motor5",{
-       description = "Frame motor 5",
-       tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
-               "technic_lv_cable.png", "technic_lv_cable.png", "pipeworks_filter_top.png^[transformR90"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
-       paramtype2 = "facedir",
-       mesecons={effector={action_on=frame_motor5_on}},
-       frames_can_connect=function(pos,dir)
-               local node=minetest.env:get_node(pos)
-               if node.param2==0 then return dir.z~=1
-               elseif node.param2==1 then return dir.x~=1
-               elseif node.param2==2 then return dir.z~=-1
-               else return dir.x~=-1 end
-       end
-})
-
-minetest.register_node("technic:frame_motor6",{
-       description = "Frame motor 6",
-       tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
-               "technic_lv_cable.png", "technic_lv_cable.png", "pipeworks_filter_top.png^[transformR270"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
-       paramtype2 = "facedir",
-       mesecons={effector={action_on=frame_motor6_on}},
-       frames_can_connect=function(pos,dir)
-               local node=minetest.env:get_node(pos)
-               if node.param2==0 then return dir.z~=1
-               elseif node.param2==1 then return dir.x~=1
-               elseif node.param2==2 then return dir.z~=-1
-               else return dir.x~=-1 end
-       end
-})
-
-function add_table(table,toadd)
-       local i=1
-       while true do
-               o=table[i]
-               if o==toadd then return end
-               if o==nil then break end
-               i=i+1
-       end
-       table[i]=toadd
-end
-
-function move_nodes_vect(poslist,vect)
-               for _,pos in ipairs(poslist) do
-               local npos=frames.addVect(pos,vect)
-               local name = minetest.env:get_node(npos).name
-               if (name~="air" and minetest.registered_nodes[name].liquidtype=="none") and not(pos_in_list(poslist,npos)) then
- return end
-       end
-       nodelist={}
-       for _,pos in ipairs(poslist) do
-               local node=minetest.env:get_node(pos)
-               local meta=minetest.env:get_meta(pos):to_table()
-               nodelist[#(nodelist)+1]={pos=pos,node=node,meta=meta}
-       end
-       objects={}
-       for _,pos in ipairs(poslist) do
-               for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
-                       add_table(objects,object)
-               end
-       end
-       for _,obj in ipairs(objects) do
-               obj:setpos(frames.addVect(obj:getpos(),vect))
-               le=obj:get_luaentity()
-               if le and le.name == "pipeworks:tubed_item" then
-                       le.start_pos=frames.addVect(le.start_pos,vect)
-               end
-       end
-       for _,n in ipairs(nodelist) do
-               local npos=frames.addVect(n.pos,vect)
-               minetest.env:set_node(npos,n.node)
-               local meta=minetest.env:get_meta(npos)
-               meta:from_table(n.meta)
-               for __,pos in ipairs(poslist) do
-                       if npos.x==pos.x and npos.y==pos.y and npos.z==pos.z then
-                               table.remove(poslist, __)
-                               break
-                       end
-               end
-       end
-       for __,pos in ipairs(poslist) do
-               minetest.env:remove_node(pos)
-       end
-end
-
-function get_connected_nodes(pos)
-       c={pos}
-       local nodename=minetest.env:get_node(pos).name
-       connected(pos,c,minetest.registered_nodes[nodename].frame_connect_all(pos))
-       return c
-end
-
-function frames.addVect(pos,vect)
-       return {x=pos.x+vect.x,y=pos.y+vect.y,z=pos.z+vect.z}
-end
-
-function pos_in_list(l,pos)
-       for _,p in ipairs(l) do
-               if p.x==pos.x and p.y==pos.y and p.z==pos.z then return true end
-       end
-       return false
-end
-
-function connected(pos,c,adj)
-       for _,vect in ipairs(adj) do
-               local pos1=frames.addVect(pos,vect)
-               local nodename=minetest.env:get_node(pos1).name
-               if not(pos_in_list(c,pos1)) and nodename~="air" and
-               (minetest.registered_nodes[nodename].frames_can_connect==nil or
-               minetest.registered_nodes[nodename].frames_can_connect(pos1,vect)) then
-                       c[#(c)+1]=pos1
-                       if minetest.registered_nodes[nodename].frame==1 then
-                               local adj=minetest.registered_nodes[nodename].frame_connect_all(pos1)
-                               connected(pos1,c,adj)
-                       end
-               end
-       end
-end
-
diff --git a/technic/generator.lua b/technic/generator.lua
deleted file mode 100644 (file)
index 21db4b4..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
--- The coal driven EU generator.
--- A simple device to get started on the electric machines.
--- Inefficient and expensive in coal (200EU 16 ticks)
--- Also only allows for LV machinery to run.
-minetest.register_alias("generator", "technic:generator")
-minetest.register_alias("generator", "technic:generator_active")
-
-minetest.register_craft({
-       output = 'technic:generator',
-       recipe = {
-               {'default:stone', 'default:stone', 'default:stone'},
-               {'default:stone', '', 'default:stone'},
-               {'default:stone', 'default:copper_ingot', 'default:stone'},
-       }
-})
-
-minetest.register_craftitem("technic:generator", {
-       description = "Coal Driven Generator",
-       stack_max = 99,
-}) 
-
-local generator_formspec =
-       "invsize[8,9;]"..
-       "image[0,0;5,5;technic_generator_menu.png]"..
-       "image[1,1;1,2;technic_power_meter_bg.png]"..
---     "label[0,0;Generator]"..
-       "label[1,3;Power level]"..
-       "list[current_name;src;3,1;1,1;]"..
-       "image[4,1;1,1;default_furnace_fire_bg.png]"..
-       "list[current_player;main;0,5;8,4;]"
-       
-
-minetest.register_node(
-   "technic:generator",
-   {
-      description = "Coal Driven Generator",
-      tiles = {"technic_generator_top.png", "technic_machine_bottom.png", "technic_generator_side.png",
-              "technic_generator_side.png", "technic_generator_side.png", "technic_generator_front.png"},
-      paramtype2 = "facedir",
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_wood_defaults(),
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       meta:set_string("infotext", "Coal Electric Generator")
-                       meta:set_float("technic_power_machine", 1)
-                       meta:set_int("LV_EU_supply", 0)
-                       meta:set_int("LV_EU_from_fuel", 1) -- Signal to the switching station that this device burns some sort of fuel and needs special handling
-                       meta:set_int("burn_time", 0)
-                       meta:set_string("formspec", generator_formspec)
-                       local inv = meta:get_inventory()
-                       inv:set_size("src", 1)
-               end,    
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  else
-                     return true
-                  end
-               end,
-   })
-
-minetest.register_node(
-   "technic:generator_active",
-   {
-      description = "Coal Driven Generator",
-      tiles = {"technic_generator_top.png", "technic_machine_bottom.png", "technic_generator_side.png",
-              "technic_generator_side.png", "technic_generator_side.png", "technic_generator_front_active.png"},
-      paramtype2 = "facedir",
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_wood_defaults(),
-      drop="technic:generator",
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  else
-                     return true
-                  end
-               end,
-   })
-
-minetest.register_abm(
-   {
-      nodenames = {"technic:generator","technic:generator_active"},
-      interval = 1,
-      chance   = 1,
-      action = function(pos, node, active_object_count, active_object_count_wider)
-                 local meta = minetest.env:get_meta(pos)
-                 local burn_time= meta:get_int("burn_time")
-
-                 -- If more to burn and the energy produced was used: produce some more
-                 if burn_time>0 then
-                    if meta:get_int("LV_EU_supply") == 0 then
-                       -- We did not use the power
-                       meta:set_int("LV_EU_supply", 200) -- Give 200EUs
-                    else
-                       burn_time = burn_time - 1
-                       meta:set_int("burn_time",burn_time)
-                       meta:set_string("infotext", "Coal Electric Generator ("..math.floor(burn_time/16*100).."%)")
-                    end
-                 end
-
-                 -- Burn another piece of coal
-                 if burn_time==0 then
-                    local inv = meta:get_inventory()
-                    if inv:is_empty("src") == false  then 
-                       local srcstack = inv:get_stack("src", 1)
-                       src_item=srcstack:to_table()
-                       if src_item["name"] == "default:coal_lump" then
-                          srcstack:take_item()
-                          inv:set_stack("src", 1, srcstack)
-                          burn_time=16
-                          meta:set_int("burn_time",burn_time)
-                          hacky_swap_node (pos,"technic:generator_active") 
-                          meta:set_int("LV_EU_supply", 200) -- Give 200EUs
-                       else
-                          meta:set_int("LV_EU_supply", 0)
-                       end
-                    end
-                 end
-
-                 local load = 8 -- math.floor((charge/max_charge)*100)
-                 local percent = math.floor((burn_time/16)*100)
-                 meta:set_string("formspec",
-                                 "invsize[8,9;]"..
-                                    "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
-                                    (load)..":technic_power_meter_fg.png]"..
-                                 "label[0,0;Generator]"..
-                                 "label[1,3;Power level]"..
-                                 "list[current_name;src;3,1;1,1;]"..
-                                 "image[4,1;1,1;default_furnace_fire_bg.png^[lowpart:"..
-                                 (percent)..":default_furnace_fire_fg.png]"..
-                              "list[current_player;main;0,5;8,4;]"
-                        )
-
-                 if burn_time==0 then
-                    hacky_swap_node (pos,"technic:generator")
-                 end
-              end
-   })
-
-technic.register_LV_machine ("technic:generator","PR")
-technic.register_LV_machine ("technic:generator_active","PR")
diff --git a/technic/geothermal.lua b/technic/geothermal.lua
deleted file mode 100644 (file)
index 5ba7a23..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
--- A geothermal EU generator
--- Using hot lava and water this device can create energy from steam
--- The machine is only producing LV EUs and can thus not drive more advanced equipment
--- The output is a little more than the coal burning generator (max 300EUs)
-minetest.register_alias("geothermal", "technic:geothermal")
-
-minetest.register_craft({
-       output = 'technic:geothermal',
-       recipe = {
-               {'default:stone', 'default:stone', 'default:stone'},
-               {'default:copper_ingot', 'default:diamond', 'default:copper_ingot'},
-               {'default:stone', 'default:copper_ingot', 'default:stone'},
-       }
-})
-
-minetest.register_craftitem("technic:geothermal", {
-       description = "Geothermal Generator",
-       stack_max = 99,
-}) 
-
-local geothermal_formspec =
-       "invsize[8,4;]"..
-       "image[1,1;1,2;technic_power_meter_bg.png]"..
-       "label[0,0;Geothermal Generator]"..
-       "label[1,3;Power level]"..
-       "list[current_player;main;0,5;8,4;]"
-       
-
-minetest.register_node(
-   "technic:geothermal",
-   {
-      description = "Geothermal Generator",
-      tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
-              "technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
-      paramtype2 = "facedir",
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_wood_defaults(),
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       meta:set_string("infotext", "Geothermal Generator")
-                       meta:set_float("technic_power_machine", 1)
-                       meta:set_int("LV_EU_supply", 0)
-                       meta:set_string("formspec", geothermal_formspec)        
-                    end,       
-   })
-
-minetest.register_node(
-   "technic:geothermal_active",
-   {
-      description = "Geothermal Generator",
-      tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
-              "technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
-      paramtype2 = "facedir",
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_wood_defaults(),
-      drop="technic:geothermal",
-   })
-
-local check_node_around = function(pos)
-                            local node=minetest.env:get_node(pos)
-                            if node.name=="default:water_source" or node.name=="default:water_flowing" then return 1 end
-                            if node.name=="default:lava_source" or node.name=="default:lava_flowing" then return 2 end 
-                            return 0
-                         end
-
-minetest.register_abm(
-   {
-      nodenames = {"technic:geothermal","technic:geothermal_active"},
-      interval = 1,
-      chance   = 1,
-      action = function(pos, node, active_object_count, active_object_count_wider)
-                 local meta             = minetest.env:get_meta(pos)
-                 local water_nodes      = 0
-                 local lava_nodes       = 0
-                 local production_level = 0
-                 local eu_supply        = 0
-
-                 -- Correct positioning is water on one side and lava on the other.
-                 -- The two cannot be adjacent because the lava the turns into obsidian or rock.
-                 -- To get to 100% production stack the water and lava one extra block down as well:
-                 --    WGL (W=Water, L=Lava, G=the generator, |=an LV cable)
-                  --    W|L
-                 pos.x=pos.x+1
-                 local check=check_node_around(pos)
-                 if check==1 then water_nodes=water_nodes+1 end
-                 if check==2 then lava_nodes=lava_nodes+1 end
-                 pos.y=pos.y-1
-                 local check=check_node_around(pos)
-                 if check==1 then water_nodes=water_nodes+1 end
-                 if check==2 then lava_nodes=lava_nodes+1 end
-
-                 pos.x=pos.x-2
-                 check=check_node_around(pos)
-                 if check==1 then water_nodes=water_nodes+1 end
-                 if check==2 then lava_nodes=lava_nodes+1 end
-                 pos.y=pos.y+1
-                 check=check_node_around(pos)
-                 if check==1 then water_nodes=water_nodes+1 end
-                 if check==2 then lava_nodes=lava_nodes+1 end
-
-                 pos.x=pos.x+1
-                 pos.z=pos.z+1
-                 check=check_node_around(pos)
-                 if check==1 then water_nodes=water_nodes+1 end
-                 if check==2 then lava_nodes=lava_nodes+1 end
-                 pos.y=pos.y-1
-                 check=check_node_around(pos)
-                 if check==1 then water_nodes=water_nodes+1 end
-                 if check==2 then lava_nodes=lava_nodes+1 end
-
-                 pos.z=pos.z-2
-                 check=check_node_around(pos)
-                 if check==1 then water_nodes=water_nodes+1 end
-                 if check==2 then lava_nodes=lava_nodes+1 end
-                 pos.y=pos.y+1
-                 check=check_node_around(pos)
-                 if check==1 then water_nodes=water_nodes+1 end
-                 if check==2 then lava_nodes=lava_nodes+1 end
-
-                 -- Back to (0,0,0)
-                 pos.z=pos.z+1
-       
-                 if water_nodes==1 and lava_nodes==1 then production_level =  25; eu_supply = 50 end
-                 if water_nodes==2 and lava_nodes==1 then production_level =  50; eu_supply = 100 end
-                 if water_nodes==1 and lava_nodes==2 then production_level =  75; eu_supply = 200 end
-                 if water_nodes==2 and lava_nodes==2 then production_level = 100; eu_supply = 300 end
-
-                 if production_level>0 then
-                    meta:set_int("LV_EU_supply", eu_supply)
-                 end
-
-                 local load = 1 -- math.floor((charge/max_charge)*100)
-                 meta:set_string("formspec",
-                                 "invsize[8,4;]"..
-                                    "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
-                                    (load)..":technic_power_meter_fg.png]"..
-                                 "label[0,0;Geothermal Generator]"..
-                                 "label[1,3;Power level]"..
-                                 "label[4,0;Production at "..tostring(production_level).."%]"
-                           )
-                               
-                 if production_level>0 and minetest.env:get_node(pos).name=="technic:geothermal" then
-                    hacky_swap_node (pos,"technic:geothermal_active")
-                    return
-                 end
-                 if production_level==0 then
-                    hacky_swap_node (pos,"technic:geothermal")
-                    meta:set_int("LV_EU_supply", 0)
-                 end
-              end
-   }) 
-
-technic.register_LV_machine ("technic:geothermal","PR")
-technic.register_LV_machine ("technic:geothermal_active","PR")
diff --git a/technic/grinder.lua b/technic/grinder.lua
deleted file mode 100644 (file)
index baef12d..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-technic.grinder_recipes ={}
-
-technic.register_grinder_recipe = function(src, dst)
-                                  technic.grinder_recipes[src] = dst
-                                  if unified_inventory then
-                                     unified_inventory.register_craft(
-                                        {
-                                           type = "grinding",
-                                           output = dst,
-                                           items = {src},
-                                           width = 0,
-                                        })
-                                  end
-                               end
-
--- Receive an ItemStack of result by an ItemStack input
-technic.get_grinder_recipe = function(itemstack)
-                               local src_item  = itemstack:to_table()
-                               if src_item == nil then
-                                  return nil
-                               end
-                               local item_name = src_item["name"]
-                               if technic.grinder_recipes[item_name] then
-                                  return ItemStack(technic.grinder_recipes[item_name])
-                               else
-                                  return nil
-                               end
-                            end
-
-
-technic.register_grinder_recipe("default:stone","default:sand")
-technic.register_grinder_recipe("default:cobble","default:gravel")
-technic.register_grinder_recipe("default:gravel","default:dirt")
-technic.register_grinder_recipe("default:desert_stone","default:desert_sand")
-technic.register_grinder_recipe("default:iron_lump","technic:iron_dust 2")
-technic.register_grinder_recipe("default:steel_ingot","technic:iron_dust 1")
-technic.register_grinder_recipe("default:coal_lump","technic:coal_dust 2")
-technic.register_grinder_recipe("default:copper_lump","technic:copper_dust 2")
-technic.register_grinder_recipe("default:copper_ingot","technic:copper_dust 1")
-technic.register_grinder_recipe("default:gold_lump","technic:gold_dust 2")
-technic.register_grinder_recipe("default:gold_ingot","technic:gold_dust 1")
---technic.register_grinder_recipe("default:bronze_ingot","technic:bronze_dust 1")  -- Dust does not exist yet
---technic.register_grinder_recipe("home_decor:brass_ingot","technic:brass_dust 1") -- needs check for the mod
-technic.register_grinder_recipe("moreores:tin_lump","technic:tin_dust 2")
-technic.register_grinder_recipe("moreores:tin_ingot","technic:tin_dust 1")
-technic.register_grinder_recipe("moreores:silver_lump","technic:silver_dust 2")
-technic.register_grinder_recipe("moreores:silver_ingot","technic:silver_dust 1")
-technic.register_grinder_recipe("moreores:mithril_lump","technic:mithril_dust 2")
-technic.register_grinder_recipe("moreores:mithril_ingot","technic:mithril_dust 1")
-technic.register_grinder_recipe("technic:chromium_lump","technic:chromium_dust 2")
-technic.register_grinder_recipe("technic:chromium_ingot","technic:chromium_dust 1")
-technic.register_grinder_recipe("technic:stainless_steel_ingot","stainless_steel_dust 1")
-technic.register_grinder_recipe("technic:brass_ingot","technic:brass_dust 1")
-technic.register_grinder_recipe("technic:zinc_lump","technic:zinc_dust 2")
-technic.register_grinder_recipe("technic:zinc_ingot","technic:zinc_dust 1")
-
-minetest.register_craftitem( "technic:coal_dust", {
-                               description = "Coal Dust",
-                               inventory_image = "technic_coal_dust.png",
-                               on_place_on_ground = minetest.craftitem_place_item,
-                            })
-
-minetest.register_craftitem( "technic:iron_dust", {
-                               description = "Iron Dust",
-                               inventory_image = "technic_iron_dust.png",
-                               on_place_on_ground = minetest.craftitem_place_item,
-                            })
-
-minetest.register_craft({
-                          type = "cooking",
-                          output = "default:steel_ingot",
-                          recipe = "technic:iron_dust",
-                       })
-
-minetest.register_craftitem( "technic:copper_dust", {
-                               description = "Copper Dust",
-                               inventory_image = "technic_copper_dust.png",
-                               on_place_on_ground = minetest.craftitem_place_item,
-                            })
-minetest.register_craft({
-                          type = "cooking",
-                          output = "moreores:copper_ingot",
-                          recipe = "technic:copper_dust",
-                       })
-
-minetest.register_craftitem( "technic:tin_dust", {
-                               description = "Tin Dust",
-                               inventory_image = "technic_tin_dust.png",
-                               on_place_on_ground = minetest.craftitem_place_item,
-                            })
-minetest.register_craft({
-                          type = "cooking",
-                          output = "moreores:tin_ingot",
-                          recipe = "technic:tin_dust",
-                       })
-
-minetest.register_craftitem( "technic:silver_dust", {
-                               description = "Silver Dust",
-                               inventory_image = "technic_silver_dust.png",
-                               on_place_on_ground = minetest.craftitem_place_item,
-                            })
-minetest.register_craft({
-                          type = "cooking",
-                          output = "moreores:silver_ingot",
-                          recipe = "technic:silver_dust",
-                       })
-
-minetest.register_craftitem( "technic:gold_dust", {
-                               description = "Gold Dust",
-                               inventory_image = "technic_gold_dust.png",
-                               on_place_on_ground = minetest.craftitem_place_item,
-                            })
-minetest.register_craft({
-                          type = "cooking",
-                          output = "default:gold_ingot",
-                          recipe = "technic:gold_dust",
-                       })
-
-minetest.register_craftitem( "technic:mithril_dust", {
-                               description = "Mithril Dust",
-                               inventory_image = "technic_mithril_dust.png",
-                               on_place_on_ground = minetest.craftitem_place_item,
-                            })
-minetest.register_craft({
-                          type = "cooking",
-                          output = "moreores:mithril_ingot",
-                          recipe = "technic:mithril_dust",
-                       })
-
-minetest.register_craftitem( "technic:chromium_dust", {
-                               description = "Chromium Dust",
-                               inventory_image = "technic_chromium_dust.png",
-                               on_place_on_ground = minetest.craftitem_place_item,
-                            })
-minetest.register_craft({
-                          type = "cooking",
-                          output = "technic:chromium_ingot",
-                          recipe = "technic:chromium_dust",
-                       })
-
-minetest.register_craftitem( "technic:bronze_dust", {
-                               description = "Bronze Dust",
-                               inventory_image = "technic_bronze_dust.png",
-                               on_place_on_ground = minetest.craftitem_place_item,
-                            })
-minetest.register_craft({
-                          type = "cooking",
-                          output = "default:bronze_ingot",
-                          recipe = "technic:bronze_dust",
-                       })
-
-minetest.register_craftitem( "technic:brass_dust", {
-                               description = "Brass Dust",
-                               inventory_image = "technic_brass_dust.png",
-                               on_place_on_ground = minetest.craftitem_place_item,
-                            })
-minetest.register_craft({
-                          type = "cooking",
-                          output = "technic:brass_ingot",
-                          recipe = "technic:brass_dust",
-                       })
-
-minetest.register_craftitem( "technic:stainless_steel_dust", {
-                               description = "Stainless Steel Dust",
-                               inventory_image = "technic_stainless_steel_dust.png",
-                            })
-
-minetest.register_craft({
-                          type = "cooking",
-                          output = "technic:stainless_steel_ingot",
-                          recipe = "technic:stainless_steel_dust",
-                       })
-
-minetest.register_craftitem( "technic:zinc_dust", {
-                               description = "Zinc Dust",
-                               inventory_image = "technic_zinc_dust.png",
-                            })
-
-minetest.register_craft({
-                          type = "cooking",
-                          output = "technic:zinc_ingot",
-                          recipe = "technic:zinc_dust",
-                       })
-
-minetest.register_alias("grinder", "technic:grinder")
-minetest.register_craft({
-                          output = 'technic:grinder',
-                          recipe = {
-                             {'default:desert_stone', 'default:desert_stone', 'default:desert_stone'},
-                             {'default:desert_stone', 'default:diamond', 'default:desert_stone'},
-                             {'default:stone', 'moreores:copper_ingot', 'default:stone'},
-                          }
-                       })
-
-minetest.register_craftitem("technic:grinder", {
-                              description = "Grinder",
-                              stack_max = 99,
-                           })
-
-local grinder_formspec =
-   "invsize[8,9;]"..
-   "label[0,0;Grinder]"..
-   "list[current_name;src;3,1;1,1;]"..
-   "list[current_name;dst;5,1;2,2;]"..
-   "list[current_player;main;0,5;8,4;]"
-
-minetest.register_node(
-   "technic:grinder",
-   {
-      description = "Grinder",
-      tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
-              "technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
-      paramtype2 = "facedir",
-      groups = {cracky=2},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_wood_defaults(),
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       meta:set_string("infotext", "Grinder")
-                       meta:set_float("technic_power_machine", 1)
-                       meta:set_string("formspec", grinder_formspec)
-                       local inv = meta:get_inventory()
-                       inv:set_size("src", 1)
-                       inv:set_size("dst", 4)
-                    end,
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") or not inv:is_empty("dst") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  else
-                     return true
-                  end
-               end,
-   })
-
-minetest.register_node(
-   "technic:grinder_active",
-   {
-      description = "Grinder",
-      tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
-              "technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front_active.png"},
-      paramtype2 = "facedir",
-      groups = {cracky=2,not_in_creative_inventory=1},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_wood_defaults(),
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") or not inv:is_empty("dst") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  else
-                     return true
-                  end
-               end,
-   })
-
-minetest.register_abm(
-   { nodenames = {"technic:grinder","technic:grinder_active"},
-     interval = 1,
-     chance   = 1,
-     action = function(pos, node, active_object_count, active_object_count_wider)
-                -- Run a machine through its states. Takes the same arguments as the ABM action
-                -- and adds the machine's states and any extra data which is needed by the machine.
-                -- A machine is characterized by running through a set number of states (usually 2:
-                -- Idle and active) in some order. A state decides when to move to the next one
-                -- and the machine only changes state if it is powered correctly.
-                -- The machine will automatically shut down if disconnected from power in some fashion.
-                local meta         = minetest.env:get_meta(pos)
-                local eu_input     = meta:get_int("LV_EU_input")
-                local state        = meta:get_int("state")
-                local next_state   = state
-
-                -- Machine information
-                local machine_name         = "Grinder"
-                local machine_node         = "technic:grinder"
-                local machine_state_demand = { 50, 300 }
-                        
-                -- Setup meta data if it does not exist. state is used as an indicator of this
-                if state == 0 then
-                   meta:set_int("state", 1)
-                   meta:set_int("LV_EU_demand", machine_state_demand[1])
-                   meta:set_int("LV_EU_input", 0)
-                   return
-                end
-                        
-                -- Power off automatically if no longer connected to a switching station
-                technic.switching_station_timeout_count(pos, "LV")
-                        
-                -- State machine
-                if eu_input == 0 then
-                   -- unpowered - go idle
-                   hacky_swap_node(pos, machine_node)
-                   meta:set_string("infotext", machine_name.." Unpowered")
-                   next_state = 1
-                elseif eu_input == machine_state_demand[state] then
-                   -- Powered - do the state specific actions
-                           
-                   local inv    = meta:get_inventory()
-                   local empty  = inv:is_empty("src")
-
-                   if state == 1 then
-                      hacky_swap_node(pos, machine_node)
-                      meta:set_string("infotext", machine_name.." Idle")
-
-                      local result = technic.get_grinder_recipe(inv:get_stack("src", 1))
-                      if not empty and result and inv:room_for_item("dst",result) then
-                         meta:set_int("src_time", 0)
-                         next_state = 2
-                      end
-
-                   elseif state == 2 then
-                      hacky_swap_node(pos, machine_node.."_active")
-                      meta:set_string("infotext", machine_name.." Active")
-
-                      if empty then
-                         next_state = 1
-                      else
-                         meta:set_int("src_time", meta:get_int("src_time") + 1)
-                         if meta:get_int("src_time") == 4 then -- 4 ticks per output
-                            -- check if there's room for output in "dst" list
-                            local result = technic.get_grinder_recipe(inv:get_stack("src", 1))
-
-                            meta:set_int("src_time", 0)
-                            if inv:room_for_item("dst",result) then
-                               -- take stuff from "src" list
-                               srcstack = inv:get_stack("src", 1)
-                               srcstack:take_item()
-                               inv:set_stack("src", 1, srcstack)
-                               -- Put result in "dst" list
-                               inv:add_item("dst", result)
-                            else
-                               -- all full: go idle
-                               next_state = 1
-                            end
-                         end
-                      end
-                   end
-                end
-                -- Change state?
-                if next_state ~= state then
-                   meta:set_int("LV_EU_demand", machine_state_demand[next_state])
-                   meta:set_int("state", next_state)
-                end
-             end
-  })
-
-technic.register_LV_machine ("technic:grinder","RE")
-technic.register_LV_machine ("technic:grinder_active","RE")
-
diff --git a/technic/grinder.lua~ b/technic/grinder.lua~
deleted file mode 100644 (file)
index 8343a94..0000000
+++ /dev/null
@@ -1,353 +0,0 @@
-grinder_recipes ={}
-
-registered_grinder_recipes_count=1
-
-function register_grinder_recipe (string1,string2)
-grinder_recipes[registered_grinder_recipes_count]={}
-grinder_recipes[registered_grinder_recipes_count].src_name=string1
-grinder_recipes[registered_grinder_recipes_count].dst_name=string2
-registered_grinder_recipes_count=registered_grinder_recipes_count+1
-if unified_inventory then
-       unified_inventory.register_craft({
-       type = "grinding",
-       output = string2,
-       items = {string1},
-       width = 0,
-       })
-       end
-end
-
-register_grinder_recipe("default:stone","default:sand")
-register_grinder_recipe("default:cobble","default:gravel")
-register_grinder_recipe("default:gravel","default:dirt")
-register_grinder_recipe("default:desert_stone","default:desert_sand")
-register_grinder_recipe("default:iron_lump","technic:iron_dust 2")
-register_grinder_recipe("default:steel_ingot","technic:iron_dust 1")
-register_grinder_recipe("default:coal_lump","technic:coal_dust 2")
-register_grinder_recipe("default:copper_lump","technic:copper_dust 2")
-register_grinder_recipe("default:copper_ingot","technic:copper_dust 1")
-register_grinder_recipe("default:gold_lump","technic:gold_dust 2")
-register_grinder_recipe("default:gold_ingot","technic:gold_dust 1")
---register_grinder_recipe("default:bronze_ingot","technic:bronze_dust 1")  -- Dust does not exist yet
---register_grinder_recipe("home_decor:brass_ingot","technic:brass_dust 1") -- needs check for the mod
-register_grinder_recipe("moreores:tin_lump","technic:tin_dust 2")
-register_grinder_recipe("moreores:tin_ingot","technic:tin_dust 1")
-register_grinder_recipe("moreores:silver_lump","technic:silver_dust 2")
-register_grinder_recipe("moreores:silver_ingot","technic:silver_dust 1")
-register_grinder_recipe("moreores:mithril_lump","technic:mithril_dust 2")
-register_grinder_recipe("moreores:mithril_ingot","technic:mithril_dust 1")
-register_grinder_recipe("technic:chromium_lump","technic:chromium_dust 2")
-register_grinder_recipe("technic:chromium_ingot","technic:chromium_dust 1")
-register_grinder_recipe("technic:stainless_steel_ingot","stainless_steel_dust 1")
-register_grinder_recipe("group:brass_ingot","technic:brass_dust 1")
-register_grinder_recipe("technic:zinc_lump","technic:zinc_dust 2")
-register_grinder_recipe("technic:zinc_ingot","technic:zinc_dust 1")
-register_grinder_recipe("technic:coal_dust","dye:black 2")
-register_grinder_recipe("default:cactus","dye:green 2")
-register_grinder_recipe("default:dry_shrub","dye:brown 2")
-register_grinder_recipe("flowers:flower_geranium","dye:blue 2")
-register_grinder_recipe("flowers:flower_dandelion_white","dye:white 2")
-register_grinder_recipe("flowers:flower_dandelion_yellow","dye:yellow 2")
-register_grinder_recipe("flowers:flower_tulip","dye:orange 2")
-register_grinder_recipe("flowers:flower_rose","dye:red 2")
-register_grinder_recipe("flowers:flower_viola","dye:violet 2")
-
-minetest.register_craftitem( "technic:coal_dust", {
-       description = "Coal Dust",
-       inventory_image = "technic_coal_dust.png",
-       on_place_on_ground = minetest.craftitem_place_item,
-       })
-
-minetest.register_craftitem( "technic:iron_dust", {
-       description = "Iron Dust",
-       inventory_image = "technic_iron_dust.png",
-       on_place_on_ground = minetest.craftitem_place_item,
-       })
-
-minetest.register_craft({
-    type = "cooking",
-    output = "default:steel_ingot",
-    recipe = "technic:iron_dust",
-})
-
-minetest.register_craftitem( "technic:copper_dust", {
-       description = "Copper Dust",
-       inventory_image = "technic_copper_dust.png",
-       on_place_on_ground = minetest.craftitem_place_item,
-       })
-minetest.register_craft({
-    type = "cooking",
-    output = "moreores:copper_ingot",
-    recipe = "technic:copper_dust",
-})
-
-minetest.register_craftitem( "technic:tin_dust", {
-       description = "Tin Dust",
-       inventory_image = "technic_tin_dust.png",
-       on_place_on_ground = minetest.craftitem_place_item,
-       })
-minetest.register_craft({
-    type = "cooking",
-    output = "moreores:tin_ingot",
-    recipe = "technic:tin_dust",
-})
-
-minetest.register_craftitem( "technic:silver_dust", {
-       description = "Silver Dust",
-       inventory_image = "technic_silver_dust.png",
-       on_place_on_ground = minetest.craftitem_place_item,
-       })
-minetest.register_craft({
-    type = "cooking",
-    output = "moreores:silver_ingot",
-    recipe = "technic:silver_dust",
-})
-
-minetest.register_craftitem( "technic:gold_dust", {
-       description = "Gold Dust",
-       inventory_image = "technic_gold_dust.png",
-       on_place_on_ground = minetest.craftitem_place_item,
-       })
-minetest.register_craft({
-    type = "cooking",
-    output = "moreores:gold_ingot",
-    recipe = "technic:gold_dust",
-})
-
-minetest.register_craftitem( "technic:mithril_dust", {
-       description = "Mithril Dust",
-       inventory_image = "technic_mithril_dust.png",
-       on_place_on_ground = minetest.craftitem_place_item,
-       })
-minetest.register_craft({
-    type = "cooking",
-    output = "moreores:mithril_ingot",
-    recipe = "technic:mithril_dust",
-})
-
-minetest.register_craftitem( "technic:chromium_dust", {
-       description = "Chromium Dust",
-       inventory_image = "technic_chromium_dust.png",
-       on_place_on_ground = minetest.craftitem_place_item,
-       })
-minetest.register_craft({
-    type = "cooking",
-    output = "technic:chromium_ingot",
-    recipe = "technic:chromium_dust",
-})
-
-minetest.register_craftitem( "technic:bronze_dust", {
-       description = "Bronze Dust",
-       inventory_image = "technic_bronze_dust.png",
-       on_place_on_ground = minetest.craftitem_place_item,
-       })
-minetest.register_craft({
-    type = "cooking",
-    output = "moreores:bronze_ingot",
-    recipe = "technic:bronze_dust",
-})
-
-minetest.register_craftitem( "technic:brass_dust", {
-       description = "Brass Dust",
-       inventory_image = "technic_brass_dust.png",
-       on_place_on_ground = minetest.craftitem_place_item,
-       })
-
-minetest.register_craft({
-    type = "cooking",
-    output = "technic:brass_ingot",
-    recipe = "technic:brass_dust",
-})
-
-minetest.register_craftitem( "technic:stainless_steel_dust", {
-       description = "Stainless Steel Dust",
-       inventory_image = "technic_stainless_steel_dust.png",
-       })
-
-minetest.register_craft({
-    type = "cooking",
-    output = "technic:stainless_steel_ingot",
-    recipe = "technic:stainless_steel_dust",
-})
-
-minetest.register_craftitem( "technic:zinc_dust", {
-       description = "Zinc Dust",
-       inventory_image = "technic_zinc_dust.png",
-       })
-
-minetest.register_craft({
-    type = "cooking",
-    output = "technic:zinc_ingot",
-    recipe = "technic:zinc_dust",
-})
-
-minetest.register_alias("grinder", "technic:grinder")
-minetest.register_craft({
-       output = 'technic:grinder',
-       recipe = {
-               {'default:desert_stone', 'default:desert_stone', 'default:desert_stone'},
-               {'default:desert_stone', 'default:diamond', 'default:desert_stone'},
-               {'default:stone', 'moreores:copper_ingot', 'default:stone'},
-       }
-})
-
-minetest.register_craftitem("technic:grinder", {
-       description = "Grinder",
-       stack_max = 99,
-})
-
-grinder_formspec =
-       "invsize[8,9;]"..
-       "image[1,1;1,2;technic_power_meter_bg.png]"..
-       "label[0,0;Grinder]"..
-       "label[1,3;Power level]"..
-       "list[current_name;src;3,1;1,1;]"..
-       "list[current_name;dst;5,1;2,2;]"..
-       "list[current_player;main;0,5;8,4;]"
-
-
-minetest.register_node("technic:grinder", {
-       description = "Grinder",
-       tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
-               "technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
-       paramtype2 = "facedir",
-       groups = {cracky=2},
-       legacy_facedir_simple = true,
-       sounds = default.node_sound_wood_defaults(),
-       technic_power_machine=1,
-       internal_EU_buffer=0;
-       internal_EU_buffer_size=5000;
-       grind_time=0;
-       grinded = nil;
-       src_time = 0;
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_string("infotext", "Grinder")
-               meta:set_float("technic_power_machine", 1)
-               meta:set_float("internal_EU_buffer", 0)
-               meta:set_float("internal_EU_buffer_size", 5000)
-               meta:set_string("formspec", grinder_formspec)
-               meta:set_float("grind_time", 0)
-               local inv = meta:get_inventory()
-               inv:set_size("src", 1)
-               inv:set_size("dst", 4)
-               end,
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               if not inv:is_empty("src") then
-                       return false
-               end
-               if not inv:is_empty("dst") then
-                       return false
-               end
-               return true
-               end,
-})
-
-minetest.register_node("technic:grinder_active", {
-       description = "Grinder",
-       tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
-               "technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front_active.png"},
-       paramtype2 = "facedir",
-       groups = {cracky=2,not_in_creative_inventory=1},
-       legacy_facedir_simple = true,
-       sounds = default.node_sound_wood_defaults(),
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               if not inv:is_empty("src") then
-                       return false
-               end
-               if not inv:is_empty("dst") then
-                       return false
-               end
-               return true
-               end,
-})
-
-minetest.register_abm({
-       nodenames = {"technic:grinder","technic:grinder_active"},
-       interval = 1,
-       chance = 1,
-       action = function(pos, node, active_object_count, active_object_count_wider)
-
-       local meta = minetest.env:get_meta(pos)
-       local charge= meta:get_float("internal_EU_buffer")
-       local max_charge= meta:get_float("internal_EU_buffer_size")
-       local grind_cost=200
-
-       local load = math.floor((charge/max_charge)*100)
-       meta:set_string("formspec",
-                               "invsize[8,9;]"..
-                               "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
-                                               (load)..":technic_power_meter_fg.png]"..
-                               "label[0,0;Grinder]"..
-                               "label[1,3;Power level]"..
-                               "list[current_name;src;3,1;1,1;]"..
-                               "list[current_name;dst;5,1;2,2;]"..
-                               "list[current_player;main;0,5;8,4;]"
-                               )
-
-               local inv = meta:get_inventory()
-               local srclist = inv:get_list("src")
-               if inv:is_empty("src") then meta:set_float("grinder_on",0) end
-
-               if (meta:get_float("grinder_on") == 1) then
-                       if charge>=grind_cost then
-                       charge=charge-grind_cost;
-                       meta:set_float("internal_EU_buffer",charge)
-                       meta:set_float("src_time", meta:get_float("src_time") + 1)
-                       if meta:get_float("src_time") >= meta:get_float("grind_time") then
-                               -- check if there's room for output in "dst" list
-                               grinded = get_grinded_item (inv:get_stack("src", 1))
-                               if inv:room_for_item("dst",grinded) then
-                                       -- Put result in "dst" list
-                                       inv:add_item("dst", grinded)
-                                       -- take stuff from "src" list
-                                       srcstack = inv:get_stack("src", 1)
-                                       srcstack:take_item()
-                                       inv:set_stack("src", 1, srcstack)
-                                       if inv:is_empty("src") then meta:set_float("grinder_on",0) end
-                               else
-                                       print("Grinder inventory full!")
-                               end
-                               meta:set_float("src_time", 0)
-                       end
-                       end
-               end
-               if (meta:get_float("grinder_on")==0) then
-               local grinded=nil
-               if not inv:is_empty("src") then
-                       grinded = get_grinded_item (inv:get_stack("src", 1))
-                       if grinded then
-                               meta:set_float("grinder_on",1)
-                               hacky_swap_node(pos,"technic:grinder_active")
-                               meta:set_string("infotext", "Grinder Active")
-                               grind_time=4
-                               meta:set_float("grind_time",grind_time)
-                               meta:set_float("src_time", 0)
-                               return
-                       end
-                       else
-                               hacky_swap_node(pos,"technic:grinder")
-                               meta:set_string("infotext", "Grinder Inactive")
-               end
-               end
-       end
-})
-
-function get_grinded_item (items)
-new_item =nil
-src_item=items:to_table()
-item_name=src_item["name"]
-
-local counter=registered_grinder_recipes_count-1
-for i=1, counter,1 do
-       if      grinder_recipes[i].src_name==item_name then return ItemStack(grinder_recipes[i].dst_name) end
-end
-return nil
-end
-
-register_LV_machine ("technic:grinder","RE")
-register_LV_machine ("technic:grinder_active","RE")
diff --git a/technic/grinder_gloopores.lua b/technic/grinder_gloopores.lua
deleted file mode 100644 (file)
index 6f603b3..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-technic.register_grinder_recipe("gloopores:alatro_lump","technic:alatro_dust 2")
-technic.register_grinder_recipe("gloopores:kalite_lump","technic:kalite_dust 2")
-technic.register_grinder_recipe("gloopores:arol_lump","technic:arol_dust 2")
-technic.register_grinder_recipe("gloopores:talinite_lump","technic:talinite_dust 2")
-technic.register_grinder_recipe("gloopores:akalin_lump","technic:akalin_dust 2")
- 
-minetest.register_craftitem("technic:alatro_dust", {
-  Â  Â  Â  description = "Alatro Dust",
-  Â  Â  Â  inventory_image = "technic_alatro_dust.png",
-})
- 
-minetest.register_craft({
-  Â  type = "cooking",
-  Â  output = "gloopores:alatro_ingot",
-  Â  recipe = "technic:alatro_dust",
-})
- 
-minetest.register_craftitem("technicplus:arol_dust", {
-  Â  Â  Â  description = "Arol Dust",
-  Â  Â  Â  inventory_image = "technic_arol_dust.png",
-})
- 
-minetest.register_craft({
-  Â  type = "cooking",
-  Â  output = "gloopores:arol_ingot",
-  Â  recipe = "technic:arol_dust",
-})
- 
-minetest.register_craftitem("technic:talinite_dust", {
-  Â  Â  Â  description = "Talinite Dust",
-  Â  Â  Â  inventory_image = "technic_talinite_dust.png",
-})
- 
-minetest.register_craft({
-  Â  type = "cooking",
-  Â  output = "gloopores:talinite_ingot",
-  Â  recipe = "technic:talinite_dust",
-})
- 
-minetest.register_craftitem("technic:akalin_dust", {
-  Â  Â  Â  description = "Akalin Dust",
-  Â  Â  Â  inventory_image = "technic_akalin_dust.png",
-})
- 
-minetest.register_craft({
-  Â  type = "cooking",
-  Â  output = "gloopores:akalin_ingot",
-  Â  recipe = "technic:akalin_dust",
-})
- 
-minetest.register_craftitem("technic:kalite_dust", {
-  Â  Â  Â  description = "Kalite Dust",
-  Â  Â  Â  inventory_image = "technic_kalite_dust.png",
-  Â  Â  Â  on_use = minetest.item_eat(2)
-})
index bc7e628b4fb4b6b9cd26f53425791f649888418d..f30ba7b64ab6c86094d29440888e15ea6ecb8a4f 100644 (file)
@@ -4,14 +4,16 @@
 
 technic = {}
 
+local modpath = minetest.get_modpath("technic")
+
+technic.modpath = modpath
+
 technic.dprint = function(string)
        if technic.DBG == 1 then
                print(string)
        end
 end
 
-local modpath = minetest.get_modpath("technic")
-
 --Read technic config file
 dofile(modpath.."/config.lua")
 --helper functions
@@ -22,65 +24,9 @@ dofile(modpath.."/items.lua")
 
 -- Register functions
 dofile(modpath.."/register_machine_and_tool.lua")
-dofile(modpath.."/alloy_furnaces_commons.lua") -- Idea: Let the LV, MV, HV version of the furnace support different alloys
-
--- Switching station LV,MV,HV
-dofile(modpath.."/switching_station.lua")
-dofile(modpath.."/supply_converter.lua")
-
---LV machines
-dofile(modpath.."/wires.lua")
-dofile(modpath.."/battery_box.lua")
-dofile(modpath.."/alloy_furnace.lua")
-dofile(modpath.."/solar_panel.lua")
-dofile(modpath.."/solar_array_lv.lua")
-dofile(modpath.."/geothermal.lua")
-dofile(modpath.."/water_mill.lua")
-dofile(modpath.."/generator.lua")
-dofile(modpath.."/electric_furnace.lua")
-dofile(modpath.."/tool_workshop.lua")
-dofile(modpath.."/music_player.lua")
-dofile(modpath.."/grinder.lua")
-dofile(modpath.."/cnc.lua")
-dofile(modpath.."/cnc_api.lua")
-dofile(modpath.."/cnc_nodes.lua")
-dofile(modpath.."/extractor.lua")
-
---MV machines
-dofile(modpath.."/wires_mv.lua")
-dofile(modpath.."/battery_box_mv.lua")
-dofile(modpath.."/solar_array_mv.lua")
---dofile(modpath.."/down_converter_mv.lua")
-dofile(modpath.."/electric_furnace_mv.lua")
-dofile(modpath.."/alloy_furnace_mv.lua")
-dofile(modpath.."/forcefield.lua")
----- The power radiator supplies appliances with inductive coupled power:
----- lighting and associated textures is taken directly from VanessaE's homedecor and made electric.
-dofile(modpath.."/power_radiator.lua")
-dofile(modpath.."/lighting.lua")
-
---HV machines
-dofile(modpath.."/wires_hv.lua")
-dofile(modpath.."/battery_box_hv.lua")
-dofile(modpath.."/solar_array_hv.lua")
---dofile(modpath.."/down_converter_hv.lua")
-dofile(modpath.."/nuclear_reactor_hv.lua")
-
---Tools
-if technic.config:getBool("enable_mining_drill") then dofile(modpath.."/mining_drill.lua") end
-if technic.config:getBool("enable_mining_laser") then dofile(modpath.."/mining_laser_mk1.lua") end
-if technic.config:getBool("enable_flashlight") then dofile(modpath.."/flashlight.lua") end
-dofile(modpath.."/cans.lua")
-dofile(modpath.."/chainsaw.lua")
-dofile(modpath.."/tree_tap.lua")
-dofile(modpath.."/sonic_screwdriver.lua")
 
----- mesecons and tubes related
-dofile(modpath.."/injector.lua")
-dofile(modpath.."/node_breaker.lua")
-dofile(modpath.."/deployer.lua")
-dofile(modpath.."/constructor.lua")
-dofile(modpath.."/frames.lua")
+-- Machines
+dofile(modpath.."/machines/init.lua")
 
 function has_locked_chest_privilege(meta, player)
    if player:get_player_name() ~= meta:get_string("owner") then
diff --git a/technic/injector.lua b/technic/injector.lua
deleted file mode 100644 (file)
index c493744..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-minetest.register_craftitem("technic:injector", {
-       description = "Injector",
-       stack_max = 99,
-})
-
-minetest.register_craft({
-       output = 'technic:injector 1',
-       recipe = {
-               {'', 'technic:control_logic_unit',''},
-               {'', 'default:chest',''},
-               {'', 'pipeworks:tube_000000',''},
-       }
-})
-
-minetest.register_node("technic:injector", {
-       description = "Injector",
-       tiles = {"technic_injector_top.png", "technic_injector_bottom.png", "technic_injector_side.png",
-               "technic_injector_side.png", "technic_injector_side.png", "technic_injector_side.png"},
-       groups = chest_groups1,
-       tube = tubes_properties,
-       sounds = default.node_sound_wood_defaults(),
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_string("formspec",
-                               "invsize[8,9;]"..
-                               "label[0,0;Injector]"..
-                               "button[0,1;.8,.8;mode;]"..
-                               "label[.8,1;Mode: single items]"..
-                               "list[current_name;main;0,2;8,2;]"..
-                               "list[current_player;main;0,5;8,4;]")
-               meta:set_string("infotext", "Injector")
-               local inv = meta:get_inventory()
-               inv:set_size("main", 8*4)
-               meta:set_string("mode","single items")
-       end,
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               return inv:is_empty("main")
-       end,
-       on_receive_fields = function(pos, formanme, fields, sender)
-       local meta = minetest.env:get_meta(pos)
-       local mode=meta:get_string("mode")
-       if fields.mode then 
-               if mode=="single items" then mode="whole stacks" 
-                else mode="single items"
-               end
-       local mode=meta:set_string("mode",mode)
-       end
-       meta:set_string("formspec",
-                               "invsize[8,9;]"..
-                               "label[0,0;Injector]"..
-                               "button[0,1;.8,.8;mode;]"..
-                               "label[.8,1;Mode: "..mode.."]"..
-                               "list[current_name;main;0,2;8,2;]"..
-                               "list[current_player;main;0,5;8,4;]")
-       end,
-})
-
-minetest.register_abm({
-       nodenames = {"technic:injector"},
-       interval = 1,
-       chance = 1,
-
-       action = function(pos, node, active_object_count, active_object_count_wider)
-       local pos1={}
-       pos1.x = pos.x
-       pos1.y = pos.y-1
-       pos1.z = pos.z
-       local meta=minetest.env:get_meta(pos1) 
-               if meta:get_int("tubelike")==1 then inject_items (pos) end
-       end,
-})
-
-function inject_items (pos)
-               local meta=minetest.env:get_meta(pos) 
-               local inv = meta:get_inventory()
-               local mode=meta:get_string("mode")
-               if mode=="single items" then
-                       local i=0
-                       for _,stack in ipairs(inv:get_list("main")) do
-                       i=i+1
-                               if stack then
-                               local item0=stack:to_table()
-                               if item0 then 
-                                       item0["count"]="1"
-                                       local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
-                                       item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
-                                       item1:setvelocity({x=0, y=-1, z=0})
-                                       item1:setacceleration({x=0, y=0, z=0})
-                                       stack:take_item(1);
-                                       inv:set_stack("main", i, stack)
-                                       return
-                                       end
-                               end
-                       end
-               end
-               if mode=="whole stacks" then
-                       local i=0
-                       for _,stack in ipairs(inv:get_list("main")) do
-                       i=i+1
-                               if stack then
-                               local item0=stack:to_table()
-                               if item0 then 
-                                       local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
-                                       item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
-                                       item1:setvelocity({x=0, y=-1, z=0})
-                                       item1:setacceleration({x=0, y=0, z=0})
-                                       stack:clear()
-                                       inv:set_stack("main", i, stack)
-                                       return
-                                       end
-                               end
-                       end
-               end
-               
-end
diff --git a/technic/injector1.lua b/technic/injector1.lua
deleted file mode 100644 (file)
index 7de4581..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-minetest.register_craftitem("technic:injector", {
-       description = "Injector",
-       stack_max = 99,
-})
-
-minetest.register_node("technic:injector", {
-       description = "Injector",
-       tiles = {"technic_injector_top.png", "technic_injector_bottom.png", "technic_injector_side.png",
-               "technic_injector_side.png", "technic_injector_side.png", "technic_injector_side.png"},
-       paramtype2 = "facedir",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       legacy_facedir_simple = true,
-       sounds = default.node_sound_wood_defaults(),
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_string("formspec",
-                               "invsize[9,9;]"..
-                               "list[current_name;main;0,2;8,2;]"..
-                               "list[current_player;main;0,5;8,4;]")
-               meta:set_string("infotext", "Injector")
-               local inv = meta:get_inventory()
-               inv:set_size("main", 8*4)
-       end,
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               return inv:is_empty("main")
-       end,
-       on_punch = function (pos, node, puncher)
-       local meta = minetest.env:get_meta(pos);
-       local inv = meta:get_inventory()
-       for _,stack in ipairs(inv:get_list("main")) do
-               if stack:get_name() ~="" then 
-                       inv:remove_item("main",stack)
-                       pos1=pos
-                       pos1.y=pos1.y
-                       local x=pos1.x+1.5
-                       local z=pos1.z
-                       item1=tube_item({x=pos1.x,y=pos1.y,z=pos1.z},stack)
-                       item1:get_luaentity().start_pos = {x=pos1.x,y=pos1.y,z=pos1.z}
-                       item1:setvelocity({x=1, y=0, z=0})
-                       item1:setacceleration({x=0, y=0, z=0})
-                       return
-                       end
-       end
-end,
-})
-
-
-function tube_item(pos, item)
-               local TUBE_nodes = {}
-               local CHEST_nodes = {}
-
-               TUBE_nodes[1]={}
-               TUBE_nodes[1].x=pos.x
-               TUBE_nodes[1].y=pos.y
-               TUBE_nodes[1].z=pos.z
-
-
-table_index=1
-       repeat
-       check_TUBE_node (TUBE_nodes,CHEST_nodes,table_index)
-       table_index=table_index+1
-       if TUBE_nodes[table_index]==nil then break end
-       until false
-found=table_index-1
-
-
-print("Found "..found.." tubes connected")
-print(dump(CHEST_nodes))
-       -- Take item in any format
-       local stack = ItemStack(item)
-       local obj = minetest.env:add_entity(pos, "technic:tubed_item")
-       obj:get_luaentity():set_item(stack:to_string())
-       return obj
-end
-
-minetest.register_entity("technic:tubed_item", {
-       initial_properties = {
-               hp_max = 1,
-               physical = false,
-               collisionbox = {0,0,0,0,0,0},
-               visual = "sprite",
-               visual_size = {x=0.5, y=0.5},
-               textures = {""},
-               spritediv = {x=1, y=1},
-               initial_sprite_basepos = {x=0, y=0},
-               is_visible = false,
-               start_pos={},
-               route={}
-       },
-       
-       itemstring = '',
-       physical_state = false,
-
-       set_item = function(self, itemstring)
-               self.itemstring = itemstring
-               local stack = ItemStack(itemstring)
-               local itemtable = stack:to_table()
-               local itemname = nil
-               if itemtable then
-                       itemname = stack:to_table().name
-               end
-               local item_texture = nil
-               local item_type = ""
-               if minetest.registered_items[itemname] then
-                       item_texture = minetest.registered_items[itemname].inventory_image
-                       item_type = minetest.registered_items[itemname].type
-               end
-               prop = {
-                       is_visible = true,
-                       visual = "sprite",
-                       textures = {"unknown_item.png"}
-               }
-               if item_texture and item_texture ~= "" then
-                       prop.visual = "sprite"
-                       prop.textures = {item_texture}
-                       prop.visual_size = {x=0.3, y=0.3}
-               else
-                       prop.visual = "wielditem"
-                       prop.textures = {itemname}
-                       prop.visual_size = {x=0.15, y=0.15}
-               end
-               self.object:set_properties(prop)
-       end,
-
-       get_staticdata = function(self)
-                       
-                       return  minetest.serialize({
-                               itemstring=self.itemstring,
-                               velocity=self.object:getvelocity(),
-                               start_pos=self.start_pos
-                               })
-       end,
-
-       on_activate = function(self, staticdata)
---             print (dump(staticdata))
-               if  staticdata=="" or staticdata==nil then return end
-               local item = minetest.deserialize(staticdata)
-               local stack = ItemStack(item.itemstring)
-               local itemtable = stack:to_table()
-               local itemname = nil
-               if itemtable then
-                       itemname = stack:to_table().name
-               end
-               
-               if itemname then 
-               self.start_pos=item.start_pos
-               self.object:setvelocity(item.velocity)
-               self.object:setacceleration({x=0, y=0, z=0})
-               self.object:setpos(item.start_pos)
-               end
-               self:set_item(item.itemstring)
-       end,
-
-       on_step = function(self, dtime)
-       if self.start_pos then
-       local pos = self.object:getpos()
-       local node = minetest.env:get_node(pos)
-       local meta = minetest.env:get_meta(pos)
-       tubelike=meta:get_int("tubelike")
-       local stack = ItemStack(self.itemstring)
-       local drop_pos=nil
-               
-       local velocity=self.object:getvelocity()
-       
-       if velocity==nil then print ("wypadl") return end
-
-       if math.abs(velocity.x)==1 then
-               local next_node=math.abs(pos.x-self.start_pos.x)
-               if next_node >= 1 then 
-                       self.start_pos.x=self.start_pos.x+velocity.x
-                       if check_pos_vector (self.start_pos, velocity)==0 then 
-                       if check_next_step (self.start_pos, velocity)==0 then
-                               drop_pos=minetest.env:find_node_near({x=self.start_pos.x,y=self.start_pos.y,z=self.start_pos.z+velocity.x}, 1, "air")
-                               if drop_pos then minetest.item_drop(stack, "", drop_pos) end
-                               self.object:remove()
-                               end
-                       self.object:setpos(self.start_pos)
-                       self.object:setvelocity(velocity)
-                       return
-                       end
-                       end
-               end
-
-       if math.abs(velocity.y)==1 then
-               local next_node=math.abs(pos.y-self.start_pos.y)
-               if next_node >= 1 then 
-                       self.start_pos.y=self.start_pos.y+velocity.y
-                       if check_pos_vector (self.start_pos, velocity)==0 then
-                       if check_next_step (self.start_pos, velocity)==0 then
-                               drop_pos=minetest.env:find_node_near({x=self.start_pos.x+velocity.x,y=self.start_pos.y+velocity.y,z=self.start_pos.z+velocity.z}, 1, "air")
-                               if drop_pos then minetest.item_drop(stack, "", drop_pos) end
-                               self.object:remove()
-                               end
-                       self.object:setpos(self.start_pos)
-                       self.object:setvelocity(velocity)
-                       return 
-                       end
-                       end
-               end
-       
-       if math.abs(velocity.z)==1 then
-               local next_node=math.abs(pos.z-self.start_pos.z)
-               if next_node >= 1 then 
-                       self.start_pos.z=self.start_pos.z+velocity.z
-                       if check_pos_vector (self.start_pos, velocity)==0 then
-                       if check_next_step (self.start_pos, velocity)==0 then
-                               drop_pos=minetest.env:find_node_near({x=self.start_pos.x+velocity.x,y=self.start_pos.y+velocity.y,z=self.start_pos.z+velocity.z}, 1, "air")
-                               if drop_pos then minetest.item_drop(stack, "", drop_pos) end
-                               self.object:remove()
-                               end
-                       self.object:setpos(self.start_pos)
-                       self.object:setvelocity(velocity)
-                       return
-                       end
-                       end
-               end
-       end
-
-end
-})
-
-
-function check_next_step (pos,velocity)
-local meta
-local tubelike
-
-if velocity.x==0 then
-meta = minetest.env:get_meta({x=pos.x-1,y=pos.y,z=pos.z})
-tubelike=meta:get_int("tubelike")
-if tubelike==1 then velocity.x=-1 velocity.y=0 velocity.z=0 return 1 end
-meta = minetest.env:get_meta({x=pos.x+1,y=pos.y,z=pos.z})
-tubelike=meta:get_int("tubelike")
-if tubelike==1 then velocity.x=1 velocity.y=0 velocity.z=0 return 1 end
-end
-
-if velocity.z==0 then
-meta = minetest.env:get_meta({x=pos.x,y=pos.y,z=pos.z+1})
-tubelike=meta:get_int("tubelike")
-if tubelike==1 then velocity.x=0 velocity.y=0 velocity.z=1 return 1 end
-meta = minetest.env:get_meta({x=pos.x,y=pos.y,z=pos.z-1})
-tubelike=meta:get_int("tubelike")
-if tubelike==1 then velocity.x=0 velocity.y=0 velocity.z=-1 return 1 end
-end
-
-if velocity.y==0 then
-meta = minetest.env:get_meta({x=pos.x,y=pos.y+1,z=pos.z})
-tubelike=meta:get_int("tubelike")
-if tubelike==1 then velocity.x=0 velocity.y=1 velocity.z=0 return 1 end
-meta = minetest.env:get_meta({x=pos.x,y=pos.y-1,z=pos.z})
-tubelike=meta:get_int("tubelike")
-if tubelike==1 then velocity.x=0 velocity.y=-1 velocity.z=0 return 1 end
-end
-
-print ("spadl")
-return 0
-end
-
-function check_pos_vector (pos,velocity)
-added={}
-added.x=pos.x+velocity.x
-added.y=pos.y+velocity.y
-added.z=pos.z+velocity.z
-local meta=minetest.env:get_meta(added) 
---print(dump(added).." : "..tubelike)
-if meta:get_int("tubelike")==1 then return 1 end
-return 0
-end
-
-function add_new_TUBE_node (TUBE_nodes,pos1,parent)
-local i=1
-       repeat
-               if TUBE_nodes[i]==nil then break end
-               if pos1.x==TUBE_nodes[i].x and pos1.y==TUBE_nodes[i].y and pos1.z==TUBE_nodes[i].z then return false end
-               i=i+1
-       until false
-TUBE_nodes[i]={}
-TUBE_nodes[i].x=pos1.x
-TUBE_nodes[i].y=pos1.y
-TUBE_nodes[i].z=pos1.z
-TUBE_nodes[i].parent_x=parent.x
-TUBE_nodes[i].parent_y=parent.y
-TUBE_nodes[i].parent_z=parent.z
-
-return true
-end
-
-function check_TUBE_node (TUBE_nodes,CHEST_nodes,i)
-               local pos1={}
-               local parent={}
-               pos1.x=TUBE_nodes[i].x
-               pos1.y=TUBE_nodes[i].y
-               pos1.z=TUBE_nodes[i].z
-               parent.x=pos1.x
-               parent.y=pos1.y
-               parent.z=pos1.z
-               new_node_added=false
-       
-               pos1.x=pos1.x+1
-               check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
-               pos1.x=pos1.x-2
-               check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
-               pos1.x=pos1.x+1
-               
-               pos1.y=pos1.y+1
-               check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
-               pos1.y=pos1.y-2
-               check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
-               pos1.y=pos1.y+1
-
-               pos1.z=pos1.z+1
-               check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
-               pos1.z=pos1.z-2
-               check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
-               pos1.z=pos1.z+1
-return new_node_added
-end
-
-function check_TUBE_node_subp (TUBE_nodes,CHEST_nodes,pos1,parent)
-meta = minetest.env:get_meta(pos1)
-if meta:get_float("tubelike")==1 then add_new_TUBE_node(TUBE_nodes,pos1,parent) return end
-nctr = minetest.env:get_node(pos1)
-if minetest.get_item_group(nctr.name, "tubedevice_receiver") == 1 then add_new_TUBE_node(CHEST_nodes,pos1,parent) return end
-end
-
diff --git a/technic/lighting.lua b/technic/lighting.lua
deleted file mode 100644 (file)
index 546e42c..0000000
+++ /dev/null
@@ -1,590 +0,0 @@
--- NOTE: The code is takes directly from VanessaE's homedecor mod.
--- I just made it the lights into indictive appliances for this mod.
-
--- This file supplies electric powered glowlights
-
--- Boilerplate to support localized strings if intllib mod is installed.
-local S
-if (minetest.get_modpath("intllib")) then
-    dofile(minetest.get_modpath("intllib").."/intllib.lua")
-    S = intllib.Getter(minetest.get_current_modname())
-else
-    S = function ( s ) return s end
-end
-
-function technic_homedecor_node_is_owned(pos, placer)
-        local ownername = false
-        if type(IsPlayerNodeOwner) == "function" then                                   -- node_ownership mod
-                if HasOwner(pos, placer) then                                           -- returns true if the node is owned
-                        if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
-                                if type(getLastOwner) == "function" then                -- ...is an old version
-                                        ownername = getLastOwner(pos)
-                                elseif type(GetNodeOwnerName) == "function" then        -- ...is a recent version
-                                        ownername = GetNodeOwnerName(pos)
-                                else
-                                        ownername = S("someone")
-                                end
-                        end
-                end
-
-        elseif type(isprotect)=="function" then                                         -- glomie's protection mod
-                if not isprotect(5, pos, placer) then
-                        ownername = S("someone")
-                end
-        elseif type(protector)=="table" and type(protector.can_dig)=="function" then                                    -- Zeg9's protection mod
-                if not protector.can_dig(5, pos, placer) then
-                        ownername = S("someone")
-                end
-        end
-
-        if ownername ~= false then
-                minetest.chat_send_player( placer:get_player_name(), S("Sorry, %s owns that spot."):format(ownername) )
-                return true
-        else
-                return false
-        end
-end
-
-local dirs1 = { 20, 23, 22, 21 }
-local dirs2 = { 9, 18, 7, 12 }
-
-local technic_homedecor_rotate_and_place = function(itemstack, placer, pointed_thing)
-       if not technic_homedecor_node_is_owned(pointed_thing.under, placer) 
-          and not technic_homedecor_node_is_owned(pointed_thing.above, placer) then
-               local node = minetest.env:get_node(pointed_thing.under)
-               if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
-
-                       local above = pointed_thing.above
-                       local under = pointed_thing.under
-                       local pitch = placer:get_look_pitch()
-                       local pname = minetest.env:get_node(under).name
-                       local node = minetest.env:get_node(above)
-                       local fdir = minetest.dir_to_facedir(placer:get_look_dir())
-                       local wield_name = itemstack:get_name()
-
-                       if not minetest.registered_nodes[pname]
-                           or not minetest.registered_nodes[pname].on_rightclick then
-
-                               local iswall = (above.x ~= under.x) or (above.z ~= under.z)
-                               local isceiling = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
-                               local pos1 = above
-
-                               if minetest.registered_nodes[pname]["buildable_to"] then
-                                       pos1 = under
-                                       iswall = false
-                               end
-
-                               if not minetest.registered_nodes[minetest.env:get_node(pos1).name]["buildable_to"] then return end
-
-                               if iswall then 
-                                       minetest.env:add_node(pos1, {name = wield_name, param2 = dirs2[fdir+1] }) -- place wall variant
-                               elseif isceiling then
-                                       minetest.env:add_node(pos1, {name = wield_name, param2 = 20 }) -- place upside down variant
-                               else
-                                       minetest.env:add_node(pos1, {name = wield_name, param2 = 0 }) -- place right side up
-                               end
-
-                               if not homedecor_expect_infinite_stacks then
-                                       itemstack:take_item()
-                                       return itemstack
-                               end
-                       end
-               else
-                       minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack)
-               end
-       end
-end
-
--- Yellow -- Half node
-minetest.register_node('technic:homedecor_glowlight_half_yellow', {
-       description = S("Yellow Glowlight (thick)"),
-       drawtype = "nodebox",
-       tiles = {
-               'technic_homedecor_glowlight_yellow_tb.png',
-               'technic_homedecor_glowlight_yellow_tb.png',
-               'technic_homedecor_glowlight_thick_yellow_sides.png',
-               'technic_homedecor_glowlight_thick_yellow_sides.png',
-               'technic_homedecor_glowlight_thick_yellow_sides.png',
-               'technic_homedecor_glowlight_thick_yellow_sides.png'
-       },
-        selection_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
-        },
-        node_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
-        },
-
-       sunlight_propagates = false,
-       paramtype = "light",
-       paramtype2 = "facedir",
-       walkable = true,
-       sounds = default.node_sound_wood_defaults(),
-
-       groups = { snappy = 3 },
-       on_place = function(itemstack, placer, pointed_thing)
-               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
-               return itemstack
-            end,
-       on_construct = function(pos)
-                         technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thick)")
-                      end,
-       on_punch = function(pos, node, puncher)
-                     technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_half_yellow_active")
-                  end
-})
-
-minetest.register_node('technic:homedecor_glowlight_half_yellow_active', {
-       description = S("Yellow Glowlight (thick)"),
-       drawtype = "nodebox",
-       tiles = {
-               'technic_homedecor_glowlight_yellow_tb.png',
-               'technic_homedecor_glowlight_yellow_tb.png',
-               'technic_homedecor_glowlight_thick_yellow_sides.png',
-               'technic_homedecor_glowlight_thick_yellow_sides.png',
-               'technic_homedecor_glowlight_thick_yellow_sides.png',
-               'technic_homedecor_glowlight_thick_yellow_sides.png'
-       },
-        selection_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
-        },
-        node_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
-        },
-
-       sunlight_propagates = false,
-       paramtype = "light",
-       paramtype2 = "facedir",
-       walkable = true,
-       light_source = LIGHT_MAX,
-       sounds = default.node_sound_wood_defaults(),
-
-       groups = { snappy = 3, not_in_creative_inventory=1},
-       drop="technic:homedecor_glowlight_half_yellow",
-       on_place = function(itemstack, placer, pointed_thing)
-               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
-               return itemstack
-            end,
-       on_construct = function(pos)
-                         technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thick)")
-                      end,
-       on_punch = function(pos, node, puncher)
-                     technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_half_yellow")
-                  end
-})
-
--- Yellow -- Quarter node
-minetest.register_node('technic:homedecor_glowlight_quarter_yellow', {
-       description = S("Yellow Glowlight (thin)"),
-       drawtype = "nodebox",
-       tiles = {
-               'technic_homedecor_glowlight_yellow_tb.png',
-               'technic_homedecor_glowlight_yellow_tb.png',
-               'technic_homedecor_glowlight_thin_yellow_sides.png',
-               'technic_homedecor_glowlight_thin_yellow_sides.png',
-               'technic_homedecor_glowlight_thin_yellow_sides.png',
-               'technic_homedecor_glowlight_thin_yellow_sides.png'
-       },
-        selection_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
-        },
-        node_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
-        },
-
-       sunlight_propagates = false,
-       paramtype = "light",
-       paramtype2 = "facedir",
-       walkable = true,
-       sounds = default.node_sound_wood_defaults(),
-
-       groups = { snappy = 3 },
-       on_place = function(itemstack, placer, pointed_thing)
-               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
-               return itemstack
-            end,
-       on_construct = function(pos)
-                         technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thin)")
-                      end,
-       on_punch = function(pos, node, puncher)
-                     technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_quarter_yellow_active")
-                  end
-})
-
-minetest.register_node('technic:homedecor_glowlight_quarter_yellow_active', {
-       description = S("Yellow Glowlight (thin)"),
-       drawtype = "nodebox",
-       tiles = {
-               'technic_homedecor_glowlight_yellow_tb.png',
-               'technic_homedecor_glowlight_yellow_tb.png',
-               'technic_homedecor_glowlight_thin_yellow_sides.png',
-               'technic_homedecor_glowlight_thin_yellow_sides.png',
-               'technic_homedecor_glowlight_thin_yellow_sides.png',
-               'technic_homedecor_glowlight_thin_yellow_sides.png'
-       },
-        selection_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
-        },
-        node_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
-        },
-
-       sunlight_propagates = false,
-       paramtype = "light",
-       paramtype2 = "facedir",
-       walkable = true,
-       light_source = LIGHT_MAX-1,
-       sounds = default.node_sound_wood_defaults(),
-
-       groups = { snappy = 3, not_in_creative_inventory=1},
-       drop="technic:homedecor_glowlight_quarter_yellow",
-       on_place = function(itemstack, placer, pointed_thing)
-               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
-               return itemstack
-            end,
-       on_construct = function(pos)
-                         technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thin)")
-                      end,
-       on_punch = function(pos, node, puncher)
-                     technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_quarter_yellow")
-                  end
-})
-
-
--- White -- half node
-minetest.register_node('technic:homedecor_glowlight_half_white', {
-       description = S("White Glowlight (thick)"),
-       drawtype = "nodebox",
-       tiles = {
-               'technic_homedecor_glowlight_white_tb.png',
-               'technic_homedecor_glowlight_white_tb.png',
-               'technic_homedecor_glowlight_thick_white_sides.png',
-               'technic_homedecor_glowlight_thick_white_sides.png',
-               'technic_homedecor_glowlight_thick_white_sides.png',
-               'technic_homedecor_glowlight_thick_white_sides.png'
-       },
-        selection_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
-        },
-        node_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
-        },
-
-       sunlight_propagates = false,
-       paramtype = "light",
-       paramtype2 = "facedir",
-       walkable = true,
-       sounds = default.node_sound_wood_defaults(),
-
-       groups = { snappy = 3 },
-       on_place = function(itemstack, placer, pointed_thing)
-               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
-               return itemstack
-            end,
-       on_construct = function(pos)
-                         technic.inductive_on_construct(pos, 100, "White Glowlight (thick)")
-                      end,
-       on_punch = function(pos, node, puncher)
-                     technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_half_white_active")
-                  end
-})
-
-minetest.register_node('technic:homedecor_glowlight_half_white_active', {
-       description = S("White Glowlight (thick)"),
-       drawtype = "nodebox",
-       tiles = {
-               'technic_homedecor_glowlight_white_tb.png',
-               'technic_homedecor_glowlight_white_tb.png',
-               'technic_homedecor_glowlight_thick_white_sides.png',
-               'technic_homedecor_glowlight_thick_white_sides.png',
-               'technic_homedecor_glowlight_thick_white_sides.png',
-               'technic_homedecor_glowlight_thick_white_sides.png'
-       },
-        selection_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
-        },
-        node_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
-        },
-
-       sunlight_propagates = false,
-       paramtype = "light",
-       paramtype2 = "facedir",
-       walkable = true,
-       light_source = LIGHT_MAX,
-       sounds = default.node_sound_wood_defaults(),
-
-       groups = { snappy = 3, not_in_creative_inventory=1},
-       drop="technic:homedecor_glowlight_half_white",
-       on_place = function(itemstack, placer, pointed_thing)
-               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
-               return itemstack
-            end,
-       on_construct = function(pos)
-                         technic.inductive_on_construct(pos, 100, "White Glowlight (thick)")
-                      end,
-       on_punch = function(pos, node, puncher)
-                     technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_half_white")
-                  end
-})
-
--- White -- Quarter node
-minetest.register_node('technic:homedecor_glowlight_quarter_white', {
-       description = S("White Glowlight (thin)"),
-       drawtype = "nodebox",
-       tiles = {
-               'technic_homedecor_glowlight_white_tb.png',
-               'technic_homedecor_glowlight_white_tb.png',
-               'technic_homedecor_glowlight_thin_white_sides.png',
-               'technic_homedecor_glowlight_thin_white_sides.png',
-               'technic_homedecor_glowlight_thin_white_sides.png',
-               'technic_homedecor_glowlight_thin_white_sides.png'
-       },
-        selection_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
-        },
-        node_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
-        },
-
-       sunlight_propagates = false,
-       paramtype = "light",
-       paramtype2 = "facedir",
-       walkable = true,
-       sounds = default.node_sound_wood_defaults(),
-
-       groups = { snappy = 3 },
-       on_place = function(itemstack, placer, pointed_thing)
-               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
-               return itemstack
-            end,
-       on_construct = function(pos)
-                         technic.inductive_on_construct(pos, 100, "White Glowlight (thin)")
-                      end,
-       on_punch = function(pos, node, puncher)
-                     technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_quarter_white_active")
-                  end
-})
-
-minetest.register_node('technic:homedecor_glowlight_quarter_white_active', {
-       description = S("White Glowlight (thin)"),
-       drawtype = "nodebox",
-       tiles = {
-               'technic_homedecor_glowlight_white_tb.png',
-               'technic_homedecor_glowlight_white_tb.png',
-               'technic_homedecor_glowlight_thin_white_sides.png',
-               'technic_homedecor_glowlight_thin_white_sides.png',
-               'technic_homedecor_glowlight_thin_white_sides.png',
-               'technic_homedecor_glowlight_thin_white_sides.png'
-       },
-        selection_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
-        },
-        node_box = {
-                type = "fixed",
-                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
-        },
-
-       sunlight_propagates = false,
-       paramtype = "light",
-       paramtype2 = "facedir",
-       walkable = true,
-       light_source = LIGHT_MAX-1,
-       sounds = default.node_sound_wood_defaults(),
-
-       groups = { snappy = 3, not_in_creative_inventory=1},
-       drop="technic:homedecor_glowlight_quarter_white",
-       on_place = function(itemstack, placer, pointed_thing)
-               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
-               return itemstack
-            end,
-       on_construct = function(pos)
-                         technic.inductive_on_construct(pos, 100, "White Glowlight (thin)")
-                      end,
-       on_punch = function(pos, node, puncher)
-                     technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_quarter_white")
-                  end
-})
-
--- Glowlight "cubes" - yellow
-minetest.register_node('technic:homedecor_glowlight_small_cube_yellow', {
-       description = S("Yellow Glowlight (small cube)"),
-       drawtype = "nodebox",
-       tiles = {
-               'technic_homedecor_glowlight_cube_yellow_tb.png',
-               'technic_homedecor_glowlight_cube_yellow_tb.png',
-               'technic_homedecor_glowlight_cube_yellow_sides.png',
-               'technic_homedecor_glowlight_cube_yellow_sides.png',
-               'technic_homedecor_glowlight_cube_yellow_sides.png',
-               'technic_homedecor_glowlight_cube_yellow_sides.png'
-       },
-        selection_box = {
-                type = "fixed",
-                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
-        },
-        node_box = {
-                type = "fixed",
-                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
-        },
-
-       sunlight_propagates = false,
-       paramtype = "light",
-       paramtype2 = "facedir",
-       walkable = true,
-       sounds = default.node_sound_wood_defaults(),
-
-       groups = { snappy = 3 },
-       on_place = function(itemstack, placer, pointed_thing)
-               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
-               return itemstack
-            end,
-       on_construct = function(pos)
-                         technic.inductive_on_construct(pos, 50, "Yellow Glowlight (small cube)")
-                      end,
-       on_punch = function(pos, node, puncher)
-                     technic.inductive_on_punch_off(pos, 50, "technic:homedecor_glowlight_small_cube_yellow_active")
-                  end
-})
-
-minetest.register_node('technic:homedecor_glowlight_small_cube_yellow_active', {
-       description = S("Yellow Glowlight (small cube)"),
-       drawtype = "nodebox",
-       tiles = {
-               'technic_homedecor_glowlight_cube_yellow_tb.png',
-               'technic_homedecor_glowlight_cube_yellow_tb.png',
-               'technic_homedecor_glowlight_cube_yellow_sides.png',
-               'technic_homedecor_glowlight_cube_yellow_sides.png',
-               'technic_homedecor_glowlight_cube_yellow_sides.png',
-               'technic_homedecor_glowlight_cube_yellow_sides.png'
-       },
-        selection_box = {
-                type = "fixed",
-                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
-        },
-        node_box = {
-                type = "fixed",
-                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
-        },
-
-       sunlight_propagates = false,
-       paramtype = "light",
-       paramtype2 = "facedir",
-       walkable = true,
-       light_source = LIGHT_MAX-1,
-       sounds = default.node_sound_wood_defaults(),
-
-       groups = { snappy = 3, not_in_creative_inventory=1},
-       drop="technic:homedecor_glowlight_small_cube_yellow",
-       on_place = function(itemstack, placer, pointed_thing)
-               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
-               return itemstack
-            end,
-       on_construct = function(pos)
-                         technic.inductive_on_construct(pos, 50, "Yellow Glowlight (small cube)")
-                      end,
-       on_punch = function(pos, node, puncher)
-                     technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_small_cube_yellow")
-                  end
-})
-
--- Glowlight "cubes" - white
-minetest.register_node('technic:homedecor_glowlight_small_cube_white', {
-       description = S("White Glowlight (small cube)"),
-       drawtype = "nodebox",
-       tiles = {
-               'technic_homedecor_glowlight_cube_white_tb.png',
-               'technic_homedecor_glowlight_cube_white_tb.png',
-               'technic_homedecor_glowlight_cube_white_sides.png',
-               'technic_homedecor_glowlight_cube_white_sides.png',
-               'technic_homedecor_glowlight_cube_white_sides.png',
-               'technic_homedecor_glowlight_cube_white_sides.png'
-       },
-        selection_box = {
-                type = "fixed",
-                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
-        },
-        node_box = {
-                type = "fixed",
-                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
-        },
-
-       sunlight_propagates = false,
-       paramtype = "light",
-       paramtype2 = "facedir",
-       walkable = true,
-       sounds = default.node_sound_wood_defaults(),
-
-       groups = { snappy = 3 },
-       on_place = function(itemstack, placer, pointed_thing)
-               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
-               return itemstack
-            end,
-       on_construct = function(pos)
-                         technic.inductive_on_construct(pos, 50, "White Glowlight (small cube)")
-                      end,
-       on_punch = function(pos, node, puncher)
-                     technic.inductive_on_punch_off(pos, 50, "technic:homedecor_glowlight_small_cube_white_active")
-                  end
-})
-
-minetest.register_node('technic:homedecor_glowlight_small_cube_white_active', {
-       description = S("White Glowlight (small cube)"),
-       drawtype = "nodebox",
-       tiles = {
-               'technic_homedecor_glowlight_cube_white_tb.png',
-               'technic_homedecor_glowlight_cube_white_tb.png',
-               'technic_homedecor_glowlight_cube_white_sides.png',
-               'technic_homedecor_glowlight_cube_white_sides.png',
-               'technic_homedecor_glowlight_cube_white_sides.png',
-               'technic_homedecor_glowlight_cube_white_sides.png'
-       },
-        selection_box = {
-                type = "fixed",
-                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
-        },
-        node_box = {
-                type = "fixed",
-                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
-        },
-
-       sunlight_propagates = false,
-       paramtype = "light",
-       paramtype2 = "facedir",
-       walkable = true,
-       light_source = LIGHT_MAX-1,
-       sounds = default.node_sound_wood_defaults(),
-
-       groups = { snappy = 3, not_in_creative_inventory=1},
-       drop="technic:homedecor_glowlight_small_cube_white",
-       on_place = function(itemstack, placer, pointed_thing)
-               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
-               return itemstack
-            end,
-       on_construct = function(pos)
-                         technic.inductive_on_construct(pos, 50, "White Glowlight (small cube)")
-                      end,
-       on_punch = function(pos, node, puncher)
-                     technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_small_cube_white")
-                  end
-})
-
-technic.register_inductive_machine("technic:homedecor_glowlight_half_yellow")
-technic.register_inductive_machine("technic:homedecor_glowlight_half_white")
-technic.register_inductive_machine("technic:homedecor_glowlight_quarter_yellow")
-technic.register_inductive_machine("technic:homedecor_glowlight_quarter_white")
-technic.register_inductive_machine("technic:homedecor_glowlight_small_cube_yellow")
-technic.register_inductive_machine("technic:homedecor_glowlight_small_cube_white")
diff --git a/technic/machines/alloy_furnaces_commons.lua b/technic/machines/alloy_furnaces_commons.lua
new file mode 100644 (file)
index 0000000..15996d0
--- /dev/null
@@ -0,0 +1,85 @@
+-- Register alloy recipes
+technic.alloy_recipes = {}
+
+-- Register recipe in a table
+technic.register_alloy_recipe = function(metal1, count1, metal2, count2, result, count3)
+                                  technic.alloy_recipes[metal1..metal2] = { src1_count = count1, src2_count = count2, dst_name = result, dst_count = count3 }
+                                  if unified_inventory then
+                                     unified_inventory.register_craft(
+                                        {
+                                           type = "alloy",
+                                           output = result.." "..count3,
+                                           items = {metal1.." "..count1,metal2.." "..count2},
+                                           width = 2,
+                                        })
+                                  end
+                               end
+
+-- Retrieve a recipe given the input metals.
+-- Input parameters are a table from a StackItem
+technic.get_alloy_recipe = function(metal1, metal2)
+                             -- Check for both combinations of metals and for the right amount in both
+                             if technic.alloy_recipes[metal1.name..metal2.name]
+                                and metal1.count >= technic.alloy_recipes[metal1.name..metal2.name].src1_count
+                                and metal2.count >= technic.alloy_recipes[metal1.name..metal2.name].src2_count then
+                                return technic.alloy_recipes[metal1.name..metal2.name]
+                             elseif technic.alloy_recipes[metal2.name..metal1.name]
+                                and metal2.count >= technic.alloy_recipes[metal2.name..metal1.name].src1_count
+                                and metal1.count >= technic.alloy_recipes[metal2.name..metal1.name].src2_count then
+                                return technic.alloy_recipes[metal2.name..metal1.name]
+                             else
+                                return nil
+                             end
+                          end
+
+technic.register_alloy_recipe("technic:copper_dust",  3, "technic:tin_dust",      1, "technic:bronze_dust",          4)
+technic.register_alloy_recipe("moreores:copper_ingot",3, "moreores:tin_ingot",    1, "moreores:bronze_ingot",        4)
+technic.register_alloy_recipe("technic:iron_dust",    3, "technic:chromium_dust", 1, "technic:stainless_steel_dust", 4)
+technic.register_alloy_recipe("default:steel_ingot",  3, "technic:chromium_ingot",1, "technic:stainless_steel_ingot",4)
+technic.register_alloy_recipe("technic:copper_dust",  2, "technic:zinc_dust",     1, "technic:brass_dust",           3)
+technic.register_alloy_recipe("moreores:copper_ingot",2, "technic:zinc_ingot",    1, "technic:brass_ingot",          3)
+technic.register_alloy_recipe("default:sand",         2, "technic:coal_dust",     2, "technic:silicon_wafer",        1)
+technic.register_alloy_recipe("technic:silicon_wafer",1, "technic:gold_dust",     1, "technic:doped_silicon_wafer",  1)
+
+--------------------------------------
+-- LEGACY CODE - some other mods might depend on this - Register the same recipes as above...
+--------------------------------------
+alloy_recipes = {}
+registered_recipes_count = 1
+
+function register_alloy_recipe (string1,count1, string2,count2, string3,count3)
+   alloy_recipes[registered_recipes_count]={}
+   alloy_recipes[registered_recipes_count].src1_name=string1
+   alloy_recipes[registered_recipes_count].src1_count=count1
+   alloy_recipes[registered_recipes_count].src2_name=string2
+   alloy_recipes[registered_recipes_count].src2_count=count2
+   alloy_recipes[registered_recipes_count].dst_name=string3
+   alloy_recipes[registered_recipes_count].dst_count=count3
+   registered_recipes_count=registered_recipes_count+1
+   alloy_recipes[registered_recipes_count]={}
+   alloy_recipes[registered_recipes_count].src1_name=string2
+   alloy_recipes[registered_recipes_count].src1_count=count2
+   alloy_recipes[registered_recipes_count].src2_name=string1
+   alloy_recipes[registered_recipes_count].src2_count=count1
+   alloy_recipes[registered_recipes_count].dst_name=string3
+   alloy_recipes[registered_recipes_count].dst_count=count3
+   registered_recipes_count=registered_recipes_count+1
+   if unified_inventory then
+      unified_inventory.register_craft({
+                 type = "alloy",
+                 output = string3.." "..count3,
+                 items = {string1.." "..count1,string2.." "..count2},
+                 width = 2,
+              })
+   end
+end
+
+register_alloy_recipe ("technic:copper_dust",3, "technic:tin_dust",1, "technic:bronze_dust",4)
+register_alloy_recipe ("default:copper_ingot",3, "moreores:tin_ingot",1, "default:bronze_ingot",4)
+register_alloy_recipe ("technic:iron_dust",3, "technic:chromium_dust",1, "technic:stainless_steel_dust",4)
+register_alloy_recipe ("default:steel_ingot",3, "technic:chromium_ingot",1, "technic:stainless_steel_ingot",4)
+register_alloy_recipe ("technic:copper_dust",2, "technic:zinc_dust",1, "technic:brass_dust",3)
+register_alloy_recipe ("default:copper_ingot",2, "technic:zinc_ingot",1, "technic:brass_ingot",3)
+register_alloy_recipe ("default:sand",2, "technic:coal_dust",2, "technic:silicon_wafer",1)
+register_alloy_recipe ("technic:silicon_wafer",1, "technic:gold_dust",1, "technic:doped_silicon_wafer",1)
+
diff --git a/technic/machines/grinder_gloopores.lua b/technic/machines/grinder_gloopores.lua
new file mode 100644 (file)
index 0000000..6f603b3
--- /dev/null
@@ -0,0 +1,55 @@
+technic.register_grinder_recipe("gloopores:alatro_lump","technic:alatro_dust 2")
+technic.register_grinder_recipe("gloopores:kalite_lump","technic:kalite_dust 2")
+technic.register_grinder_recipe("gloopores:arol_lump","technic:arol_dust 2")
+technic.register_grinder_recipe("gloopores:talinite_lump","technic:talinite_dust 2")
+technic.register_grinder_recipe("gloopores:akalin_lump","technic:akalin_dust 2")
+ 
+minetest.register_craftitem("technic:alatro_dust", {
+  Â  Â  Â  description = "Alatro Dust",
+  Â  Â  Â  inventory_image = "technic_alatro_dust.png",
+})
+ 
+minetest.register_craft({
+  Â  type = "cooking",
+  Â  output = "gloopores:alatro_ingot",
+  Â  recipe = "technic:alatro_dust",
+})
+ 
+minetest.register_craftitem("technicplus:arol_dust", {
+  Â  Â  Â  description = "Arol Dust",
+  Â  Â  Â  inventory_image = "technic_arol_dust.png",
+})
+ 
+minetest.register_craft({
+  Â  type = "cooking",
+  Â  output = "gloopores:arol_ingot",
+  Â  recipe = "technic:arol_dust",
+})
+ 
+minetest.register_craftitem("technic:talinite_dust", {
+  Â  Â  Â  description = "Talinite Dust",
+  Â  Â  Â  inventory_image = "technic_talinite_dust.png",
+})
+ 
+minetest.register_craft({
+  Â  type = "cooking",
+  Â  output = "gloopores:talinite_ingot",
+  Â  recipe = "technic:talinite_dust",
+})
+ 
+minetest.register_craftitem("technic:akalin_dust", {
+  Â  Â  Â  description = "Akalin Dust",
+  Â  Â  Â  inventory_image = "technic_akalin_dust.png",
+})
+ 
+minetest.register_craft({
+  Â  type = "cooking",
+  Â  output = "gloopores:akalin_ingot",
+  Â  recipe = "technic:akalin_dust",
+})
+ 
+minetest.register_craftitem("technic:kalite_dust", {
+  Â  Â  Â  description = "Kalite Dust",
+  Â  Â  Â  inventory_image = "technic_kalite_dust.png",
+  Â  Â  Â  on_use = minetest.item_eat(2)
+})
diff --git a/technic/machines/hv/battery_box.lua b/technic/machines/hv/battery_box.lua
new file mode 100644 (file)
index 0000000..979dc13
--- /dev/null
@@ -0,0 +1,231 @@
+-- HV battery box
+minetest.register_craft(
+   {output = 'technic:hv_battery_box 1',
+    recipe = {
+       {'technic:mv_battery_box', 'technic:mv_battery_box', 'technic:mv_battery_box'},
+       {'technic:mv_battery_box', 'technic:hv_transformer', 'technic:mv_battery_box'},
+       {'', 'technic:hv_cable', ''},
+    }
+ })
+
+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;]"
+
+minetest.register_node(
+   "technic:hv_battery_box", {
+      description = "HV Battery Box",
+      tiles = {"technic_hv_battery_box_top.png", "technic_hv_battery_box_bottom.png", "technic_hv_battery_box_side0.png",
+              "technic_hv_battery_box_side0.png", "technic_hv_battery_box_side0.png", "technic_hv_battery_box_side0.png"},
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+      sounds = default.node_sound_wood_defaults(),
+      drop="technic:hv_battery_box",
+      on_construct = function(pos)
+                       local meta = minetest.env:get_meta(pos)
+                       local inv = meta:get_inventory()
+                       meta:set_string("infotext", "HV Battery Box")
+                       meta:set_float("technic_hv_power_machine", 1)
+                       meta:set_string("formspec", battery_box_formspec)
+                       meta:set_int("HV_EU_demand", 0) -- How much can this node charge
+                       meta:set_int("HV_EU_supply", 0) -- How much can this node discharge
+                       meta:set_int("HV_EU_input",  0) -- How much power is this machine getting.
+                       meta:set_float("internal_EU_charge", 0)
+                       inv:set_size("src", 1)
+                       inv:set_size("dst", 1)
+                    end,
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") or not inv:is_empty("dst") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  else
+                     return true
+                  end
+               end,
+   })
+
+for i=1,8,1 do
+   minetest.register_node(
+      "technic:hv_battery_box"..i,
+      {description = "HV Battery Box",
+       tiles = {"technic_hv_battery_box_top.png", "technic_hv_battery_box_bottom.png", "technic_hv_battery_box_side0.png^technic_power_meter"..i..".png",
+               "technic_hv_battery_box_side0.png^technic_power_meter"..i..".png", "technic_hv_battery_box_side0.png^technic_power_meter"..i..".png", "technic_hv_battery_box_side0.png^technic_power_meter"..i..".png"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
+       sounds = default.node_sound_wood_defaults(),
+       paramtype="light",
+       light_source=9,
+       drop="technic:hv_battery_box",
+       can_dig = function(pos,player)
+                   local meta = minetest.env:get_meta(pos);
+                   local inv = meta:get_inventory()
+                   if not inv:is_empty("src") or not inv:is_empty("dst") then
+                      minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                      return false
+                   else
+                      return true
+                   end
+                end,
+    })
+end
+
+local power_tools = technic.HV_power_tools
+
+local charge_HV_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_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 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_HV_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_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 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:hv_battery_box","technic:hv_battery_box1","technic:hv_battery_box2","technic:hv_battery_box3","technic:hv_battery_box4",
+                "technic:hv_battery_box5","technic:hv_battery_box6","technic:hv_battery_box7","technic:hv_battery_box8"
+             },
+    interval = 1,
+    chance   = 1,
+    action = function(pos, node, active_object_count, active_object_count_wider)
+               local meta               = minetest.env:get_meta(pos)
+               local max_charge         = 1500000 -- Set maximum charge for the device here
+               local max_charge_rate    = 3000    -- Set maximum rate of charging
+               local max_discharge_rate = 5000    -- Set maximum rate of discharging (16000)
+               local eu_input           = meta:get_int("HV_EU_input")
+               local current_charge     = meta:get_int("internal_EU_charge") -- Battery charge right now
+
+               -- Power off automatically if no longer connected to a switching station
+               technic.switching_station_timeout_count(pos, "HV")
+
+               -- Charge/discharge the battery with the input EUs
+               if eu_input >=0 then
+                  current_charge = math.min(current_charge+eu_input, max_charge)
+               else
+                  current_charge = math.max(current_charge+eu_input, 0)
+               end
+
+               -- Charging/discharging tools here
+               current_charge = charge_HV_tools(meta, current_charge)
+               current_charge = discharge_HV_tools(meta, current_charge, max_charge)
+
+               -- 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))
+
+               -- Set how much we can supply
+               meta:set_int("HV_EU_supply", math.min(max_discharge_rate, current_charge))
+
+               meta:set_int("internal_EU_charge", current_charge)
+               --dprint("BA: input:"..eu_input.." supply="..meta:get_int("HV_EU_supply").." demand="..meta:get_int("HV_EU_demand").." current:"..current_charge)
+
+               -- Select node textures
+               local i=math.ceil((current_charge/max_charge)*8)
+               if i > 8 then i = 8 end
+               local j = meta:get_float("last_side_shown")
+               if i~=j then
+                  if i>0 then hacky_swap_node(pos,"technic:hv_battery_box"..i)
+                  elseif i==0 then hacky_swap_node(pos,"technic:hv_battery_box") end
+                  meta:set_float("last_side_shown",i)
+               end
+
+               local load = math.floor(current_charge/max_charge * 100)
+               meta:set_string("formspec",
+                               battery_box_formspec..
+                                  "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
+                                  (load)..":technic_power_meter_fg.png]"
+                            )
+
+               if eu_input == 0 then
+                  meta:set_string("infotext", "HV Battery box: "..current_charge.."/"..max_charge.." (idle)")
+               else
+                  meta:set_string("infotext", "HV Battery box: "..current_charge.."/"..max_charge)
+               end
+            end
+ })
+
+-- Register as a battery type
+-- Battery type machines function as power reservoirs and can both receive and give back power
+technic.register_HV_machine("technic:hv_battery_box","BA")
+for i=1,8,1 do
+   technic.register_HV_machine("technic:hv_battery_box"..i,"BA")
+end
+
diff --git a/technic/machines/hv/forcefield.lua b/technic/machines/hv/forcefield.lua
new file mode 100644 (file)
index 0000000..8ad5410
--- /dev/null
@@ -0,0 +1,225 @@
+-- Forcefield mod by ShadowNinja
+-- Modified by kpoppel
+--
+-- Forcefields are powerful barriers but they consume huge amounts of power.
+-- Forcefield Generator is a HV machine.
+
+-- How expensive is the generator? Leaves room for upgrades lowering the power drain?
+local forcefield_power_drain     = 10 -- default 10
+local forcefield_update_interval = 1
+
+minetest.register_craft({
+       output = 'technic:forcefield_emitter_off',
+       recipe = {
+                       {'default:mese',         'technic:deployer_off', 'default:mese'        },
+                       {'technic:deployer_off', 'technic:motor',        'technic:deployer_off'},
+                       {'default:mese',         'technic:deployer_off', 'default:mese'        },
+       }
+})
+
+-- Idea: Let forcefields have different colors by upgrade slot.
+-- Idea: Let forcefields add up by detecting if one hits another.
+--    ___   __
+--   /   \/   \
+--  |          |
+--   \___/\___/
+--
+local function add_forcefield(pos, range)
+       for x=-range,range do
+       for y=-range,range do
+       for z=-range,range do
+               if ((x*x+y*y+z*z) <= (range * range + range)) then
+                       if ((range-1) * (range-1) + (range-1) <= x*x+y*y+z*z) then
+                               local np={x=pos.x+x,y=pos.y+y,z=pos.z+z}
+                               local n = minetest.env:get_node(np).name
+                               if (n == "air") then
+                                       minetest.env:add_node(np, {name = "technic:forcefield"})
+                               end
+                       end
+               end
+       end
+       end
+       end
+       return true
+end
+
+local function remove_forcefield(p, range)
+       for x=-range,range do
+       for y=-range,range do
+       for z=-range,range do
+               if ((x*x+y*y+z*z) <= (range * range + range)) then
+                       if ((range-1) * (range-1) + (range-1) <= x*x+y*y+z*z) then
+                               local np={x=p.x+x,y=p.y+y,z=p.z+z}
+                               local n = minetest.env:get_node(np).name
+                               if (n == "technic:forcefield") then
+                                       minetest.env:remove_node(np)
+                               end
+                       end
+               end
+       end
+       end
+       end
+end
+
+local get_forcefield_formspec = function(range)
+   --  return "invsize[8,9;]"..  (if upgrades added later - colors for instance)
+       return "invsize[3,4;]"..
+       "label[0,0;Forcefield emitter]"..
+       "label[1,1;Range]"..
+       "label[1,2;"..range.."]"..
+       "button[0,2;1,1;subtract;-]"..
+       "button[2,2;1,1;add;+]"..
+       "button[0,3;3,1;toggle;Enable/Disable]" -- ..
+--     "list[current_player;main;0,5;8,4;]"
+end
+
+local forcefield_receive_fields = function(pos, formname, fields, sender)
+                                    local meta = minetest.env:get_meta(pos)
+                                    local range = meta:get_int("range")
+                                    if fields.add then range = range + 1 end
+                                    if fields.subtract then range = range - 1 end
+                                    if fields.toggle then
+                                       if meta:get_int("enabled") == 1 then
+                                          meta:set_int("enabled", 0)
+                                       else
+                                          meta:set_int("enabled", 1)
+                                       end
+                                    end
+                                    -- Smallest field is 5. Anything less is asking for trouble.
+                                    -- Largest is 20. It is a matter of pratical node handling.
+                                    if range < 5  then range = 5 end
+                                    if range > 20 then range = 20 end
+
+                                    if range <= 20 and range >= 5 and meta:get_int("range") ~= range then
+                                       remove_forcefield(pos, meta:get_int("range"))
+                                       meta:set_int("range", range)
+                                       meta:set_string("formspec", get_forcefield_formspec(range))
+                                    end
+                                 end
+
+local forcefield_check = function(pos)
+                           local meta = minetest.env:get_meta(pos)
+                           local node = minetest.env:get_node(pos)
+                           local eu_input   = meta:get_int("HV_EU_input")
+                           local eu_demand  = meta:get_int("HV_EU_demand")
+                           local enabled    = meta:get_int("enabled")
+                           
+                           -- Power off automatically if no longer connected to a switching station
+                           technic.switching_station_timeout_count(pos, "HV")
+
+                           local power_requirement
+                           if enabled == 1 then
+                              power_requirement = math.floor(4*math.pi*math.pow(meta:get_int("range"), 2)) * forcefield_power_drain
+                           else
+                              power_requirement = eu_demand
+                           end
+
+                           if eu_input == 0 then
+                              meta:set_string("infotext", "Forcefield Generator Unpowered")
+                              meta:set_int("HV_EU_demand", 100)
+                              meta:set_int("enabled", 0)
+                              if node.name == "technic:forcefield_emitter_on" then
+                                 remove_forcefield(pos, meta:get_int("range"))
+                                 hacky_swap_node(pos, "technic:forcefield_emitter_off")
+                              end
+                           elseif eu_input == power_requirement then
+                              if meta:get_int("enabled") == 1 then
+                                 if node.name == "technic:forcefield_emitter_off" then
+                                    hacky_swap_node(pos, "technic:forcefield_emitter_on")
+                                    meta:set_string("infotext", "Forcefield Generator Active")
+                                    add_forcefield(pos, meta:get_int("range"))
+                                 else
+                                    -- Range updated. Move the forcefield.
+                                    add_forcefield(pos, meta:get_int("range"))
+                                 end
+                              else
+                                 if node.name == "technic:forcefield_emitter_on" then
+                                    remove_forcefield(pos, meta:get_int("range"))
+                                    hacky_swap_node(pos, "technic:forcefield_emitter_off")
+                                    meta:set_int("HV_EU_demand", 100)
+                                    meta:set_string("infotext", "Forcefield Generator Idle")
+                                 end
+                              end
+                           else
+                              meta:set_int("HV_EU_demand", power_requirement)
+                           end
+                           return true
+                        end
+
+local mesecons = {effector = {
+       action_on = function(pos, node)
+               minetest.env:get_meta(pos):set_int("enabled", 0)
+       end,
+       action_off = function(pos, node)
+               minetest.env:get_meta(pos):set_int("enabled", 1)
+       end
+}}
+
+minetest.register_node("technic:forcefield_emitter_off", {
+       description = "Forcefield emitter",
+       inventory_image = minetest.inventorycube("technic_forcefield_emitter_off.png"),
+       tiles = {"technic_forcefield_emitter_off.png"},
+       is_ground_content = true,
+       groups = {cracky = 1},
+       on_timer = forcefield_check,
+       on_receive_fields = forcefield_receive_fields,
+       on_construct = function(pos)
+               minetest.env:get_node_timer(pos):start(forcefield_update_interval)
+               local meta = minetest.env:get_meta(pos)
+               meta:set_float("technic_hv_power_machine", 1)
+               meta:set_int("HV_EU_input", 0)
+               meta:set_int("HV_EU_demand", 0)
+               meta:set_int("range", 10)
+               meta:set_int("enabled", 0)
+               meta:set_string("formspec", get_forcefield_formspec(meta:get_int("range")))
+               meta:set_string("infotext", "Forcefield emitter");
+       end,
+       mesecons = mesecons
+})
+
+minetest.register_node("technic:forcefield_emitter_on", {
+       description = "Forcefield emitter on (you hacker you)",
+       tiles = {"technic_forcefield_emitter_on.png"},
+       is_ground_content = true,
+       groups = {cracky = 1, not_in_creative_inventory=1},
+       drop='"technic:forcefield_emitter_off" 1',
+       on_timer = forcefield_check,
+       on_receive_fields = forcefield_receive_fields,
+       on_construct = function(pos) 
+               minetest.env:get_node_timer(pos):start(forcefield_update_interval)
+               local meta = minetest.env:get_meta(pos)
+--             meta:set_float("technic_hv_power_machine", 1)
+--             meta:set_float("HV_EU_input", 0)
+--             meta:set_float("HV_EU_demand", 0)
+--             meta:set_int("range", 10)
+--             meta:set_int("enabled", 1)
+               meta:set_string("formspec", get_forcefield_formspec(meta:get_int("range")))
+--             meta:set_string("infotext", "Forcefield emitter");
+       end,
+       on_dig = function(pos, node, digger)    
+               remove_forcefield(pos, minetest.env:get_meta(pos):get_int("range"))
+               return minetest.node_dig(pos, node, digger)
+       end,
+       mesecons = mesecons
+})
+
+minetest.register_node("technic:forcefield", {
+       description = "Forcefield (you hacker you)",
+       sunlight_propagates = true,
+       drop = '',
+        light_source = 8,
+       tiles = {{name="technic_forcefield_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}}},
+       is_ground_content = true,
+       groups = {not_in_creative_inventory=1, unbreakable=1},
+       paramtype = "light",
+       drawtype = "nodebox",
+       node_box = {  --hacky way to get the field blue and not see through the ground
+               type = "fixed",
+               fixed={
+                       {-.5,-.5,-.5,.5,.5,.5},
+               },
+       },
+})
+
+technic.register_HV_machine("technic:forcefield_emitter_on","RE")
+technic.register_HV_machine("technic:forcefield_emitter_off","RE")
diff --git a/technic/machines/hv/init.lua b/technic/machines/hv/init.lua
new file mode 100644 (file)
index 0000000..6dd1ece
--- /dev/null
@@ -0,0 +1,8 @@
+local path = technic.modpath.."/machines/hv"
+
+dofile(path.."/forcefield.lua")
+dofile(path.."/wires.lua")
+dofile(path.."/battery_box.lua")
+dofile(path.."/solar_array.lua")
+dofile(path.."/nuclear_reactor.lua")
+
diff --git a/technic/machines/hv/nuclear_reactor.lua b/technic/machines/hv/nuclear_reactor.lua
new file mode 100644 (file)
index 0000000..a5204c7
--- /dev/null
@@ -0,0 +1,239 @@
+-- The enriched uranium rod driven EU generator.
+-- A very large and advanced machine providing vast amounts of power.
+-- Very efficient but also expensive to run as it needs uranium. (10000EU 86400 ticks (24h))
+-- Provides HV EUs that can be down converted as needed.
+--
+-- The nuclear reactor core needs water and a protective shield to work.
+-- This is checked now and then and if the machine is tampered with... BOOM!
+local burn_ticks   =     1                      -- [minutes]. How many minutes does the power plant burn per serving?
+local power_supply = 10000                      -- [HV] EUs
+local fuel_type    = "technic:enriched_uranium" -- This reactor burns this stuff
+
+-- FIXME: recipe must make more sense like a rod recepticle, steam chamber, HV generator?
+minetest.register_craft({
+       output = 'technic:hv_nuclear_reactor_core',
+       recipe = {
+               {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
+               {'technic:stainless_steel_ingot', '', 'technic:stainless_steel_ingot'},
+               {'technic:stainless_steel_ingot', 'technic:hv_cable', 'technic:stainless_steel_ingot'},
+       }
+})
+
+minetest.register_craftitem("technic:hv_nuclear_reactor_core", {
+       description = "Uranium Rod Driven HV Reactor",
+       stack_max = 1,
+}) 
+
+local generator_formspec =
+       "invsize[8,9;]"..
+--     "image[0,0;5,5;technic_generator_menu.png]"..
+       "label[0,0;Nuclear Reactor Rod Compartment]"..
+       "list[current_name;src;2,1;3,2;]"..
+       "list[current_player;main;0,5;8,4;]"
+
+-- "Boxy sphere"
+local nodebox = {{ -0.353, -0.353, -0.353, 0.353, 0.353, 0.353 }, -- Box
+                { -0.495, -0.064, -0.064, 0.495, 0.064, 0.064 }, -- Circle +-x
+                { -0.483, -0.128, -0.128, 0.483, 0.128, 0.128 },
+                { -0.462, -0.191, -0.191, 0.462, 0.191, 0.191 },
+                { -0.433, -0.249, -0.249, 0.433, 0.249, 0.249 },
+                { -0.397, -0.303, -0.303, 0.397, 0.303, 0.303 },
+                { -0.305, -0.396, -0.305, 0.305, 0.396, 0.305 }, -- Circle +-y
+                { -0.250, -0.432, -0.250, 0.250, 0.432, 0.250 },
+                { -0.191, -0.461, -0.191, 0.191, 0.461, 0.191 },
+                { -0.130, -0.482, -0.130, 0.130, 0.482, 0.130 },
+                { -0.066, -0.495, -0.066, 0.066, 0.495, 0.066 },
+                { -0.064, -0.064, -0.495, 0.064, 0.064, 0.495 }, -- Circle +-z
+                { -0.128, -0.128, -0.483, 0.128, 0.128, 0.483 },
+                { -0.191, -0.191, -0.462, 0.191, 0.191, 0.462 },
+                { -0.249, -0.249, -0.433, 0.249, 0.249, 0.433 },
+                { -0.303, -0.303, -0.397, 0.303, 0.303, 0.397 },
+                }
+
+minetest.register_node(
+   "technic:hv_nuclear_reactor_core",
+   {
+      description = "Nuclear Reactor",
+      tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
+              "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"},
+--      paramtype2 = "facedir",
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_wood_defaults(),
+      drawtype="nodebox",
+      paramtype = "light",
+      node_box = {
+        type = "fixed",
+        fixed = nodebox
+      },
+      on_construct = function(pos)
+                       local meta = minetest.env:get_meta(pos)
+                       meta:set_string("infotext", "Nuclear Reactor Core")
+                       meta:set_float("technic_hv_power_machine", 1)
+                       meta:set_int("HV_EU_supply", 0)
+                       meta:set_int("HV_EU_from_fuel", 1) -- Signal to the switching station that this device burns some sort of fuel and needs special handling
+                       meta:set_int("burn_time", 0)
+                       meta:set_string("formspec", generator_formspec)
+                       local inv = meta:get_inventory()
+                       inv:set_size("src", 6)
+               end,    
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  else
+                     return true
+                  end
+               end,
+   })
+
+minetest.register_node(
+   "technic:hv_nuclear_reactor_core_active",
+   {
+      description = "Coal Driven Generator",
+      tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
+              "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"},
+--      paramtype2 = "facedir",
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_wood_defaults(),
+      drop="technic:generator",
+      drawtype="nodebox",
+      light_source = 15,
+      paramtype = "light",
+      node_box = {
+        type = "fixed",
+        fixed = nodebox
+      },
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  else
+                     return true
+                  end
+               end,
+   })
+
+local check_reactor_structure = function(pos)
+                                  -- The reactor consists of an 11x11x11 cube structure
+                                  -- A cross section through the middle:
+                                  --  CCCCC CCCCC
+                                  --  CCCCC CCCCC
+                                  --  CCSSS SSSCC
+                                  --  CCSCC CCSCC
+                                  --  CCSCWWWCSCC
+                                  --  CCSCW#WCSCC
+                                  --  CCSCW|WCSCC
+                                  --  CCSCC|CCSCC
+                                  --  CCSSS|SSSCC
+                                  --  CCCCC|CCCCC
+                                  --  C = Concrete, S = Stainless Steel, W = water node (not floating), #=reactor core, |=HV cable
+                                  --  The man-hole and the HV cable is only in the middle.
+                                  local water_nodes = minetest.find_nodes_in_area({x=pos.x-1, y=pos.y-1, z=pos.z-1},
+                                                                            {x=pos.x+1, y=pos.y+1, z=pos.z+1}, "default:water_source")
+                                  --print("Water      (  25):"..#water_nodes)
+                                  if #water_nodes ~= 25 then
+                                     --print("Water supply defect")
+                                     return 0
+                                  end
+                                  local inner_shield_nodes = minetest.find_nodes_in_area({x=pos.x-2, y=pos.y-2, z=pos.z-2},
+                                                                                         {x=pos.x+2, y=pos.y+2, z=pos.z+2}, "technic:concrete")
+
+                                  --print("Concrete 1 (  96):"..#inner_shield_nodes)
+                                  if #inner_shield_nodes ~= 96 then
+                                     --print("Inner shield defect")
+                                     return 0
+                                  end
+                                  local steel_shield_nodes = minetest.find_nodes_in_area({x=pos.x-3, y=pos.y-3, z=pos.z-3},
+                                                                                         {x=pos.x+3, y=pos.y+3, z=pos.z+3}, "default:steelblock")
+
+                                  --print("Steel      ( 216):"..#steel_shield_nodes)
+                                  if #steel_shield_nodes ~= 216 then
+                                     --print("Steel shield defect")
+                                     return 0
+                                  end
+                                  local outer_shield_nodes = minetest.find_nodes_in_area({x=pos.x-5, y=pos.y-5, z=pos.z-5},
+                                                                                         {x=pos.x+5, y=pos.y+5, z=pos.z+5}, "technic:concrete")
+                                  --print("Concrete 2 (1080):"..#outer_shield_nodes)
+                                  if #outer_shield_nodes ~= (984+#inner_shield_nodes) then
+                                     --print("Outer shield defect")
+                                     return 0
+                                  end
+                                  return 1
+                               end
+
+local explode_reactor = function(pos)
+                          print("BOOM A reactor exploded!")
+                       end
+
+minetest.register_abm(
+   {
+      nodenames = {"technic:hv_nuclear_reactor_core","technic:hv_nuclear_reactor_core_active"},
+      interval = 1,
+      chance   = 1,
+      action = function(pos, node, active_object_count, active_object_count_wider)
+                 local meta = minetest.env:get_meta(pos)
+                 local burn_time= meta:get_int("burn_time")
+
+                 -- If more to burn and the energy produced was used: produce some more
+                 if burn_time>0 then
+                    if meta:get_int("HV_EU_supply") == 0 then
+                       -- We did not use the power
+                       meta:set_int("HV_EU_supply", power_sypply)
+                    else
+                       burn_time = burn_time - 1
+                       meta:set_int("burn_time",burn_time)
+                       meta:set_string("infotext", "Nuclear Reactor Core ("..math.floor(burn_time/(burn_ticks*60)*100).."%)")
+                    end
+                 end
+
+                 -- Burn another piece of coal
+                 if burn_time==0 then
+                    local inv = meta:get_inventory()
+                    local correct_fuel_count = 0
+                    if inv:is_empty("src") == false  then 
+                       local srclist= inv:get_list("src")
+                       for _, srcstack in pairs(srclist) do
+                          if srcstack then
+                             local src_item=srcstack:to_table()
+                             if src_item and src_item["name"] == fuel_type then
+                                correct_fuel_count = correct_fuel_count + 1
+                             end
+                          end
+                       end
+                       -- Check that the reactor is complete as well as the correct number of correct fuel
+                       if correct_fuel_count == 6 then
+                          if check_reactor_structure(pos) == 1 then
+                             burn_time=burn_ticks*60
+                             meta:set_int("burn_time",burn_time)
+                             hacky_swap_node (pos,"technic:hv_nuclear_reactor_core_active") 
+                             meta:set_int("HV_EU_supply", power_supply)
+                             for idx, srcstack in pairs(srclist) do
+                                srcstack:take_item()
+                                inv:set_stack("src", idx, srcstack)
+                             end
+                          else
+                             -- BOOM!!! (the reactor was compromised and it should explode after some time) TNT mod inspired??
+                             explode_reactor(pos)
+                          end
+                       else
+                          meta:set_int("HV_EU_supply", 0)
+                       end
+                    end
+                 end
+
+                 -- Nothing left to burn
+                 if burn_time==0 then
+                    meta:set_string("infotext", "Nuclear Reactor Core (idle)")
+                    hacky_swap_node (pos,"technic:hv_nuclear_reactor_core")
+                 end
+              end
+   })
+
+technic.register_HV_machine ("technic:hv_nuclear_reactor_core","PR")
+technic.register_HV_machine ("technic:hv_nuclear_reactor_core_active","PR")
diff --git a/technic/machines/hv/solar_array.lua b/technic/machines/hv/solar_array.lua
new file mode 100644 (file)
index 0000000..73f6ee2
--- /dev/null
@@ -0,0 +1,78 @@
+-- The high voltage solar array is an assembly of medium voltage arrays.
+-- The assembly can deliver high voltage levels and is a 20% less efficient
+-- compared to 5 individual medium voltage arrays due to losses in the transformer.
+-- However high voltage is supplied.
+-- Solar arrays are not able to store large amounts of energy.
+minetest.register_node("technic:solar_array_hv", {
+       tiles = {"technic_hv_solar_array_top.png", "technic_hv_solar_array_bottom.png", "technic_hv_solar_array_side.png",
+                "technic_hv_solar_array_side.png", "technic_hv_solar_array_side.png", "technic_hv_solar_array_side.png"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+       sounds = default.node_sound_wood_defaults(),
+       description="HV Solar Array",
+       active = false,
+       drawtype = "nodebox",
+       paramtype = "light",
+       is_ground_content = true,       
+       node_box = {
+                       type = "fixed",
+                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
+               },
+               selection_box = {
+                       type = "fixed",
+                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
+               },
+       on_construct = function(pos)
+               local meta = minetest.env:get_meta(pos)
+               meta:set_float("technic_hv_power_machine", 1)
+               meta:set_int("HV_EU_supply", 0)
+               meta:set_string("infotext", "HV Solar Array")
+       end,
+})
+
+minetest.register_craft(
+   {output = 'technic:solar_array_hv 1',
+    recipe = {
+       {'technic:solar_array_mv', 'technic:solar_array_mv','technic:solar_array_mv'},
+       {'technic:solar_array_mv', 'technic:hv_transformer','technic:solar_array_mv'},
+       {'default:steel_ingot',    'technic:hv_cable',      'default:steel_ingot'},
+    }
+ })
+
+minetest.register_abm(
+   {nodenames = {"technic:solar_array_hv"},
+    interval   = 1,
+    chance     = 1,
+    action = function(pos, node, active_object_count, active_object_count_wider)
+               -- The action here is to make the solar array produce power
+               -- Power is dependent on the light level and the height above ground
+               -- 130m and above is optimal as it would be above cloud level.
+                -- Height gives 1/4 of the effect, light 3/4. Max. effect is 2880EU for the array.
+                -- There are many ways to cheat by using other light sources like lamps.
+                -- As there is no way to determine if light is sunlight that is just a shame.
+                -- To take care of some of it solar panels do not work outside daylight hours or if
+                -- built below -10m
+               local pos1={}
+               pos1.y=pos.y+1
+               pos1.x=pos.x
+               pos1.z=pos.z
+               local light = minetest.env:get_node_light(pos1, nil)
+               local time_of_day = minetest.env:get_timeofday()
+               local meta = minetest.env:get_meta(pos)
+               if light == nil then light = 0 end
+               -- turn on array only during day time and if sufficient light
+                -- I know this is counter intuitive when cheating by using other light sources.
+               if light >= 12 and time_of_day>=0.24 and time_of_day<=0.76 and pos.y > -10 then
+                  local charge_to_give          = math.floor(light*(light*9.6+pos1.y/130*48))
+                  if charge_to_give<0   then charge_to_give=0 end
+                  if charge_to_give>160 then charge_to_give=160 end
+                  meta:set_string("infotext", "Solar Array is active ("..charge_to_give.."EU)")
+                  meta:set_int("HV_EU_supply", charge_to_give)
+               else
+                  meta:set_string("infotext", "Solar Array is inactive");
+                  meta:set_int("HV_EU_supply", 0)
+               end
+            end,
+ }) 
+
+technic.register_HV_machine ("technic:solar_array_hv","PR")
+
diff --git a/technic/machines/hv/wires.lua b/technic/machines/hv/wires.lua
new file mode 100644 (file)
index 0000000..b2c9834
--- /dev/null
@@ -0,0 +1,398 @@
+--HV cable node boxes
+
+
+minetest.register_craft({
+       output = 'technic:hv_cable 3',
+       recipe ={
+               {'technic:rubber','technic:rubber','technic:rubber'},
+               {'technic:mv_cable','technic:mv_cable','technic:mv_cable'},
+               {'technic:rubber','technic:rubber','technic:rubber'},
+               }
+}) 
+
+
+minetest.register_craftitem("technic:hv_cable", {
+       description = "Gigh Voltage Copper Cable",
+       stack_max = 99,
+}) 
+
+minetest.register_node("technic:hv_cable", {
+       description = "High Voltage Copper Cable",
+       tiles = {"technic_hv_cable.png"},
+       inventory_image = "technic_hv_cable_wield.png",
+       wield_image = "technic_hv_cable_wield.png",
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+       sounds = default.node_sound_wood_defaults(),
+       drop = "technic:hv_cable",
+       hv_cablelike=1,
+       rules_x1=0,
+       rules_x2=0,
+       rules_y1=0,
+       rules_y2=0,
+       rules_z1=0,
+       rules_z2=0,
+       paramtype = "light",
+        drawtype = "nodebox", 
+       selection_box = {
+               type = "fixed",
+                fixed = {
+               { -0.1 , -0.1 , -0.1 , 0.1 ,  0.1 , 0.1  },
+               }},
+       node_box = {
+               type = "fixed",
+                fixed = {
+               { -0.125 , -0.125 , -0.125 , 0.125 ,  0.125 , 0.125  },
+               }},
+       on_construct = function(pos)
+       meta=minetest.env:get_meta(pos)
+       meta:set_float("hv_cablelike",1)
+       meta:set_float("x1",0)
+       meta:set_float("x2",0)
+       meta:set_float("y1",0)
+       meta:set_float("y2",0)
+       meta:set_float("z1",0)
+       meta:set_float("z2",0)
+       HV_check_connections (pos)
+       end,
+
+       after_dig_node = function (pos, oldnode, oldmetadata, digger)
+       HV_check_connections_on_destroy (pos)
+       end,
+
+})
+
+
+str_y1=                { -0.125 , -0.125 , -0.125 , 0.125 , 0.5, 0.125  }    --0 y+
+str_x1=                { -0.125 , -0.125 , -0.125 , 0.5, 0.125 , 0.125  }    --0 x+
+str_z1=                { -0.125 , -0.125 ,  0.125 ,  0.125 , 0.125 , 0.5 }   --0 z+
+str_z2=                { -0.125 , -0.125, -0.5 ,  0.125 ,  0.125 , 0.125  }  --0 z-
+str_y2=                { -0.125 , -0.5, -0.125 ,  0.125 ,  0.125 , 0.125  }  --0 y-
+str_x2=                { -0.5 , -0.125, -0.125 ,  0.125 ,  0.125 , 0.125  }  --0 x-
+
+
+
+local x1,x2,y1,y2,z1,z2
+local count=0
+
+for x1 = 0, 1, 1 do    --x-
+for x2 = 0, 1, 1 do    --x+
+for y1 = 0, 1, 1 do    --y-
+for y2 = 0, 1, 1 do    --y-    
+for z1 = 0, 1, 1 do    --z-
+for z2 = 0, 1, 1 do    --z+
+     
+temp_x1={} temp_x2={} temp_y1={} temp_y2={} temp_z1={} temp_z2={}
+
+if x1==1 then  temp_x1=str_x1  end 
+if x2==1 then  temp_x2=str_x2  end 
+if y1==1 then  temp_y1=str_y1  end 
+if y2==1 then  temp_y2=str_y2  end 
+if z1==1 then  temp_z1=str_z1  end 
+if z2==1 then  temp_z2=str_z2  end 
+
+
+minetest.register_node("technic:hv_cable"..count, {
+       description = "Gigh Voltage Copper Cable",
+       tiles = {"technic_hv_cable.png"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
+       sounds = default.node_sound_wood_defaults(),
+       drop = "technic:hv_cable",
+       rules_x1=0,
+       rules_x2=0,
+       rules_y1=0,
+       rules_y2=0,
+       rules_z1=0,
+       rules_z2=0,
+       cablelike=1,
+       paramtype = "light",
+        drawtype = "nodebox", 
+       selection_box = {
+               type = "fixed",
+           fixed = {
+               temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
+               }},
+
+       node_box = {
+               type = "fixed",
+           fixed = {
+               temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
+               }},
+
+       after_dig_node = function (pos, oldnode, oldmetadata, digger)
+       HV_check_connections_on_destroy (pos)
+       end,
+       
+})
+
+count=count+1 end end end end end end
+
+HV_check_connections = function(pos)
+               local pos1={}
+               pos1.x=pos.x
+               pos1.y=pos.y
+               pos1.z=pos.z
+               
+               pos1.x=pos1.x+1
+               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
+               x2=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:hv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("x2",x2)
+               meta=minetest.env:get_meta(pos)
+               x1=1
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("x1",x1)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:hv_cable"..rule)
+               end
+
+               pos1.x=pos1.x-2
+               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
+               x1=1
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:hv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("x1",x1)
+               meta=minetest.env:get_meta(pos)
+               x2=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("x2",x2)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:hv_cable"..rule)
+               end
+
+               pos1.x=pos1.x+1
+               
+               pos1.y=pos1.y+1
+               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
+               y2=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:hv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("y2",y2)
+               meta=minetest.env:get_meta(pos)
+               y1=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("y1",y1)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:hv_cable"..rule)
+               end
+               
+               if minetest.env:get_meta(pos1):get_float("technic_hv_power_machine")==1 then
+               y1=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:hv_cable"..rule)
+               meta=minetest.env:get_meta(pos)
+               meta:set_float("y1",y1)
+               end
+
+
+               pos1.y=pos1.y-2
+               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
+               y1=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:hv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("y1",y1)
+               meta=minetest.env:get_meta(pos)
+               y2=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("y2",y2)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:hv_cable"..rule)
+               end
+               pos1.y=pos1.y+1
+
+               pos1.z=pos1.z+1
+               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
+               z2=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:hv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("z2",z2)
+               meta=minetest.env:get_meta(pos)
+               z1=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("z1",z1)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:hv_cable"..rule)
+               end
+               pos1.z=pos1.z-2
+               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
+               z1=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:hv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("z1",z1)
+               meta=minetest.env:get_meta(pos)
+               z2=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               meta:set_float("z2",z2)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:hv_cable"..rule)
+               end
+               pos1.z=pos1.z+1
+end    
+
+
+HV_check_connections_on_destroy = function(pos)
+               local pos1={}
+               pos1.x=pos.x
+               pos1.y=pos.y
+               pos1.z=pos.z
+               
+               pos1.x=pos1.x+1
+               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
+               x2=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("x2",x2)
+               end
+               
+               pos1.x=pos1.x-2
+               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
+               x1=0
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("x1",x1)
+               end
+               pos1.x=pos1.x+1
+
+               pos1.y=pos1.y+1
+               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
+               y2=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("y2",y2)
+               end
+               
+               pos1.y=pos1.y-2
+               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
+               y1=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("y1",y1)
+               end
+               pos1.y=pos1.y+1
+
+               pos1.z=pos1.z+1
+               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
+               z2=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("z2",z2)
+               end
+               
+               pos1.z=pos1.z-2
+               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
+               z1=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("z1",z1)
+               end
+               pos1.y=pos1.y+1
+               
+end    
+
diff --git a/technic/machines/init.lua b/technic/machines/init.lua
new file mode 100644 (file)
index 0000000..58b42f4
--- /dev/null
@@ -0,0 +1,10 @@
+local path = technic.modpath.."/machines"
+
+dofile(path.."/switching_station.lua")
+dofile(path.."/supply_converter.lua")
+dofile(path.."/alloy_furnaces_commons.lua")
+dofile(path.."/lv/init.lua")
+dofile(path.."/mv/init.lua")
+dofile(path.."/hv/init.lua")
+dofile(path.."/other/init.lua")
+
diff --git a/technic/machines/lv/alloy_furnace.lua b/technic/machines/lv/alloy_furnace.lua
new file mode 100644 (file)
index 0000000..fcdb9c0
--- /dev/null
@@ -0,0 +1,367 @@
+-- LV Alloy furnace
+minetest.register_craft({
+       output = 'technic:coal_alloy_furnace',
+       recipe = {
+               {'default:brick', 'default:brick', 'default:brick'},
+               {'default:brick', '',              'default:brick'},
+               {'default:brick', 'default:brick', 'default:brick'},
+       }
+})
+
+-- FIXME: kpoppel: I'd like to introduce an induction heating element here...
+minetest.register_craft({
+       output = 'technic:alloy_furnace',
+       recipe = {
+               {'default:brick', 'default:brick', 'default:brick'},
+               {'default:brick', '', 'default:brick'},
+               {'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
+       }
+})
+
+local alloy_furnace_formspec =
+   "invsize[8,9;]"..
+   "list[current_name;src;3,1;1,1;]"..
+   "list[current_name;src2;3,2;1,1;]"..
+   "list[current_name;dst;5,1;2,2;]"..
+   "list[current_player;main;0,5;8,4;]"..
+   "label[0,0;Electric Alloy Furnace]"
+
+minetest.register_node(
+   "technic:alloy_furnace",
+   {
+      description = "Electric alloy furnace",
+      tiles = {"technic_alloy_furnace_top.png", "technic_machine_bottom.png", "technic_alloy_furnace_side.png",
+              "technic_alloy_furnace_side.png", "technic_alloy_furnace_side.png", "technic_alloy_furnace_front.png"},
+      paramtype2 = "facedir",
+      groups = {cracky=2},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_stone_defaults(),
+      on_construct = function(pos)
+                       local meta = minetest.env:get_meta(pos)
+                       meta:set_string("infotext", "Electric Alloy furnace")
+                       meta:set_float("technic_power_machine", 1)
+                       meta:set_string("formspec", alloy_furnace_formspec)
+                       local inv = meta:get_inventory()
+                       inv:set_size("src", 1)
+                       inv:set_size("src2", 1)
+                       inv:set_size("dst", 4)
+                    end,
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") or not inv:is_empty("src2") or not inv:is_empty("dst") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  else
+                     return true
+                  end
+               end,
+})
+
+minetest.register_node(
+   "technic:alloy_furnace_active",
+   {
+      description = "Alloy Furnace",
+      tiles = {"technic_alloy_furnace_top.png", "technic_machine_bottom.png", "technic_alloy_furnace_side.png",
+              "technic_alloy_furnace_side.png", "technic_alloy_furnace_side.png", "technic_alloy_furnace_front_active.png"},
+      paramtype2 = "facedir",
+      light_source = 8,
+      drop = "technic:alloy_furnace",
+      groups = {cracky=2,not_in_creative_inventory=1},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_stone_defaults(),
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") or not inv:is_empty("src2") or not inv:is_empty("dst") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  else
+                     return true
+                  end
+               end,
+   })
+
+minetest.register_abm(
+   { nodenames = {"technic:alloy_furnace","technic:alloy_furnace_active"},
+     interval = 1,
+     chance   = 1,
+     action = function(pos, node, active_object_count, active_object_count_wider)
+                local meta         = minetest.env:get_meta(pos)
+                local eu_input     = meta:get_int("LV_EU_input")
+                local state        = meta:get_int("state")
+                local next_state   = state
+
+                -- Machine information
+                local machine_name         = "Electric Alloy Furnace"
+                local machine_node         = "technic:alloy_furnace"
+                local machine_state_demand = { 50, 600 }
+
+                -- Setup meta data if it does not exist. state is used as an indicator of this
+                if state == 0 then
+                   meta:set_int("state", 1)
+                   meta:set_int("LV_EU_demand", machine_state_demand[1])
+                   meta:set_int("LV_EU_input", 0)
+                   meta:set_int("tube_time", 0)
+                   return
+                end
+                        
+                -- Power off automatically if no longer connected to a switching station
+                technic.switching_station_timeout_count(pos, "LV")
+                        
+                -- State machine
+                if eu_input == 0 then
+                   -- Unpowered - go idle
+                   hacky_swap_node(pos, machine_node)
+                   meta:set_string("infotext", machine_name.." Unpowered")
+                   next_state = 1
+                elseif eu_input == machine_state_demand[state] then
+                   -- Powered - do the state specific actions
+                           
+                   -- Execute always if powered logic
+                   local inv    = meta:get_inventory()
+                   local empty  = 1
+                   local recipe = nil
+                   local result = nil
+
+                   -- Get what to cook if anything
+                   local srcstack  = inv:get_stack("src", 1)
+                   local src2stack = inv:get_stack("src2", 1)
+                   local src_item1 = nil
+                   local src_item2 = nil
+                   if srcstack and src2stack then
+                      src_item1 = srcstack:to_table()
+                      src_item2 = src2stack:to_table()
+                      empty     = 0
+                   end
+              
+                   if src_item1 and src_item2 then
+                      recipe = technic.get_alloy_recipe(src_item1,src_item2)
+                   end
+                   if recipe then
+                      result = { name=recipe.dst_name, count=recipe.dst_count}
+                   end
+
+                   if recipe then
+                      print("recipe "..recipe.dst_name.." : result "..result.name.." : empty "..empty.." : src_item1 "..src_item1.name.." : src_item2 "..src_item2.name)
+                   end
+
+                   if state == 1 then
+                      hacky_swap_node(pos, machine_node)
+                      meta:set_string("infotext", machine_name.." Idle")
+                      
+                      if empty == 0 and recipe and inv:room_for_item("dst", result) then
+                         meta:set_string("infotext", machine_name.." Active")
+                         meta:set_string("src_time", 0)
+                         next_state = 2
+                      end
+
+                   elseif state == 2 then
+                      hacky_swap_node(pos, machine_node.."_active")
+                      meta:set_int("src_time", meta:get_int("src_time") + 1)
+                      if meta:get_int("src_time") == 4 then -- 4 ticks per output
+                         meta:set_string("src_time", 0)
+                         -- check if there's room for output in "dst" list and that we have the materials
+                         if recipe and inv:room_for_item("dst", result) then
+                            -- Take stuff from "src" list
+                            srcstack:take_item(recipe.src1_count)
+                            inv:set_stack("src", 1, srcstack)
+                            src2stack:take_item(recipe.src2_count)
+                            inv:set_stack("src2", 1, src2stack)
+                          -- Put result in "dst" list
+                            inv:add_item("dst",result)
+                         else
+                            next_state = 1
+                         end
+                      end
+                   end
+                   -- Change state?
+                   if next_state ~= state then
+                      meta:set_int("LV_EU_demand", machine_state_demand[next_state])
+                      meta:set_int("state", next_state)
+                   end
+                end
+             end,
+  })
+
+technic.register_LV_machine ("technic:alloy_furnace","RE")
+technic.register_LV_machine ("technic:alloy_furnace_active","RE")
+
+--------------------------------------------------
+-- coal driven alloy furnace. This uses no EUs:
+--------------------------------------------------
+coal_alloy_furnace_formspec =
+       "size[8,9]"..
+       "label[0,0;Alloy Furnace]"..
+       "image[2,2;1,1;default_furnace_fire_bg.png]"..
+       "list[current_name;fuel;2,3;1,1;]"..
+       "list[current_name;src;2,1;1,1;]"..
+       "list[current_name;src2;3,1;1,1;]"..
+       "list[current_name;dst;5,1;2,2;]"..
+       "list[current_player;main;0,5;8,4;]"
+
+minetest.register_node("technic:coal_alloy_furnace", {
+       description = "Alloy Furnace",
+       tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", "technic_coal_alloy_furnace_side.png",
+               "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front.png"},
+       paramtype2 = "facedir",
+       groups = {cracky=2},
+       legacy_facedir_simple = true,
+       sounds = default.node_sound_stone_defaults(),
+       on_construct = function(pos)
+               local meta = minetest.env:get_meta(pos)
+               meta:set_string("formspec", coal_alloy_furnace_formspec)
+               meta:set_string("infotext", "Alloy Furnace")
+               local inv = meta:get_inventory()
+               inv:set_size("fuel", 1)
+               inv:set_size("src", 1)
+               inv:set_size("src2", 1)
+               inv:set_size("dst", 4)
+       end,
+       can_dig = function(pos,player)
+               local meta = minetest.env:get_meta(pos);
+               local inv = meta:get_inventory()
+               if not (inv:is_empty("fuel") or inv:is_empty("dst") or inv:is_empty("src") or inv:is_empty("src2") )then
+                       return false
+                       end
+               return true
+       end,
+})
+
+minetest.register_node("technic:coal_alloy_furnace_active", {
+       description = "Alloy Furnace",
+       tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", "technic_coal_alloy_furnace_side.png",
+               "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front_active.png"},
+       paramtype2 = "facedir",
+       light_source = 8,
+       drop = "technic:coal_alloy_furnace",
+       groups = {cracky=2, not_in_creative_inventory=1},
+       legacy_facedir_simple = true,
+       sounds = default.node_sound_stone_defaults(),
+       can_dig = function(pos,player)
+               local meta = minetest.env:get_meta(pos);
+               local inv = meta:get_inventory()
+               if not (inv:is_empty("fuel") or inv:is_empty("dst") or inv:is_empty("src") or inv:is_empty("src2") )then
+                       return false
+                       end
+               return true
+       end,
+})
+
+minetest.register_abm({
+       nodenames = {"technic:coal_alloy_furnace","technic:coal_alloy_furnace_active"},
+       interval = 1,
+       chance = 1,
+
+       action = function(pos, node, active_object_count, active_object_count_wider)
+               local meta = minetest.env:get_meta(pos)
+               for i, name in pairs({
+                               "fuel_totaltime",
+                               "fuel_time",
+                               "src_totaltime",
+                               "src_time"
+               }) do
+                       if meta:get_string(name) == "" then
+                               meta:set_float(name, 0.0)
+                       end
+               end
+
+               local inv    = meta:get_inventory()
+               local recipe = nil
+
+               -- Get what to cook if anything
+               local srcstack = inv:get_stack("src", 1)
+               if srcstack then src_item1=srcstack:to_table() end
+               
+               local src2stack = inv:get_stack("src2", 1)
+               if src2stack then src_item2=src2stack:to_table() end
+               
+               if src_item1 and src_item2 then
+                  recipe = technic.get_alloy_recipe(src_item1,src_item2)
+               end
+
+               local was_active = false
+
+               if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
+                  was_active = true
+                  meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
+                  meta:set_float("src_time", meta:get_float("src_time") + 1)
+                  if recipe and meta:get_float("src_time") == 6 then
+                     -- check if there's room for output in "dst" list
+                     local dst_stack = { name=recipe.dst_name, count=recipe.dst_count}
+                     if inv:room_for_item("dst",dst_stack) then
+                        -- Take stuff from "src" list
+                        srcstack:take_item(recipe.src1_count)
+                        inv:set_stack("src", 1, srcstack)
+                        src2stack:take_item(recipe.src2_count)
+                        inv:set_stack("src2", 1, src2stack)
+                        -- Put result in "dst" list
+                        inv:add_item("dst",dst_stack)
+                     else
+                        print("Furnace inventory full!") -- Silly code...
+                     end
+                     meta:set_string("src_time", 0)
+                  end
+               end
+               
+               if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
+                  local percent = math.floor(meta:get_float("fuel_time") /
+                                          meta:get_float("fuel_totaltime") * 100)
+                  meta:set_string("infotext","Furnace active: "..percent.."%")
+                  hacky_swap_node(pos,"technic:coal_alloy_furnace_active")
+                  meta:set_string("formspec",
+                                  "size[8,9]"..
+                                     "label[0,0;Electric Alloy Furnace]"..
+                                     "image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
+                                     (100-percent)..":default_furnace_fire_fg.png]"..
+                                  "list[current_name;fuel;2,3;1,1;]"..
+                                  "list[current_name;src;2,1;1,1;]"..
+                                  "list[current_name;src2;3,1;1,1;]"..
+                                  "list[current_name;dst;5,1;2,2;]"..
+                                  "list[current_player;main;0,5;8,4;]")
+                  return
+               end
+
+               -- FIXME: Make this look more like the electrical version.
+               -- This code refetches the recipe to see if it can be done again after the iteration
+               srcstack = inv:get_stack("src", 1)
+               if srcstack then src_item1=srcstack:to_table() end
+               srcstack = inv:get_stack("src2", 1)
+               if srcstack then src_item2=srcstack:to_table() end
+               if src_item1 and src_item2 then
+                  recipe = technic.get_alloy_recipe(src_item1,src_item2)
+               end
+
+               if recipe==nil then
+                  if was_active then
+                     meta:set_string("infotext","Furnace is empty")
+                     hacky_swap_node(pos,"technic:coal_alloy_furnace")
+                     meta:set_string("formspec", coal_alloy_furnace_formspec)
+                  end
+                  return
+               end
+
+               -- Next take a hard look at the fuel situation
+               local fuel = nil
+               local fuellist = inv:get_list("fuel")
+
+               if fuellist then
+                  fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
+               end
+
+               if fuel.time <= 0 then
+                  meta:set_string("infotext","Furnace out of fuel")
+                  hacky_swap_node(pos,"technic:coal_alloy_furnace")
+                  meta:set_string("formspec", coal_alloy_furnace_formspec)
+                  return
+               end
+
+               meta:set_string("fuel_totaltime", fuel.time)
+               meta:set_string("fuel_time", 0)
+
+               local stack = inv:get_stack("fuel", 1)
+               stack:take_item()
+               inv:set_stack("fuel", 1, stack)
+            end,
+     })
+
diff --git a/technic/machines/lv/battery_box.lua b/technic/machines/lv/battery_box.lua
new file mode 100644 (file)
index 0000000..3a2272a
--- /dev/null
@@ -0,0 +1,269 @@
+-- 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)
+
+minetest.register_craft({
+       output = 'technic:battery 1',
+       recipe = {
+               {'default:wood', 'default:copper_ingot', 'default:wood'},
+               {'default:wood', 'moreores:tin_ingot',   'default:wood'},
+               {'default:wood', 'default:copper_ingot', 'default:wood'},
+       }
+})
+
+minetest.register_tool("technic:battery", {
+       description = "RE Battery",
+       inventory_image = "technic_battery.png",
+       tool_capabilities = {
+               load=0,
+               max_drop_level=0,
+               groupcaps={
+                       fleshy={times={}, uses=10000, maxlevel=0}
+               }
+       }
+})
+
+--------------------------------------------
+-- The Battery box
+--------------------------------------------
+minetest.register_craftitem("technic:battery_box", {
+       description = "Battery box",
+       stack_max = 99,
+})
+
+minetest.register_craft({
+       output = 'technic:battery_box 1',
+       recipe = {
+               {'technic:battery',     'default:wood',         'technic:battery'},
+               {'technic:battery',     'default:copper_ingot', 'technic:battery'},
+               {'default:steel_ingot', 'default:steel_ingot',  'default:steel_ingot'},
+       }
+})
+
+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;Battery box]"..
+       "label[3,0;Charge]"..
+       "label[5,0;Discharge]"..
+       "label[1,3;Power level]"..
+       "list[current_player;main;0,5;8,4;]"
+
+minetest.register_node("technic:battery_box", {
+       description = "LV Battery Box",
+       tiles = {"technic_battery_box_top.png", "technic_battery_box_bottom.png",
+                "technic_battery_box_side0.png", "technic_battery_box_side0.png",
+                "technic_battery_box_side0.png", "technic_battery_box_side0.png"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+       sounds = default.node_sound_wood_defaults(),
+       drop="technic:battery_box",
+       on_construct = function(pos)
+               local meta = minetest.env:get_meta(pos)
+               local inv = meta:get_inventory()
+               meta:set_string("infotext", "Battery box")
+               meta:set_float("technic_power_machine", 1)
+               meta:set_string("formspec", battery_box_formspec)
+               meta:set_int("LV_EU_demand", 0) -- How much can this node charge
+               meta:set_int("LV_EU_supply", 0) -- How much can this node discharge
+               meta:set_int("LV_EU_input",  0) -- How much power is this machine getting.
+               meta:set_float("internal_EU_charge", 0)
+               inv:set_size("src", 1)
+               inv:set_size("dst", 1)
+       end,
+       can_dig = function(pos,player)
+               local meta = minetest.env:get_meta(pos);
+               local inv = meta:get_inventory()
+               if not inv:is_empty("src") or not inv:is_empty("dst") then
+                       minetest.chat_send_player(player:get_player_name(),
+                               "Machine cannot be removed because it is not empty");
+                       return false
+               else
+                       return true
+               end
+       end,
+})
+
+
+for i=1,8,1 do
+   minetest.register_node(
+      "technic:battery_box"..i, {
+        description = "LV Battery Box",
+        tiles = {"technic_battery_box_top.png", "technic_battery_box_bottom.png",
+                 "technic_battery_box_side0.png^technic_power_meter"..i..".png",
+                 "technic_battery_box_side0.png^technic_power_meter"..i..".png",
+                 "technic_battery_box_side0.png^technic_power_meter"..i..".png",
+                 "technic_battery_box_side0.png^technic_power_meter"..i..".png"},
+        groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
+        sounds = default.node_sound_wood_defaults(),
+        drop="technic:battery_box",
+        can_dig = function(pos,player)
+                     local meta = minetest.env:get_meta(pos);
+                     local inv = meta:get_inventory()
+                     if not inv:is_empty("src") or not inv:is_empty("dst") then
+                        minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                        return false
+                     else
+                        return true
+                     end
+                  end,
+      })
+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"},
+    interval = 1,
+    chance = 1,
+    action = function(pos, node, active_object_count, active_object_count_wider)
+               local meta               = minetest.env:get_meta(pos)
+               local max_charge         = 60000 -- Set maximum charge for the device here
+               local max_charge_rate    = 1000  -- Set maximum rate of charging
+               local max_discharge_rate = 2000  -- Set maximum rate of discharging
+               local eu_input           = meta:get_int("LV_EU_input")
+               local current_charge     = meta:get_int("internal_EU_charge") -- Battery charge right now
+
+               -- Power off automatically if no longer connected to a switching station
+               technic.switching_station_timeout_count(pos, "LV")
+
+               -- Charge/discharge the battery with the input EUs
+               if eu_input >=0 then
+                  current_charge = math.min(current_charge+eu_input, max_charge)
+               else
+                  current_charge = math.max(current_charge+eu_input, 0)
+               end
+
+               -- Charging/discharging tools here
+               current_charge = charge_LV_tools(meta, current_charge)
+               current_charge = discharge_LV_tools(meta, current_charge, max_charge)
+
+               -- 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))
+               --print("BA:"..max_charge_rate.."|"..max_charge-current_charge.."|"..math.min(max_charge_rate, max_charge-current_charge))
+
+               -- Set how much we can supply
+               meta:set_int("LV_EU_supply", math.min(max_discharge_rate, current_charge))
+
+               meta:set_int("internal_EU_charge", current_charge)
+               --dprint("BA: input:"..eu_input.." supply="..meta:get_int("LV_EU_supply").." demand="..meta:get_int("LV_EU_demand").." current:"..current_charge)
+
+               -- Select node textures
+               local i=math.ceil((current_charge/max_charge)*8)
+               if i > 8 then i = 8 end
+               local j = meta:get_float("last_side_shown")
+               if i~=j then
+                  if i>0 then hacky_swap_node(pos,"technic:battery_box"..i)
+                  elseif i==0 then hacky_swap_node(pos,"technic:battery_box") end
+                  meta:set_float("last_side_shown",i)
+               end
+
+               local load = math.floor(current_charge/max_charge * 100)
+               meta:set_string("formspec",
+                               battery_box_formspec..
+                                  "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
+                                  (load)..":technic_power_meter_fg.png]"
+                            )
+
+               if eu_input == 0 then
+                  meta:set_string("infotext", "LV Battery box: "..current_charge.."/"..max_charge.." (idle)")
+               else
+                  meta:set_string("infotext", "LV Battery box: "..current_charge.."/"..max_charge)
+               end
+
+            end
+ })
+
+-- Register as a battery type
+-- Battery type machines function as power reservoirs and can both receive and give back power
+technic.register_LV_machine("technic:battery_box","BA")
+for i=1,8,1 do
+   technic.register_LV_machine("technic:battery_box"..i,"BA")
+end
+
diff --git a/technic/machines/lv/cnc.lua b/technic/machines/lv/cnc.lua
new file mode 100644 (file)
index 0000000..8e215ae
--- /dev/null
@@ -0,0 +1,293 @@
+-- Technic CNC v1.0 by kpoppel
+-- Based on the NonCubic Blocks MOD v1.4 by yves_de_beck
+
+-- Idea:
+--   Somehow have a tabbed/paged panel if the number of shapes should expand
+--   beyond what is available in the panel today.
+--   I could imagine some form of API allowing modders to come with their own node
+--   box definitions and easily stuff it in the this machine for production.
+
+
+local shape = {}
+local onesize_products = {
+   slope                    = 2,
+   slope_edge               = 1,
+   slope_inner_edge         = 1,
+   pyramid                  = 2,
+   spike                    = 1,
+   cylinder                 = 2,
+   sphere                   = 1,
+   stick                    = 8,
+   slope_upsdown            = 2,
+   slope_edge_upsdown       = 1,
+   slope_inner_edge_upsdown = 1,
+   cylinder_horizontal      = 2,
+   slope_lying              = 2,
+   onecurvededge            = 1,
+   twocurvededge            = 1,
+}
+local twosize_products = {
+   element_straight         = 4,
+   element_end              = 2,
+   element_cross            = 1,
+   element_t                = 1,
+   element_edge             = 2,
+}
+
+local cnc_formspec =
+   "invsize[9,11;]"..
+   "label[1,0;Choose Milling Program:]"..
+   "image_button[1,0.5;1,1;technic_cnc_slope.png;slope; ]"..
+   "image_button[2,0.5;1,1;technic_cnc_slope_edge.png;slope_edge; ]"..
+   "image_button[3,0.5;1,1;technic_cnc_slope_inner_edge.png;slope_inner_edge; ]"..
+   "image_button[4,0.5;1,1;technic_cnc_pyramid.png;pyramid; ]"..
+   "image_button[5,0.5;1,1;technic_cnc_spike.png;spike; ]"..
+   "image_button[6,0.5;1,1;technic_cnc_cylinder.png;cylinder; ]"..
+   "image_button[7,0.5;1,1;technic_cnc_sphere.png;sphere; ]"..
+   "image_button[8,0.5;1,1;technic_cnc_stick.png;stick; ]"..
+   
+   "image_button[1,1.5;1,1;technic_cnc_slope_upsdwn.png;slope_upsdown; ]"..
+   "image_button[2,1.5;1,1;technic_cnc_slope_edge_upsdwn.png;slope_edge_upsdown; ]"..
+   "image_button[3,1.5;1,1;technic_cnc_slope_inner_edge_upsdwn.png;slope_inner_edge_upsdown; ]"..
+   "image_button[4,1.5;1,1;technic_cnc_cylinder_horizontal.png;cylinder_horizontal; ]"..
+   
+   "image_button[1,2.5;1,1;technic_cnc_slope_lying.png;slope_lying; ]"..
+   "image_button[2,2.5;1,1;technic_cnc_onecurvededge.png;onecurvededge; ]"..
+   "image_button[3,2.5;1,1;technic_cnc_twocurvededge.png;twocurvededge; ]"..
+   
+   "label[1,3.5;Slim Elements half / normal height:]"..
+   
+   "image_button[1,4;1,0.5;technic_cnc_full.png;full; ]"..
+   "image_button[1,4.5;1,0.5;technic_cnc_half.png;half; ]"..
+   "image_button[2,4;1,1;technic_cnc_element_straight.png;element_straight; ]"..
+   "image_button[3,4;1,1;technic_cnc_element_end.png;element_end; ]"..
+   "image_button[4,4;1,1;technic_cnc_element_cross.png;element_cross; ]"..
+   "image_button[5,4;1,1;technic_cnc_element_t.png;element_t; ]"..
+   "image_button[6,4;1,1;technic_cnc_element_edge.png;element_edge; ]"..
+   
+   "label[0, 5.5;In:]"..
+   "list[current_name;src;0.5,5.5;1,1;]"..
+   "label[4, 5.5;Out:]"..
+   "list[current_name;dst;5,5.5;4,1;]"..
+   
+   "list[current_player;main;0,7;8,4;]"
+
+local size     = 1;
+
+-- The form handler is declared here because we need it in both the inactive and active modes
+-- in order to be able to change programs wile it is running.
+local form_handler = function(pos, formname, fields, sender)
+                       -- REGISTER MILLING PROGRAMS AND OUTPUTS:
+                       ------------------------------------------
+                       -- Program for half/full size
+                       if fields["full"] then
+                          size = 1
+                          return
+                       end
+                       
+                       if fields["half"] then
+                          size = 2
+                          return
+                       end
+                       
+                       -- Resolve the node name and the number of items to make
+                       local meta       = minetest.env:get_meta(pos)
+                       local inv        = meta:get_inventory()
+                       local inputstack = inv:get_stack("src", 1)
+                       local inputname  = inputstack:get_name()
+                       local multiplier = 0
+                       for k, _ in pairs(fields) do
+                          -- Set a multipier for the half/full size capable blocks
+                          if twosize_products[k] ~= nil then
+                             multiplier = size*twosize_products[k]
+                          else
+                             multiplier = onesize_products[k]
+                          end
+                          
+                          if onesize_products[k] ~= nil or twosize_products[k] ~= nil then
+                             meta:set_float( "cnc_multiplier", multiplier)
+                             meta:set_string("cnc_user", sender:get_player_name())
+                          end
+                          
+                          if onesize_products[k] ~= nil or (twosize_products[k] ~= nil and size==2) then
+                             meta:set_string("cnc_product",  inputname .. "_technic_cnc_" .. k)
+                             --print(inputname .. "_technic_cnc_" .. k)
+                             break
+                          end
+                          
+                          if twosize_products[k] ~= nil and size==1 then
+                             meta:set_string("cnc_product",  inputname .. "_technic_cnc_" .. k .. "_double")
+                             --print(inputname .. "_technic_cnc_" .. k .. "_double")
+                             break
+                          end
+                       end
+                       return
+                    end -- callback function
+
+-- The actual block inactive state
+minetest.register_node(
+   "technic:cnc",
+   {
+      description = "CNC Milling Machine",
+      tiles       = {"technic_cnc_top.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
+                    "technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front.png"},
+      drawtype    = "nodebox",
+      paramtype   = "light",
+      paramtype2  = "facedir",
+      node_box    = {
+        type  = "fixed",
+        fixed = {
+           {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
+           
+        },
+      },
+      selection_box = {
+        type = "fixed",
+        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
+      },
+      groups = {cracky=2},
+      legacy_facedir_simple = true,
+      on_construct = function(pos)
+                       local meta = minetest.env:get_meta(pos)
+                       meta:set_string("infotext", "CNC Machine")
+                       meta:set_float("technic_power_machine", 1)
+                       meta:set_string("formspec", cnc_formspec)
+                       local inv = meta:get_inventory()
+                       inv:set_size("src", 1)
+                       inv:set_size("dst", 4)
+                    end,
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") or not inv:is_empty("dst") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  else
+                     return true
+                  end
+               end,
+      on_receive_fields = form_handler,
+   })
+
+-- Active state block
+minetest.register_node("technic:cnc_active", {
+                         description = "CNC Machine",
+                         tiles       = {"technic_cnc_top_active.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
+                                        "technic_cnc_side.png",       "technic_cnc_side.png",   "technic_cnc_front_active.png"},
+                         paramtype2 = "facedir",
+                         groups = {cracky=2,not_in_creative_inventory=1},
+                         legacy_facedir_simple = true,
+                         can_dig = function(pos,player)
+                                      local meta = minetest.env:get_meta(pos);
+                                      local inv = meta:get_inventory()
+                                      if not inv:is_empty("src") or not inv:is_empty("dst") then
+                                         minetest.chat_send_player(player:get_player_name(), "CNC machine cannot be removed because it is not empty");
+                                         return false
+                                      end
+                                      return true
+                                   end,
+                         on_receive_fields = form_handler,
+                      })
+
+-- Action code performing the transformation
+minetest.register_abm(
+   { nodenames = {"technic:cnc","technic:cnc_active"},
+     interval = 1,
+     chance   = 1,
+     action = function(pos, node, active_object_count, active_object_count_wider)
+                local meta         = minetest.env:get_meta(pos)
+                local eu_input     = meta:get_int("LV_EU_input")
+                local state        = meta:get_int("state")
+                local next_state   = state
+
+                -- Machine information
+                local machine_name         = "CNC"
+                local machine_node         = "technic:cnc"
+                local machine_state_demand = { 50, 450 }
+                        
+                -- Setup meta data if it does not exist. state is used as an indicator of this
+                if state == 0 then
+                   meta:set_int("state", 1)
+                   meta:set_int("LV_EU_demand", machine_state_demand[1])
+                   meta:set_int("LV_EU_input", 0)
+                   return
+                end
+                        
+                -- Power off automatically if no longer connected to a switching station
+                technic.switching_station_timeout_count(pos, "LV")
+                        
+                -- State machine
+                if eu_input == 0 then
+                   -- Unpowered - go idle
+                   hacky_swap_node(pos, machine_node)
+                   meta:set_string("infotext", machine_name.." Unpowered")
+                   next_state = 1
+                elseif eu_input == machine_state_demand[state] then
+                   -- Powered - do the state specific actions
+                           
+                   local inv   = meta:get_inventory()
+                   local empty = inv:is_empty("src")
+
+                   if state == 1 then
+                      hacky_swap_node(pos, machine_node)
+                      meta:set_string("infotext", machine_name.." Idle")
+
+                      local result = meta:get_string("cnc_product")
+                      if not empty and minetest.registered_nodes[result] ~= nil and inv:room_for_item("dst",result) then
+                         next_state = 2
+                      else
+                         meta:set_string("cnc_product", "") -- Reset the program
+                      end
+                      --minetest.chat_send_player(meta:get_string("cnc_user"), "CNC machine does not know how to handle this material. Please remove it.");
+
+                   elseif state == 2 then
+                      hacky_swap_node(pos, machine_node.."_active")
+                      meta:set_string("infotext", machine_name.." Active")
+
+                      if empty then
+                         next_state = 1
+                      else
+                         meta:set_int("src_time", meta:get_int("src_time") + 1)
+                         if meta:get_int("src_time") >= 3 then -- 3 ticks per output
+                            local result = meta:get_string("cnc_product")
+                            -- check if there's room for output in "dst" list
+                            if inv:room_for_item("dst",result) then
+                               -- CNC does the transformation
+                               ------------------------------
+                               meta:set_int("src_time", 0)
+                               -- take stuff from "src" list
+                               srcstack = inv:get_stack("src", 1)
+                               srcstack:take_item()
+                               inv:set_stack("src", 1, srcstack)
+                               -- Put result in "dst" list
+                               inv:add_item("dst",result .. " " .. meta:get_int("cnc_multiplier"))
+                            else
+                               next_state = 1
+                            end
+                         end
+                      end
+                   end
+                end
+                -- Change state?
+                if next_state ~= state then
+                   meta:set_int("LV_EU_demand", machine_state_demand[next_state])
+                   meta:set_int("state", next_state)
+                end
+             end
+  }) 
+
+technic.register_LV_machine ("technic:cnc","RE")
+technic.register_LV_machine ("technic:cnc_active","RE")
+
+-------------------------
+-- CNC Machine Recipe
+-------------------------
+minetest.register_craft({
+       output = 'technic:cnc',
+       recipe = {
+               {'default:glass',              'technic:diamond_drill_head', 'default:glass'},
+               {'technic:control_logic_unit', 'technic:motor',              'default:steel_ingot'},
+               {'default:steel_ingot',        'default:copper_ingot',       'default:steel_ingot'},         
+       },
+})
+
diff --git a/technic/machines/lv/cnc_api.lua b/technic/machines/lv/cnc_api.lua
new file mode 100644 (file)
index 0000000..2d5e305
--- /dev/null
@@ -0,0 +1,372 @@
+-- API for the technic CNC machine
+-- Again code is adapted from the NonCubic Blocks MOD v1.4 by yves_de_beck
+technic_cnc_api = {}
+
+-- HERE YOU CAN CHANGE THE DETAIL-LEVEL:
+----------------------------------------
+technic_cnc_api.detail_level = 16 -- 16; 1-32
+
+-- REGISTER NONCUBIC FORMS, CREATE MODELS AND RECIPES:
+------------------------------------------------------
+local cnc_sphere =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level
+      local sehne
+      for i = 1, detail-1 do
+        sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
+        nodebox[i]={-sehne, (i/detail)-0.5, -sehne, sehne, (i/detail)+(1/detail)-0.5, sehne}
+      end
+      return nodebox
+   end
+
+local cnc_cylinder_horizontal =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level
+      local sehne
+      for i = 1, detail-1 do
+        sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
+        nodebox[i]={-0.5, (i/detail)-0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, sehne}
+      end
+      return nodebox
+   end
+
+local cnc_cylinder =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level
+      local sehne
+      for i = 1, detail-1 do
+        sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
+        nodebox[i]={(i/detail)-0.5, -0.5, -sehne, (i/detail)+(1/detail)-0.5, 0.5, sehne}
+      end
+      return nodebox
+   end
+
+local cnc_twocurvededge =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level*2
+      local sehne
+      for i = (detail/2)-1, detail-1 do
+        sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
+        nodebox[i]={-sehne, -0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, 0.5}
+      end
+      return nodebox
+   end
+
+local cnc_onecurvededge =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level*2
+      local sehne
+      for i = (detail/2)-1, detail-1 do
+        sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
+        nodebox[i]={-0.5, -0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, 0.5}
+      end 
+     return nodebox
+   end
+
+local cnc_spike =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level
+      for i = 0, detail-1 do
+        nodebox[i+1]={(i/detail/2)-0.5, (i/detail/2)-0.5, (i/detail/2)-0.5, 0.5-(i/detail/2), (i/detail)-0.5+(1/detail), 0.5-(i/detail/2)}
+end
+      return nodebox
+   end
+
+local cnc_pyramid =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level/2
+      for i = 0, detail-1 do
+        nodebox[i+1]={(i/detail/2)-0.5, (i/detail/2)-0.5, (i/detail/2)-0.5, 0.5-(i/detail/2), (i/detail/2)-0.5+(1/detail), 0.5-(i/detail/2)}
+      end
+      return nodebox
+   end
+
+local cnc_slope_inner_edge_upsdown =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level
+      for i = 0, detail-1 do
+        nodebox[i+1]={0.5-(i/detail)-(1/detail), (i/detail)-0.5, -0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
+        nodebox[i+detail+1]={-0.5, (i/detail)-0.5, 0.5-(i/detail)-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
+      end
+      return nodebox
+   end
+
+local cnc_slope_edge_upsdown =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level
+      for i = 0, detail-1 do
+        nodebox[i+1]={(-1*(i/detail))+0.5-(1/detail), (i/detail)-0.5, (-1*(i/detail))+0.5-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
+      end
+      return nodebox
+   end
+
+local cnc_slope_inner_edge =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level
+      for i = 0, detail-1 do
+        nodebox[i+1]={(i/detail)-0.5, -0.5, -0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
+        nodebox[i+detail+1]={-0.5, -0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
+      end
+      return nodebox
+   end
+
+local cnc_slope_edge =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level
+      for i = 0, detail-1 do
+        nodebox[i+1]={(i/detail)-0.5, -0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
+      end
+      return nodebox
+   end
+
+local cnc_slope_upsdown =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level
+      for i = 0, detail-1 do
+        nodebox[i+1]={-0.5, (i/detail)-0.5, (-1*(i/detail))+0.5-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
+      end
+      return nodebox
+   end
+
+local cnc_slope_lying =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level
+      for i = 0, detail-1 do
+        nodebox[i+1]={(i/detail)-0.5, -0.5, (i/detail)-0.5, (i/detail)-0.5+(1/detail), 0.5 , 0.5}
+      end
+      return nodebox
+   end
+
+local cnc_slope =
+   function()
+      local nodebox = {}
+      local detail = technic_cnc_api.detail_level
+      for i = 0, detail-1 do
+        nodebox[i+1]={-0.5, (i/detail)-0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
+      end
+      return nodebox
+   end
+
+-- Define slope boxes for the various nodes
+-------------------------------------------
+technic_cnc_api.cnc_programs = {
+   {suffix  = "technic_cnc_stick",
+    nodebox = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15},
+    desc    = "Stick"},
+
+   {suffix  = "technic_cnc_element_end_double",
+    nodebox = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.5},
+    desc    = "Element End Double"},
+
+   {suffix  = "technic_cnc_element_cross_double",
+    nodebox = {
+       {0.3, -0.5, -0.3, 0.5, 0.5, 0.3},
+       {-0.3, -0.5, -0.5, 0.3, 0.5, 0.5},
+       {-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}},
+    desc    = "Element Cross Double"},
+
+   {suffix  = "technic_cnc_element_t_double",
+    nodebox = {
+       {-0.3, -0.5, -0.5, 0.3, 0.5, 0.3},
+       {-0.5, -0.5, -0.3, -0.3, 0.5, 0.3},
+       {0.3, -0.5, -0.3, 0.5, 0.5, 0.3}},
+    desc    = "Element T Double"},
+
+   {suffix  = "technic_cnc_element_edge_double",
+    nodebox = {
+       {-0.3, -0.5, -0.5, 0.3, 0.5, 0.3},
+       {-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}},
+    desc    = "Element Edge Double"},
+
+   {suffix  = "technic_cnc_element_straight_double",
+    nodebox = {-0.3, -0.5, -0.5, 0.3, 0.5, 0.5},
+    desc    = "Element Straight Double"},
+
+   {suffix  = "technic_cnc_element_end",
+    nodebox = {-0.3, -0.5, -0.3, 0.3, 0, 0.5},
+    desc    = "Element End"},
+
+   {suffix  = "technic_cnc_element_cross",
+    nodebox = {
+       {0.3, -0.5, -0.3, 0.5, 0, 0.3},
+       {-0.3, -0.5, -0.5, 0.3, 0, 0.5},
+       {-0.5, -0.5, -0.3, -0.3, 0, 0.3}},
+    desc    = "Element Cross"},
+
+   {suffix  = "technic_cnc_element_t",
+    nodebox = {
+       {-0.3, -0.5, -0.5, 0.3, 0, 0.3},
+       {-0.5, -0.5, -0.3, -0.3, 0, 0.3},
+       {0.3, -0.5, -0.3, 0.5, 0, 0.3}},
+    desc    = "Element T"},
+
+   {suffix  = "technic_cnc_element_edge",
+    nodebox = {
+       {-0.3, -0.5, -0.5, 0.3, 0, 0.3},
+       {-0.5, -0.5, -0.3, -0.3, 0, 0.3}},
+    desc    = "Element Edge"},
+
+   {suffix  = "technic_cnc_element_straight",
+    nodebox = {-0.3, -0.5, -0.5, 0.3, 0, 0.5},
+    desc    = "Element Straight"},
+
+   {suffix  = "technic_cnc_sphere",
+    nodebox = cnc_sphere(),
+    desc    = "Sphere"},
+
+   {suffix  = "technic_cnc_cylinder_horizontal",
+    nodebox = cnc_cylinder_horizontal(),
+    desc    = "Cylinder Horizontal"},
+
+   {suffix  = "technic_cnc_cylinder",
+    nodebox = cnc_cylinder(),
+    desc    = ""},
+
+   {suffix  = "technic_cnc_twocurvededge",
+    nodebox = cnc_twocurvededge(),
+    desc    = "One Curved Edge Block"},
+
+   {suffix  = "technic_cnc_onecurvededge",
+    nodebox = cnc_onecurvededge(),
+    desc    = "Two Curved Edge Block"},
+
+   {suffix  = "technic_cnc_spike",
+    nodebox = cnc_spike(),
+    desc    = "Spike"},
+
+   {suffix  = "technic_cnc_pyramid",
+    nodebox = cnc_pyramid(),
+    desc    = "Pyramid"},
+
+   {suffix  = "technic_cnc_slope_inner_edge_upsdown",
+    nodebox = cnc_slope_inner_edge_upsdown(),
+    desc    = "Slope Upside Down Inner Edge"},
+
+   {suffix  = "technic_cnc_slope_edge_upsdown",
+    nodebox = cnc_slope_edge_upsdown(),
+    desc    = "Slope Upside Down Edge"},
+
+   {suffix  = "technic_cnc_slope_inner_edge",
+    nodebox = cnc_slope_inner_edge(),
+    desc    = "Slope Inner Edge"},
+
+   {suffix  = "technic_cnc_slope_edge",
+    nodebox = cnc_slope_edge(),
+    desc    = "Slope Edge"},
+
+   {suffix  = "technic_cnc_slope_upsdown",
+    nodebox = cnc_slope_upsdown(),
+    desc    = "Slope Upside Down"},
+
+   {suffix  = "technic_cnc_slope_lying",
+    nodebox = cnc_slope_lying(),
+    desc    = "Slope Lying"},
+
+   {suffix  = "technic_cnc_slope",
+    nodebox = cnc_slope(),
+    desc    = "Slope"},
+--   {suffix  = "",
+--    nodebox =},
+}
+
+-- Allow disabling certain programs for some node. Default is allowing all types for all nodes
+technic_cnc_api.cnc_programs_disable = {
+   -- ["default:brick"] = {"technic_cnc_stick"}, -- Example: Disallow the stick for brick
+   -- ...
+   ["default:dirt"] = {"technic_cnc_sphere", "technic_cnc_slope_upsdown", "technic_cnc_edge",
+                      "technic_cnc_inner_edge", "technic_cnc_slope_edge_upsdown", "technic_cnc_slope_inner_edge_upsdown",
+                      "technic_cnc_stick", "technic_cnc_cylinder_horizontal"}
+}
+
+-- Generic function for registering all the different node types
+function technic_cnc_api.register_cnc_program(recipeitem, suffix, nodebox, groups, images, description)
+   minetest.register_node(":" .. recipeitem .. "_" .. suffix, {
+                            description   = description,
+                            drawtype      = "nodebox",
+                            tiles         = images,
+                            paramtype     = "light",
+                            paramtype2    = "facedir",
+                            walkable      = true,
+                            selection_box = {
+                               type  = "fixed",
+                               fixed = nodebox
+                            },
+                            node_box      = {
+                               type  = "fixed",
+                               fixed = nodebox
+                            },
+                            groups        = groups,
+                         })
+end
+
+-- function to iterate over all the programs the CNC machine knows
+function technic_cnc_api.register_all(recipeitem, groups, images, description)
+   for _, data in ipairs(technic_cnc_api.cnc_programs) do
+      -- Disable node creation for disabled node types for some material
+      local do_register = true
+      if technic_cnc_api.cnc_programs_disable[recipeitem] ~= nil then
+        for __, disable in ipairs(technic_cnc_api.cnc_programs_disable[recipeitem]) do
+           if disable == data.suffix then
+              do_register = false
+           end
+        end
+      end
+      -- Create the node if it passes the test
+      if do_register then
+        technic_cnc_api.register_cnc_program(recipeitem, data.suffix, data.nodebox, groups, images, description.." "..data.desc)
+      end
+   end
+end
+
+
+-- REGISTER NEW TECHNIC_CNC_API's PART 2: technic_cnc_api.register_element_end(subname, recipeitem, groups, images, desc_element_xyz)
+-----------------------------------------------------------------------------------------------------------------------
+function technic_cnc_api.register_slope_edge_etc(recipeitem, groups, images, desc_slope, desc_slope_lying, desc_slope_upsdown, desc_slope_edge, desc_slope_inner_edge, desc_slope_upsdwn_edge, desc_slope_upsdwn_inner_edge, desc_pyramid, desc_spike, desc_onecurvededge, desc_twocurvededge, desc_cylinder, desc_cylinder_horizontal, desc_sphere, desc_element_straight, desc_element_edge, desc_element_t, desc_element_cross, desc_element_end)
+
+         technic_cnc_api.register_slope(recipeitem, groups, images, desc_slope)
+         technic_cnc_api.register_slope_lying(recipeitem, groups, images, desc_slope_lying)
+         technic_cnc_api.register_slope_upsdown(recipeitem, groups, images, desc_slope_upsdown)
+         technic_cnc_api.register_slope_edge(recipeitem, groups, images, desc_slope_edge)
+         technic_cnc_api.register_slope_inner_edge(recipeitem, groups, images, desc_slope_inner_edge)
+         technic_cnc_api.register_slope_edge_upsdown(recipeitem, groups, images, desc_slope_upsdwn_edge)
+         technic_cnc_api.register_slope_inner_edge_upsdown(recipeitem, groups, images, desc_slope_upsdwn_inner_edge)
+         technic_cnc_api.register_pyramid(recipeitem, groups, images, desc_pyramid)
+         technic_cnc_api.register_spike(recipeitem, groups, images, desc_spike)
+         technic_cnc_api.register_onecurvededge(recipeitem, groups, images, desc_onecurvededge)
+         technic_cnc_api.register_twocurvededge(recipeitem, groups, images, desc_twocurvededge)
+         technic_cnc_api.register_cylinder(recipeitem, groups, images, desc_cylinder)
+         technic_cnc_api.register_cylinder_horizontal(recipeitem, groups, images, desc_cylinder_horizontal)
+         technic_cnc_api.register_sphere(recipeitem, groups, images, desc_sphere)
+         technic_cnc_api.register_element_straight(recipeitem, groups, images, desc_element_straight)
+         technic_cnc_api.register_element_edge(recipeitem, groups, images, desc_element_edge)
+         technic_cnc_api.register_element_t(recipeitem, groups, images, desc_element_t)
+         technic_cnc_api.register_element_cross(recipeitem, groups, images, desc_element_cross)
+         technic_cnc_api.register_element_end(recipeitem, groups, images, desc_element_end)
+end
+
+-- REGISTER STICKS: noncubic.register_xyz(recipeitem, groups, images, desc_element_xyz)
+------------------------------------------------------------------------------------------------------------
+function technic_cnc_api.register_stick_etc(recipeitem, groups, images, desc_stick)
+         technic_cnc_api.register_stick(recipeitem, groups, images, desc_stick)
+end
+
+function technic_cnc_api.register_elements(recipeitem, groups, images, desc_element_straight_double, desc_element_edge_double, desc_element_t_double, desc_element_cross_double, desc_element_end_double)
+         technic_cnc_api.register_element_straight_double(recipeitem, groups, images, desc_element_straight_double)
+         technic_cnc_api.register_element_edge_double(recipeitem, groups, images, desc_element_edge_double)
+         technic_cnc_api.register_element_t_double(recipeitem, groups, images, desc_element_t_double)
+         technic_cnc_api.register_element_cross_double(recipeitem, groups, images, desc_element_cross_double)
+         technic_cnc_api.register_element_end_double(recipeitem, groups, images, desc_element_end_double)
+end
diff --git a/technic/machines/lv/cnc_nodes.lua b/technic/machines/lv/cnc_nodes.lua
new file mode 100644 (file)
index 0000000..3d263b9
--- /dev/null
@@ -0,0 +1,70 @@
+-- REGISTER MATERIALS AND PROPERTIES FOR NONCUBIC ELEMENTS:
+-----------------------------------------------------------
+-- DIRT
+-------
+technic_cnc_api.register_all("default:dirt",
+                {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
+                {"default_grass.png", "default_dirt.png", "default_grass.png"},
+                "Dirt")
+technic_cnc_api.cnc_programs_disable["default:dirt"] = {"technic_cnc_sphere", "technic_cnc_slope_upsdown",
+                                                       "technic_cnc_edge",   "technic_cnc_inner_edge",
+                                                       "technic_cnc_slope_edge_upsdown", "technic_cnc_slope_inner_edge_upsdown",
+                                                       "technic_cnc_stick", "technic_cnc_cylinder_horizontal"}
+
+-- TREE
+-------
+technic_cnc_api.register_all("default:tree",
+                {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
+                {"default_tree.png"},
+                "Wooden")
+
+-- WOOD
+-------
+technic_cnc_api.register_all("default:wood",
+                {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
+                {"default_wood.png"},
+                "Wooden")
+-- STONE
+--------
+technic_cnc_api.register_all("default:stone",
+                {cracky=3,not_in_creative_inventory=1},
+                {"default_stone.png"},
+                "Stone")
+-- COBBLE
+---------
+technic_cnc_api.register_all("default:cobble",
+                {cracky=3,not_in_creative_inventory=1},
+                {"default_cobble.png"},
+                "Cobble")
+-- BRICK
+--------
+technic_cnc_api.register_all("default:brick",
+                {cracky=3,not_in_creative_inventory=1},
+                {"default_brick.png"},
+                "Brick")
+
+-- SANDSTONE
+------------
+technic_cnc_api.register_all("default:sandstone",
+                {crumbly=2,cracky=2,not_in_creative_inventory=1},
+                {"default_sandstone.png"},
+                "Sandstone")
+
+-- LEAVES
+---------
+technic_cnc_api.register_all("default:leaves",
+                {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
+                {"default_leaves.png"},
+                "Leaves")
+-- TREE
+-------
+technic_cnc_api.register_all("default:tree",
+                {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1,not_in_creative_inventory=1},
+                {"default_tree.png"},
+                "Tree")
+-- STEEL
+--------
+technic_cnc_api.register_all("default:steel",
+                {snappy=1,bendy=2,cracky=1,melty=2,level=2,not_in_creative_inventory=1},
+                {"default_steel_block.png"},
+                "Steel")
diff --git a/technic/machines/lv/electric_furnace.lua b/technic/machines/lv/electric_furnace.lua
new file mode 100644 (file)
index 0000000..0c1f43e
--- /dev/null
@@ -0,0 +1,160 @@
+-- LV Electric Furnace
+-- This is a faster version of the stone furnace which runs on EUs
+
+-- FIXME: kpoppel I'd like to introduce an induction heating element here also
+minetest.register_craft(
+   {output = 'technic:electric_furnace',
+    recipe = {
+       {'default:cobble',      'default:cobble',        'default:cobble'},
+       {'default:cobble',      '',                      'default:cobble'},
+       {'default:steel_ingot', 'moreores:copper_ingot', 'default:steel_ingot'},
+    }
+ })
+
+local electric_furnace_formspec =
+   "invsize[8,9;]"..
+   "list[current_name;src;3,1;1,1;]"..
+   "list[current_name;dst;5,1;2,2;]"..
+   "list[current_player;main;0,5;8,4;]"..
+   "label[0,0;Electric Furnace]"..
+   "label[1,3;Power level]"
+
+minetest.register_node(
+   "technic:electric_furnace",
+   {description = "Electric furnace",
+    tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
+            "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front.png"},
+    paramtype2 = "facedir",
+    groups = {cracky=2},
+    legacy_facedir_simple = true,
+    sounds = default.node_sound_stone_defaults(),
+    on_construct = function(pos)
+                     local meta = minetest.env:get_meta(pos)
+                     meta:set_string("infotext", "Electric Furnace")
+                     meta:set_float("technic_power_machine", 1)
+                     meta:set_string("formspec", electric_furnace_formspec)
+                     local inv = meta:get_inventory()
+                     inv:set_size("src", 1)
+                     inv:set_size("dst", 4)
+                  end,
+    can_dig = function(pos,player)
+                local meta = minetest.env:get_meta(pos);
+                local inv = meta:get_inventory()
+                if not inv:is_empty("src") or not inv:is_empty("dst") then
+                   minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                   return false
+                else
+                   return true
+                end
+             end,
+ })
+
+minetest.register_node(
+   "technic:electric_furnace_active",
+   {description = "Electric Furnace",
+    tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
+            "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front_active.png"},
+    paramtype2 = "facedir",
+    light_source = 8,
+    drop = "technic:electric_furnace",
+    groups = {cracky=2, not_in_creative_inventory=1},
+    legacy_facedir_simple = true,
+    sounds = default.node_sound_stone_defaults(),
+    can_dig = function(pos,player)
+                local meta = minetest.env:get_meta(pos);
+                local inv = meta:get_inventory()
+                if not inv:is_empty("src") or not inv:is_empty("dst") then
+                   minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                   return false
+                else
+                   return true
+                end
+             end,
+ })
+
+minetest.register_abm(
+   { nodenames = {"technic:electric_furnace","technic:electric_furnace_active"},
+     interval = 1,
+     chance   = 1,
+     action = function(pos, node, active_object_count, active_object_count_wider)
+                local meta         = minetest.env:get_meta(pos)
+                local eu_input     = meta:get_int("LV_EU_input")
+                local state        = meta:get_int("state")
+                local next_state   = state
+
+                -- Machine information
+                local machine_name         = "Electric furnace"
+                local machine_node         = "technic:electric_furnace"
+                local machine_state_demand = { 50, 1000 }
+                        
+                -- Setup meta data if it does not exist. state is used as an indicator of this
+                if state == 0 then
+                   meta:set_int("state", 1)
+                   meta:set_int("LV_EU_demand", machine_state_demand[1])
+                   meta:set_int("LV_EU_input", 0)
+                   return
+                end
+                        
+                -- Power off automatically if no longer connected to a switching station
+                technic.switching_station_timeout_count(pos, "LV")
+                        
+                -- State machine
+                if eu_input == 0 then
+                   -- Unpowered - go idle
+                   hacky_swap_node(pos, machine_node)
+                   meta:set_string("infotext", machine_name.." Unpowered")
+                   next_state = 1
+                elseif eu_input == machine_state_demand[state] then
+                   -- Powered - do the state specific actions
+                           
+                   -- Execute always if powered logic
+                   local inv    = meta:get_inventory()
+                   local empty  = inv:is_empty("src")
+
+                   if state == 1 then
+                      hacky_swap_node(pos, machine_node)
+                      meta:set_string("infotext", machine_name.." Idle")
+
+                      local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
+                      if not empty and result and inv:room_for_item("dst",result) then
+                         next_state = 2
+                      end
+
+                   elseif state == 2 then
+                      hacky_swap_node(pos, machine_node.."_active")
+                      meta:set_string("infotext", machine_name.." Active")
+
+                      if empty then
+                         next_state = 1
+                      else
+                         meta:set_int("src_time", meta:get_int("src_time") + 3) -- Cooking time 3x
+                         local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
+                         if result and result.item and meta:get_int("src_time") >= result.time then
+                            -- check if there's room for output in "dst" list
+                            meta:set_int("src_time", 0)
+                            if inv:room_for_item("dst",result.item) then
+                               -- take stuff from "src" list
+                               srcstack = inv:get_stack("src", 1)
+                               srcstack:take_item()
+                               inv:set_stack("src", 1, srcstack)
+                               -- Put result in "dst" list
+                               inv:add_item("dst", result.item)
+                            else
+                               -- all full: go idle
+                               next_state = 1
+                            end
+                         end
+                      end
+                   end
+                end
+                -- Change state?
+                if next_state ~= state then
+                   meta:set_int("LV_EU_demand", machine_state_demand[next_state])
+                   meta:set_int("state", next_state)
+                end
+             end,
+  })
+
+technic.register_LV_machine ("technic:electric_furnace","RE")
+technic.register_LV_machine ("technic:electric_furnace_active","RE")
+
diff --git a/technic/machines/lv/extractor.lua b/technic/machines/lv/extractor.lua
new file mode 100644 (file)
index 0000000..d4fe1cc
--- /dev/null
@@ -0,0 +1,220 @@
+technic.extractor_recipes ={}
+
+technic.register_extractor_recipe = function(src, src_count, dst, dst_count)
+                                  technic.extractor_recipes[src] = {src_count = src_count, dst_name = dst, dst_count = dst_count}
+                                  if unified_inventory then
+                                     unified_inventory.register_craft(
+                                        {
+                                           type = "extracting",
+                                           output = dst.." "..dst_count,
+                                           items = {src.." "..src_count},
+                                           width = 0,
+                                        })
+                                  end
+                               end
+
+-- Receive an ItemStack of result by an ItemStack input
+technic.get_extractor_recipe = function(item)
+                               if technic.extractor_recipes[item.name]
+                                  and item.count >= technic.extractor_recipes[item.name].src_count then
+                                  return technic.extractor_recipes[item.name]
+                               else
+                                  return nil
+                               end
+                            end
+
+
+
+technic.register_extractor_recipe("technic:coal_dust", 1, "dye:black", 2)
+technic.register_extractor_recipe("default:cactus", 1, "dye:green", 2)
+technic.register_extractor_recipe("default:dry_shrub", 1, "dye:brown", 2)
+technic.register_extractor_recipe("flowers:geranium", 1, "dye:blue", 2)
+technic.register_extractor_recipe("flowers:dandelion_white", 1, "dye:white", 2)
+technic.register_extractor_recipe("flowers:dandelion_yellow", 1, "dye:yellow", 2)
+technic.register_extractor_recipe("flowers:tulip", 1, "dye:orange", 2)
+technic.register_extractor_recipe("flowers:rose", 1, "dye:red", 2)
+technic.register_extractor_recipe("flowers:viola", 1, "dye:violet", 2)
+technic.register_extractor_recipe("technic:raw_latex", 1, "technic:rubber", 3)
+technic.register_extractor_recipe("moretrees:rubber_tree_trunk_empty", 1, "technic:rubber", 1)
+technic.register_extractor_recipe("moretrees:rubber_tree_trunk", 1, "technic:rubber", 1)
+technic.register_extractor_recipe("technic:uranium", 5, "technic:enriched_uranium", 1)
+
+minetest.register_alias("extractor", "technic:extractor")
+minetest.register_craft({
+                          output = 'technic:extractor',
+                          recipe = {
+                             {'technic:treetap', 'technic:motor', 'technic:treetap'},
+                             {'technic:treetap', 'technic:lv_cable', 'technic:treetap'},
+                             {'','',''},
+                          }
+                       })
+
+minetest.register_craftitem("technic:extractor", {
+                              description = "Extractor",
+                              stack_max = 99,
+                           })
+
+local extractor_formspec =
+   "invsize[8,9;]"..
+   "label[0,0;Extractor]"..
+   "list[current_name;src;3,1;1,1;]"..
+   "list[current_name;dst;5,1;2,2;]"..
+   "list[current_player;main;0,5;8,4;]"
+
+minetest.register_node(
+   "technic:extractor",
+   {
+      description = "Extractor",
+      tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
+              "technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
+      paramtype2 = "facedir",
+      groups = {cracky=2},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_wood_defaults(),
+      on_construct = function(pos)
+                       local meta = minetest.env:get_meta(pos)
+                       meta:set_string("infotext", "Extractor")
+                       meta:set_float("technic_power_machine", 1)
+                       meta:set_string("formspec", extractor_formspec)
+                       local inv = meta:get_inventory()
+                       inv:set_size("src", 1)
+                       inv:set_size("dst", 4)
+                    end,
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") or not inv:is_empty("dst") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  else
+                     return true
+                  end
+               end,
+   })
+
+minetest.register_node(
+   "technic:extractor_active",
+   {
+      description = "Extractor",
+      tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
+              "technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front_active.png"},
+      paramtype2 = "facedir",
+      groups = {cracky=2,not_in_creative_inventory=1},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_wood_defaults(),
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") or not inv:is_empty("dst") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  else
+                     return true
+                  end
+               end,
+   })
+
+minetest.register_abm(
+   { nodenames = {"technic:extractor","technic:extractor_active"},
+     interval = 1,
+     chance   = 1,
+     action = function(pos, node, active_object_count, active_object_count_wider)
+                -- Run a machine through its states. Takes the same arguments as the ABM action
+                -- and adds the machine's states and any extra data which is needed by the machine.
+                -- A machine is characterized by running through a set number of states (usually 2:
+                -- Idle and active) in some order. A state decides when to move to the next one
+                -- and the machine only changes state if it is powered correctly.
+                -- The machine will automatically shut down if disconnected from power in some fashion.
+                local meta         = minetest.env:get_meta(pos)
+                local eu_input     = meta:get_int("LV_EU_input")
+                local state        = meta:get_int("state")
+                local next_state   = state
+
+                -- Machine information
+                local machine_name         = "Extractor"
+                local machine_node         = "technic:extractor"
+                local machine_state_demand = { 50, 300 }
+                        
+                -- Setup meta data if it does not exist. state is used as an indicator of this
+                if state == 0 then
+                   meta:set_int("state", 1)
+                   meta:set_int("LV_EU_demand", machine_state_demand[1])
+                   meta:set_int("LV_EU_input", 0)
+                   return
+                end
+                        
+                -- Power off automatically if no longer connected to a switching station
+                technic.switching_station_timeout_count(pos, "LV")
+                        
+                -- State machine
+                if eu_input == 0 then
+                   -- unpowered - go idle
+                   hacky_swap_node(pos, machine_node)
+                   meta:set_string("infotext", machine_name.." Unpowered")
+                   next_state = 1
+                elseif eu_input == machine_state_demand[state] then
+                   -- Powered - do the state specific actions
+                           
+                   local inv    = meta:get_inventory()
+                   local empty  = inv:is_empty("src")
+                   local srcstack  = inv:get_stack("src", 1)
+                   local src_item = nil
+                   local recipe = nil
+                   local result = nil
+                   
+                   if srcstack then
+                      src_item = srcstack:to_table()
+                   end
+                   if src_item then
+                      recipe = technic.get_extractor_recipe(src_item)
+                   end
+                   if recipe then
+                      result = {name=recipe.dst_name, count=recipe.dst_count}
+                   end 
+                   
+                   if state == 1 then
+                      hacky_swap_node(pos, machine_node)
+                      meta:set_string("infotext", machine_name.." Idle")
+
+                      if not empty and result and inv:room_for_item("dst",result) then
+                         meta:set_int("src_time", 0)
+                         next_state = 2
+                      end
+
+                   elseif state == 2 then
+                      hacky_swap_node(pos, machine_node.."_active")
+                      meta:set_string("infotext", machine_name.." Active")
+
+                      if empty then
+                         next_state = 1
+                      else
+                         meta:set_int("src_time", meta:get_int("src_time") + 1)
+                         if meta:get_int("src_time") == 4 then -- 4 ticks per output
+                            -- check if there's room for output in "dst" list
+
+                            meta:set_int("src_time", 0)
+                            if recipe and inv:room_for_item("dst",result) then
+                               -- take stuff from "src" list
+                               srcstack:take_item(recipe.src_count)
+                               inv:set_stack("src", 1, srcstack)
+                               -- Put result in "dst" list
+                               inv:add_item("dst", result)
+                            else
+                               -- all full: go idle
+                               next_state = 1
+                            end
+                         end
+                      end
+                   end
+                end
+                -- Change state?
+                if next_state ~= state then
+                   meta:set_int("LV_EU_demand", machine_state_demand[next_state])
+                   meta:set_int("state", next_state)
+                end
+             end
+  })
+
+technic.register_LV_machine ("technic:extractor","RE")
+technic.register_LV_machine ("technic:extractor_active","RE")
+
diff --git a/technic/machines/lv/generator.lua b/technic/machines/lv/generator.lua
new file mode 100644 (file)
index 0000000..21db4b4
--- /dev/null
@@ -0,0 +1,150 @@
+-- The coal driven EU generator.
+-- A simple device to get started on the electric machines.
+-- Inefficient and expensive in coal (200EU 16 ticks)
+-- Also only allows for LV machinery to run.
+minetest.register_alias("generator", "technic:generator")
+minetest.register_alias("generator", "technic:generator_active")
+
+minetest.register_craft({
+       output = 'technic:generator',
+       recipe = {
+               {'default:stone', 'default:stone', 'default:stone'},
+               {'default:stone', '', 'default:stone'},
+               {'default:stone', 'default:copper_ingot', 'default:stone'},
+       }
+})
+
+minetest.register_craftitem("technic:generator", {
+       description = "Coal Driven Generator",
+       stack_max = 99,
+}) 
+
+local generator_formspec =
+       "invsize[8,9;]"..
+       "image[0,0;5,5;technic_generator_menu.png]"..
+       "image[1,1;1,2;technic_power_meter_bg.png]"..
+--     "label[0,0;Generator]"..
+       "label[1,3;Power level]"..
+       "list[current_name;src;3,1;1,1;]"..
+       "image[4,1;1,1;default_furnace_fire_bg.png]"..
+       "list[current_player;main;0,5;8,4;]"
+       
+
+minetest.register_node(
+   "technic:generator",
+   {
+      description = "Coal Driven Generator",
+      tiles = {"technic_generator_top.png", "technic_machine_bottom.png", "technic_generator_side.png",
+              "technic_generator_side.png", "technic_generator_side.png", "technic_generator_front.png"},
+      paramtype2 = "facedir",
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_wood_defaults(),
+      on_construct = function(pos)
+                       local meta = minetest.env:get_meta(pos)
+                       meta:set_string("infotext", "Coal Electric Generator")
+                       meta:set_float("technic_power_machine", 1)
+                       meta:set_int("LV_EU_supply", 0)
+                       meta:set_int("LV_EU_from_fuel", 1) -- Signal to the switching station that this device burns some sort of fuel and needs special handling
+                       meta:set_int("burn_time", 0)
+                       meta:set_string("formspec", generator_formspec)
+                       local inv = meta:get_inventory()
+                       inv:set_size("src", 1)
+               end,    
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  else
+                     return true
+                  end
+               end,
+   })
+
+minetest.register_node(
+   "technic:generator_active",
+   {
+      description = "Coal Driven Generator",
+      tiles = {"technic_generator_top.png", "technic_machine_bottom.png", "technic_generator_side.png",
+              "technic_generator_side.png", "technic_generator_side.png", "technic_generator_front_active.png"},
+      paramtype2 = "facedir",
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_wood_defaults(),
+      drop="technic:generator",
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  else
+                     return true
+                  end
+               end,
+   })
+
+minetest.register_abm(
+   {
+      nodenames = {"technic:generator","technic:generator_active"},
+      interval = 1,
+      chance   = 1,
+      action = function(pos, node, active_object_count, active_object_count_wider)
+                 local meta = minetest.env:get_meta(pos)
+                 local burn_time= meta:get_int("burn_time")
+
+                 -- If more to burn and the energy produced was used: produce some more
+                 if burn_time>0 then
+                    if meta:get_int("LV_EU_supply") == 0 then
+                       -- We did not use the power
+                       meta:set_int("LV_EU_supply", 200) -- Give 200EUs
+                    else
+                       burn_time = burn_time - 1
+                       meta:set_int("burn_time",burn_time)
+                       meta:set_string("infotext", "Coal Electric Generator ("..math.floor(burn_time/16*100).."%)")
+                    end
+                 end
+
+                 -- Burn another piece of coal
+                 if burn_time==0 then
+                    local inv = meta:get_inventory()
+                    if inv:is_empty("src") == false  then 
+                       local srcstack = inv:get_stack("src", 1)
+                       src_item=srcstack:to_table()
+                       if src_item["name"] == "default:coal_lump" then
+                          srcstack:take_item()
+                          inv:set_stack("src", 1, srcstack)
+                          burn_time=16
+                          meta:set_int("burn_time",burn_time)
+                          hacky_swap_node (pos,"technic:generator_active") 
+                          meta:set_int("LV_EU_supply", 200) -- Give 200EUs
+                       else
+                          meta:set_int("LV_EU_supply", 0)
+                       end
+                    end
+                 end
+
+                 local load = 8 -- math.floor((charge/max_charge)*100)
+                 local percent = math.floor((burn_time/16)*100)
+                 meta:set_string("formspec",
+                                 "invsize[8,9;]"..
+                                    "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
+                                    (load)..":technic_power_meter_fg.png]"..
+                                 "label[0,0;Generator]"..
+                                 "label[1,3;Power level]"..
+                                 "list[current_name;src;3,1;1,1;]"..
+                                 "image[4,1;1,1;default_furnace_fire_bg.png^[lowpart:"..
+                                 (percent)..":default_furnace_fire_fg.png]"..
+                              "list[current_player;main;0,5;8,4;]"
+                        )
+
+                 if burn_time==0 then
+                    hacky_swap_node (pos,"technic:generator")
+                 end
+              end
+   })
+
+technic.register_LV_machine ("technic:generator","PR")
+technic.register_LV_machine ("technic:generator_active","PR")
diff --git a/technic/machines/lv/geothermal.lua b/technic/machines/lv/geothermal.lua
new file mode 100644 (file)
index 0000000..5ba7a23
--- /dev/null
@@ -0,0 +1,156 @@
+-- A geothermal EU generator
+-- Using hot lava and water this device can create energy from steam
+-- The machine is only producing LV EUs and can thus not drive more advanced equipment
+-- The output is a little more than the coal burning generator (max 300EUs)
+minetest.register_alias("geothermal", "technic:geothermal")
+
+minetest.register_craft({
+       output = 'technic:geothermal',
+       recipe = {
+               {'default:stone', 'default:stone', 'default:stone'},
+               {'default:copper_ingot', 'default:diamond', 'default:copper_ingot'},
+               {'default:stone', 'default:copper_ingot', 'default:stone'},
+       }
+})
+
+minetest.register_craftitem("technic:geothermal", {
+       description = "Geothermal Generator",
+       stack_max = 99,
+}) 
+
+local geothermal_formspec =
+       "invsize[8,4;]"..
+       "image[1,1;1,2;technic_power_meter_bg.png]"..
+       "label[0,0;Geothermal Generator]"..
+       "label[1,3;Power level]"..
+       "list[current_player;main;0,5;8,4;]"
+       
+
+minetest.register_node(
+   "technic:geothermal",
+   {
+      description = "Geothermal Generator",
+      tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
+              "technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
+      paramtype2 = "facedir",
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_wood_defaults(),
+      on_construct = function(pos)
+                       local meta = minetest.env:get_meta(pos)
+                       meta:set_string("infotext", "Geothermal Generator")
+                       meta:set_float("technic_power_machine", 1)
+                       meta:set_int("LV_EU_supply", 0)
+                       meta:set_string("formspec", geothermal_formspec)        
+                    end,       
+   })
+
+minetest.register_node(
+   "technic:geothermal_active",
+   {
+      description = "Geothermal Generator",
+      tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
+              "technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
+      paramtype2 = "facedir",
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_wood_defaults(),
+      drop="technic:geothermal",
+   })
+
+local check_node_around = function(pos)
+                            local node=minetest.env:get_node(pos)
+                            if node.name=="default:water_source" or node.name=="default:water_flowing" then return 1 end
+                            if node.name=="default:lava_source" or node.name=="default:lava_flowing" then return 2 end 
+                            return 0
+                         end
+
+minetest.register_abm(
+   {
+      nodenames = {"technic:geothermal","technic:geothermal_active"},
+      interval = 1,
+      chance   = 1,
+      action = function(pos, node, active_object_count, active_object_count_wider)
+                 local meta             = minetest.env:get_meta(pos)
+                 local water_nodes      = 0
+                 local lava_nodes       = 0
+                 local production_level = 0
+                 local eu_supply        = 0
+
+                 -- Correct positioning is water on one side and lava on the other.
+                 -- The two cannot be adjacent because the lava the turns into obsidian or rock.
+                 -- To get to 100% production stack the water and lava one extra block down as well:
+                 --    WGL (W=Water, L=Lava, G=the generator, |=an LV cable)
+                  --    W|L
+                 pos.x=pos.x+1
+                 local check=check_node_around(pos)
+                 if check==1 then water_nodes=water_nodes+1 end
+                 if check==2 then lava_nodes=lava_nodes+1 end
+                 pos.y=pos.y-1
+                 local check=check_node_around(pos)
+                 if check==1 then water_nodes=water_nodes+1 end
+                 if check==2 then lava_nodes=lava_nodes+1 end
+
+                 pos.x=pos.x-2
+                 check=check_node_around(pos)
+                 if check==1 then water_nodes=water_nodes+1 end
+                 if check==2 then lava_nodes=lava_nodes+1 end
+                 pos.y=pos.y+1
+                 check=check_node_around(pos)
+                 if check==1 then water_nodes=water_nodes+1 end
+                 if check==2 then lava_nodes=lava_nodes+1 end
+
+                 pos.x=pos.x+1
+                 pos.z=pos.z+1
+                 check=check_node_around(pos)
+                 if check==1 then water_nodes=water_nodes+1 end
+                 if check==2 then lava_nodes=lava_nodes+1 end
+                 pos.y=pos.y-1
+                 check=check_node_around(pos)
+                 if check==1 then water_nodes=water_nodes+1 end
+                 if check==2 then lava_nodes=lava_nodes+1 end
+
+                 pos.z=pos.z-2
+                 check=check_node_around(pos)
+                 if check==1 then water_nodes=water_nodes+1 end
+                 if check==2 then lava_nodes=lava_nodes+1 end
+                 pos.y=pos.y+1
+                 check=check_node_around(pos)
+                 if check==1 then water_nodes=water_nodes+1 end
+                 if check==2 then lava_nodes=lava_nodes+1 end
+
+                 -- Back to (0,0,0)
+                 pos.z=pos.z+1
+       
+                 if water_nodes==1 and lava_nodes==1 then production_level =  25; eu_supply = 50 end
+                 if water_nodes==2 and lava_nodes==1 then production_level =  50; eu_supply = 100 end
+                 if water_nodes==1 and lava_nodes==2 then production_level =  75; eu_supply = 200 end
+                 if water_nodes==2 and lava_nodes==2 then production_level = 100; eu_supply = 300 end
+
+                 if production_level>0 then
+                    meta:set_int("LV_EU_supply", eu_supply)
+                 end
+
+                 local load = 1 -- math.floor((charge/max_charge)*100)
+                 meta:set_string("formspec",
+                                 "invsize[8,4;]"..
+                                    "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
+                                    (load)..":technic_power_meter_fg.png]"..
+                                 "label[0,0;Geothermal Generator]"..
+                                 "label[1,3;Power level]"..
+                                 "label[4,0;Production at "..tostring(production_level).."%]"
+                           )
+                               
+                 if production_level>0 and minetest.env:get_node(pos).name=="technic:geothermal" then
+                    hacky_swap_node (pos,"technic:geothermal_active")
+                    return
+                 end
+                 if production_level==0 then
+                    hacky_swap_node (pos,"technic:geothermal")
+                    meta:set_int("LV_EU_supply", 0)
+                 end
+              end
+   }) 
+
+technic.register_LV_machine ("technic:geothermal","PR")
+technic.register_LV_machine ("technic:geothermal_active","PR")
diff --git a/technic/machines/lv/grinder.lua b/technic/machines/lv/grinder.lua
new file mode 100644 (file)
index 0000000..baef12d
--- /dev/null
@@ -0,0 +1,352 @@
+technic.grinder_recipes ={}
+
+technic.register_grinder_recipe = function(src, dst)
+                                  technic.grinder_recipes[src] = dst
+                                  if unified_inventory then
+                                     unified_inventory.register_craft(
+                                        {
+                                           type = "grinding",
+                                           output = dst,
+                                           items = {src},
+                                           width = 0,
+                                        })
+                                  end
+                               end
+
+-- Receive an ItemStack of result by an ItemStack input
+technic.get_grinder_recipe = function(itemstack)
+                               local src_item  = itemstack:to_table()
+                               if src_item == nil then
+                                  return nil
+                               end
+                               local item_name = src_item["name"]
+                               if technic.grinder_recipes[item_name] then
+                                  return ItemStack(technic.grinder_recipes[item_name])
+                               else
+                                  return nil
+                               end
+                            end
+
+
+technic.register_grinder_recipe("default:stone","default:sand")
+technic.register_grinder_recipe("default:cobble","default:gravel")
+technic.register_grinder_recipe("default:gravel","default:dirt")
+technic.register_grinder_recipe("default:desert_stone","default:desert_sand")
+technic.register_grinder_recipe("default:iron_lump","technic:iron_dust 2")
+technic.register_grinder_recipe("default:steel_ingot","technic:iron_dust 1")
+technic.register_grinder_recipe("default:coal_lump","technic:coal_dust 2")
+technic.register_grinder_recipe("default:copper_lump","technic:copper_dust 2")
+technic.register_grinder_recipe("default:copper_ingot","technic:copper_dust 1")
+technic.register_grinder_recipe("default:gold_lump","technic:gold_dust 2")
+technic.register_grinder_recipe("default:gold_ingot","technic:gold_dust 1")
+--technic.register_grinder_recipe("default:bronze_ingot","technic:bronze_dust 1")  -- Dust does not exist yet
+--technic.register_grinder_recipe("home_decor:brass_ingot","technic:brass_dust 1") -- needs check for the mod
+technic.register_grinder_recipe("moreores:tin_lump","technic:tin_dust 2")
+technic.register_grinder_recipe("moreores:tin_ingot","technic:tin_dust 1")
+technic.register_grinder_recipe("moreores:silver_lump","technic:silver_dust 2")
+technic.register_grinder_recipe("moreores:silver_ingot","technic:silver_dust 1")
+technic.register_grinder_recipe("moreores:mithril_lump","technic:mithril_dust 2")
+technic.register_grinder_recipe("moreores:mithril_ingot","technic:mithril_dust 1")
+technic.register_grinder_recipe("technic:chromium_lump","technic:chromium_dust 2")
+technic.register_grinder_recipe("technic:chromium_ingot","technic:chromium_dust 1")
+technic.register_grinder_recipe("technic:stainless_steel_ingot","stainless_steel_dust 1")
+technic.register_grinder_recipe("technic:brass_ingot","technic:brass_dust 1")
+technic.register_grinder_recipe("technic:zinc_lump","technic:zinc_dust 2")
+technic.register_grinder_recipe("technic:zinc_ingot","technic:zinc_dust 1")
+
+minetest.register_craftitem( "technic:coal_dust", {
+                               description = "Coal Dust",
+                               inventory_image = "technic_coal_dust.png",
+                               on_place_on_ground = minetest.craftitem_place_item,
+                            })
+
+minetest.register_craftitem( "technic:iron_dust", {
+                               description = "Iron Dust",
+                               inventory_image = "technic_iron_dust.png",
+                               on_place_on_ground = minetest.craftitem_place_item,
+                            })
+
+minetest.register_craft({
+                          type = "cooking",
+                          output = "default:steel_ingot",
+                          recipe = "technic:iron_dust",
+                       })
+
+minetest.register_craftitem( "technic:copper_dust", {
+                               description = "Copper Dust",
+                               inventory_image = "technic_copper_dust.png",
+                               on_place_on_ground = minetest.craftitem_place_item,
+                            })
+minetest.register_craft({
+                          type = "cooking",
+                          output = "moreores:copper_ingot",
+                          recipe = "technic:copper_dust",
+                       })
+
+minetest.register_craftitem( "technic:tin_dust", {
+                               description = "Tin Dust",
+                               inventory_image = "technic_tin_dust.png",
+                               on_place_on_ground = minetest.craftitem_place_item,
+                            })
+minetest.register_craft({
+                          type = "cooking",
+                          output = "moreores:tin_ingot",
+                          recipe = "technic:tin_dust",
+                       })
+
+minetest.register_craftitem( "technic:silver_dust", {
+                               description = "Silver Dust",
+                               inventory_image = "technic_silver_dust.png",
+                               on_place_on_ground = minetest.craftitem_place_item,
+                            })
+minetest.register_craft({
+                          type = "cooking",
+                          output = "moreores:silver_ingot",
+                          recipe = "technic:silver_dust",
+                       })
+
+minetest.register_craftitem( "technic:gold_dust", {
+                               description = "Gold Dust",
+                               inventory_image = "technic_gold_dust.png",
+                               on_place_on_ground = minetest.craftitem_place_item,
+                            })
+minetest.register_craft({
+                          type = "cooking",
+                          output = "default:gold_ingot",
+                          recipe = "technic:gold_dust",
+                       })
+
+minetest.register_craftitem( "technic:mithril_dust", {
+                               description = "Mithril Dust",
+                               inventory_image = "technic_mithril_dust.png",
+                               on_place_on_ground = minetest.craftitem_place_item,
+                            })
+minetest.register_craft({
+                          type = "cooking",
+                          output = "moreores:mithril_ingot",
+                          recipe = "technic:mithril_dust",
+                       })
+
+minetest.register_craftitem( "technic:chromium_dust", {
+                               description = "Chromium Dust",
+                               inventory_image = "technic_chromium_dust.png",
+                               on_place_on_ground = minetest.craftitem_place_item,
+                            })
+minetest.register_craft({
+                          type = "cooking",
+                          output = "technic:chromium_ingot",
+                          recipe = "technic:chromium_dust",
+                       })
+
+minetest.register_craftitem( "technic:bronze_dust", {
+                               description = "Bronze Dust",
+                               inventory_image = "technic_bronze_dust.png",
+                               on_place_on_ground = minetest.craftitem_place_item,
+                            })
+minetest.register_craft({
+                          type = "cooking",
+                          output = "default:bronze_ingot",
+                          recipe = "technic:bronze_dust",
+                       })
+
+minetest.register_craftitem( "technic:brass_dust", {
+                               description = "Brass Dust",
+                               inventory_image = "technic_brass_dust.png",
+                               on_place_on_ground = minetest.craftitem_place_item,
+                            })
+minetest.register_craft({
+                          type = "cooking",
+                          output = "technic:brass_ingot",
+                          recipe = "technic:brass_dust",
+                       })
+
+minetest.register_craftitem( "technic:stainless_steel_dust", {
+                               description = "Stainless Steel Dust",
+                               inventory_image = "technic_stainless_steel_dust.png",
+                            })
+
+minetest.register_craft({
+                          type = "cooking",
+                          output = "technic:stainless_steel_ingot",
+                          recipe = "technic:stainless_steel_dust",
+                       })
+
+minetest.register_craftitem( "technic:zinc_dust", {
+                               description = "Zinc Dust",
+                               inventory_image = "technic_zinc_dust.png",
+                            })
+
+minetest.register_craft({
+                          type = "cooking",
+                          output = "technic:zinc_ingot",
+                          recipe = "technic:zinc_dust",
+                       })
+
+minetest.register_alias("grinder", "technic:grinder")
+minetest.register_craft({
+                          output = 'technic:grinder',
+                          recipe = {
+                             {'default:desert_stone', 'default:desert_stone', 'default:desert_stone'},
+                             {'default:desert_stone', 'default:diamond', 'default:desert_stone'},
+                             {'default:stone', 'moreores:copper_ingot', 'default:stone'},
+                          }
+                       })
+
+minetest.register_craftitem("technic:grinder", {
+                              description = "Grinder",
+                              stack_max = 99,
+                           })
+
+local grinder_formspec =
+   "invsize[8,9;]"..
+   "label[0,0;Grinder]"..
+   "list[current_name;src;3,1;1,1;]"..
+   "list[current_name;dst;5,1;2,2;]"..
+   "list[current_player;main;0,5;8,4;]"
+
+minetest.register_node(
+   "technic:grinder",
+   {
+      description = "Grinder",
+      tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
+              "technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
+      paramtype2 = "facedir",
+      groups = {cracky=2},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_wood_defaults(),
+      on_construct = function(pos)
+                       local meta = minetest.env:get_meta(pos)
+                       meta:set_string("infotext", "Grinder")
+                       meta:set_float("technic_power_machine", 1)
+                       meta:set_string("formspec", grinder_formspec)
+                       local inv = meta:get_inventory()
+                       inv:set_size("src", 1)
+                       inv:set_size("dst", 4)
+                    end,
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") or not inv:is_empty("dst") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  else
+                     return true
+                  end
+               end,
+   })
+
+minetest.register_node(
+   "technic:grinder_active",
+   {
+      description = "Grinder",
+      tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
+              "technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front_active.png"},
+      paramtype2 = "facedir",
+      groups = {cracky=2,not_in_creative_inventory=1},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_wood_defaults(),
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") or not inv:is_empty("dst") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  else
+                     return true
+                  end
+               end,
+   })
+
+minetest.register_abm(
+   { nodenames = {"technic:grinder","technic:grinder_active"},
+     interval = 1,
+     chance   = 1,
+     action = function(pos, node, active_object_count, active_object_count_wider)
+                -- Run a machine through its states. Takes the same arguments as the ABM action
+                -- and adds the machine's states and any extra data which is needed by the machine.
+                -- A machine is characterized by running through a set number of states (usually 2:
+                -- Idle and active) in some order. A state decides when to move to the next one
+                -- and the machine only changes state if it is powered correctly.
+                -- The machine will automatically shut down if disconnected from power in some fashion.
+                local meta         = minetest.env:get_meta(pos)
+                local eu_input     = meta:get_int("LV_EU_input")
+                local state        = meta:get_int("state")
+                local next_state   = state
+
+                -- Machine information
+                local machine_name         = "Grinder"
+                local machine_node         = "technic:grinder"
+                local machine_state_demand = { 50, 300 }
+                        
+                -- Setup meta data if it does not exist. state is used as an indicator of this
+                if state == 0 then
+                   meta:set_int("state", 1)
+                   meta:set_int("LV_EU_demand", machine_state_demand[1])
+                   meta:set_int("LV_EU_input", 0)
+                   return
+                end
+                        
+                -- Power off automatically if no longer connected to a switching station
+                technic.switching_station_timeout_count(pos, "LV")
+                        
+                -- State machine
+                if eu_input == 0 then
+                   -- unpowered - go idle
+                   hacky_swap_node(pos, machine_node)
+                   meta:set_string("infotext", machine_name.." Unpowered")
+                   next_state = 1
+                elseif eu_input == machine_state_demand[state] then
+                   -- Powered - do the state specific actions
+                           
+                   local inv    = meta:get_inventory()
+                   local empty  = inv:is_empty("src")
+
+                   if state == 1 then
+                      hacky_swap_node(pos, machine_node)
+                      meta:set_string("infotext", machine_name.." Idle")
+
+                      local result = technic.get_grinder_recipe(inv:get_stack("src", 1))
+                      if not empty and result and inv:room_for_item("dst",result) then
+                         meta:set_int("src_time", 0)
+                         next_state = 2
+                      end
+
+                   elseif state == 2 then
+                      hacky_swap_node(pos, machine_node.."_active")
+                      meta:set_string("infotext", machine_name.." Active")
+
+                      if empty then
+                         next_state = 1
+                      else
+                         meta:set_int("src_time", meta:get_int("src_time") + 1)
+                         if meta:get_int("src_time") == 4 then -- 4 ticks per output
+                            -- check if there's room for output in "dst" list
+                            local result = technic.get_grinder_recipe(inv:get_stack("src", 1))
+
+                            meta:set_int("src_time", 0)
+                            if inv:room_for_item("dst",result) then
+                               -- take stuff from "src" list
+                               srcstack = inv:get_stack("src", 1)
+                               srcstack:take_item()
+                               inv:set_stack("src", 1, srcstack)
+                               -- Put result in "dst" list
+                               inv:add_item("dst", result)
+                            else
+                               -- all full: go idle
+                               next_state = 1
+                            end
+                         end
+                      end
+                   end
+                end
+                -- Change state?
+                if next_state ~= state then
+                   meta:set_int("LV_EU_demand", machine_state_demand[next_state])
+                   meta:set_int("state", next_state)
+                end
+             end
+  })
+
+technic.register_LV_machine ("technic:grinder","RE")
+technic.register_LV_machine ("technic:grinder_active","RE")
+
diff --git a/technic/machines/lv/init.lua b/technic/machines/lv/init.lua
new file mode 100644 (file)
index 0000000..a95f78e
--- /dev/null
@@ -0,0 +1,19 @@
+local path = technic.modpath.."/machines/lv"
+
+dofile(path.."/wires.lua")
+dofile(path.."/battery_box.lua")
+dofile(path.."/alloy_furnace.lua")
+dofile(path.."/solar_panel.lua")
+dofile(path.."/solar_array.lua")
+dofile(path.."/geothermal.lua")
+dofile(path.."/water_mill.lua")
+dofile(path.."/generator.lua")
+dofile(path.."/electric_furnace.lua")
+dofile(path.."/tool_workshop.lua")
+dofile(path.."/music_player.lua")
+dofile(path.."/grinder.lua")
+dofile(path.."/cnc.lua")
+dofile(path.."/cnc_api.lua")
+dofile(path.."/cnc_nodes.lua")
+dofile(path.."/extractor.lua")
+
diff --git a/technic/machines/lv/music_player.lua b/technic/machines/lv/music_player.lua
new file mode 100644 (file)
index 0000000..a3f52aa
--- /dev/null
@@ -0,0 +1,156 @@
+-- LV Music player.
+-- The playe can play music. But it is high ampage!
+minetest.register_alias("music_player", "technic:music_player")
+minetest.register_craft({
+       output = 'technic:music_player',
+       recipe = {
+               {'default:wood', 'default:wood', 'default:wood'},
+               {'default:diamond', 'default:diamond', 'default:diamond'},
+               {'default:stone', 'default:copper_ingot', 'default:stone'},
+       }
+})
+
+minetest.register_craftitem("technic:music_player", {
+       description = "Music Player",
+       stack_max = 99,
+})
+
+local music_player_formspec =
+   "invsize[8,9;]"..
+   "label[0,0;Music Player]"..
+   "button[4,1;1,1;track1;1]"..
+   "button[5,1;1,1;track2;2]"..
+   "button[6,1;1,1;track3;3]"..
+   "button[4,2;1,1;track4;4]"..
+   "button[5,2;1,1;track5;5]"..
+   "button[6,2;1,1;track6;6]"..
+   "button[4,3;1,1;track7;7]"..
+   "button[5,3;1,1;track8;8]"..
+   "button[6,3;1,1;track9;9]"..
+   "button[4,4;1,2;play;Play]"..
+   "button[6,4;1,2;stop;Stop]"..
+   "label[4,0;Current track --]"
+
+minetest.register_node(
+   "technic:music_player",
+   {
+      description = "Music Player",
+      tiles = {"technic_music_player_top.png", "technic_machine_bottom.png", "technic_music_player_side.png",
+              "technic_music_player_side.png", "technic_music_player_side.png", "technic_music_player_side.png"},
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+      sounds = default.node_sound_wood_defaults(),
+      on_construct = function(pos)
+                       local meta = minetest.env:get_meta(pos)
+                       meta:set_string("infotext", "Music Player")
+                       meta:set_float("technic_power_machine", 1)
+                       meta:set_int("active",     0) -- Is the device on?
+                       meta:set_int("music_player_current_track", 1)
+                       meta:set_string("formspec", music_player_formspec)
+                    end,
+      on_receive_fields = function(pos, formanme, fields, sender)
+                            local meta                 = minetest.env:get_meta(pos)
+                            music_handle               = meta:get_int("music_handle")
+                            music_player_current_track = meta:get_int("music_player_current_track")
+                            if fields.track1 then music_player_current_track = 1 end
+                            if fields.track2 then music_player_current_track = 2 end
+                            if fields.track3 then music_player_current_track = 3 end
+                            if fields.track4 then music_player_current_track = 4 end
+                            if fields.track5 then music_player_current_track = 5 end
+                            if fields.track6 then music_player_current_track = 6 end
+                            if fields.track7 then music_player_current_track = 7 end
+                            if fields.track8 then music_player_current_track = 8 end
+                            if fields.track9 then music_player_current_track = 9 end
+                            meta:set_int("music_player_current_track",music_player_current_track)
+                            if fields.play and meta:get_int("active") == 0 then
+                               if music_handle then minetest.sound_stop(music_handle) end
+                               music_handle = minetest.sound_play("technic_track"..music_player_current_track, {pos = pos, gain = 1.0,loop = true, max_hear_distance = 72,})
+                               meta:set_int("active",1)
+                            end
+                            if fields.stop then
+                               meta:set_int("active",0)
+                               if music_handle then minetest.sound_stop(music_handle) end
+                            end
+                            meta:set_int("music_handle",music_handle)
+                         end,
+   })
+
+minetest.register_abm(
+   { nodenames = {"technic:music_player"},
+     interval = 1,
+     chance   = 1,
+     action = function(pos, node, active_object_count, active_object_count_wider)
+                local meta         = minetest.env:get_meta(pos)
+                local eu_input     = meta:get_int("LV_EU_input")
+                local state        = meta:get_int("state")
+                local next_state   = state
+
+                -- Machine information
+                local machine_name         = "Music Player"
+                local machine_node         = "technic:music_player"
+                local machine_state_demand = { 10, 150 }
+                        
+                local music_handle         = meta:get_int("music_handle")
+
+                -- Setup meta data if it does not exist. state is used as an indicator of this
+                if state == 0 then
+                   meta:set_int("state", 1)
+                   meta:set_int("LV_EU_demand", machine_state_demand[1])
+                   meta:set_int("LV_EU_input", 0)
+                   return
+                end
+                        
+                -- Power off automatically if no longer connected to a switching station
+                technic.switching_station_timeout_count(pos, "LV")
+                        
+                -- State machine
+                if eu_input == 0 then
+                   -- unpowered - go idle
+                   -- hacky_swap_node(pos, machine_node) -- if someday two nodes for this
+                   meta:set_string("infotext", machine_name.." Unpowered")
+                   next_state = 1
+                elseif eu_input == machine_state_demand[state] then
+                   -- Powered - do the state specific actions
+                   if state == 1 then
+                      -- hacky_swap_node(pos, machine_node) -- if someday two nodes for this
+                      meta:set_string("infotext", machine_name.." Idle")
+
+                      if meta:get_int("active") == 1 then
+                         next_state = 2
+                      end
+
+                   elseif state == 2 then
+                      -- hacky_swap_node(pos, machine_node.."_active") -- if someday two nodes for this
+                      meta:set_string("infotext", machine_name.." Active")
+
+                      music_player_current_track=meta:get_int("music_player_current_track")
+                      meta:set_string("formspec",
+                                      "invsize[8,9;]"..
+                                         "label[0,0;Music Player]"..
+                                         "button[4,1;1,1;track1;1]"..
+                                         "button[5,1;1,1;track2;2]"..
+                                         "button[6,1;1,1;track3;3]"..
+                                         "button[4,2;1,1;track4;4]"..
+                                         "button[5,2;1,1;track5;5]"..
+                                         "button[6,2;1,1;track6;6]"..
+                                         "button[4,3;1,1;track7;7]"..
+                                         "button[5,3;1,1;track8;8]"..
+                                         "button[6,3;1,1;track9;9]"..
+                                         "button[4,4;1,2;play;Play]"..
+                                         "button[6,4;1,2;stop;Stop]"..
+                                         "label[4,0;Current track "..tostring(music_player_current_track).."]"
+                                   )
+                      if meta:get_int("active") == 0 then
+                         if music_handle then minetest.sound_stop(music_handle) end
+                         next_state = 1
+                      end
+                   end
+                end
+                -- Change state?
+                if next_state ~= state then
+                   meta:set_int("LV_EU_demand", machine_state_demand[next_state])
+                   meta:set_int("state", next_state)
+                end
+             end
+   })
+
+technic.register_LV_machine ("technic:music_player","RE")
diff --git a/technic/machines/lv/solar_array.lua b/technic/machines/lv/solar_array.lua
new file mode 100644 (file)
index 0000000..e758eb8
--- /dev/null
@@ -0,0 +1,78 @@
+-- The solar array is an assembly of panels into a powerful array
+-- The assembly can deliver more energy than the individual panel because
+-- of the transformer unit which converts the panel output variations into
+-- a stable supply.
+-- Solar arrays are not able to store large amounts of energy.
+-- The LV arrays are used to make medium voltage arrays.
+minetest.register_node("technic:solar_array_lv", {
+       tiles = {"technic_lv_solar_array_top.png", "technic_lv_solar_array_bottom.png", "technic_lv_solar_array_side.png",
+               "technic_lv_solar_array_side.png", "technic_lv_solar_array_side.png", "technic_lv_solar_array_side.png"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+       sounds = default.node_sound_wood_defaults(),
+       description="LV Solar Array",
+       drawtype = "nodebox",
+       paramtype = "light",
+       is_ground_content = true,       
+       node_box = {
+                       type = "fixed",
+                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
+               },
+               selection_box = {
+                       type = "fixed",
+                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
+               },
+       on_construct = function(pos)
+               local meta = minetest.env:get_meta(pos)
+               meta:set_int("technic_power_machine", 1)
+               meta:set_int("LV_EU_supply", 0)
+               meta:set_string("infotext", "LV Solar Array")
+       end,
+})
+
+minetest.register_craft(
+   {output = 'technic:solar_array_lv 1',
+    recipe = {
+       {'technic:solar_panel', 'technic:solar_panel',    'technic:solar_panel'},
+       {'technic:solar_panel', 'technic:lv_transformer', 'technic:solar_panel'},
+       {'default:steel_ingot', 'technic:lv_cable',       'default:steel_ingot'},
+    }
+ })
+
+minetest.register_abm(
+   {nodenames = {"technic:solar_array_lv"},
+    interval   = 1,
+    chance     = 1,
+    action = function(pos, node, active_object_count, active_object_count_wider)
+               -- The action here is to make the solar array produce power
+               -- Power is dependent on the light level and the height above ground
+               -- 130m and above is optimal as it would be above cloud level.
+               -- Height gives 1/4 of the effect, light 3/4. Max. effect is 160EU for the array.
+               -- There are many ways to cheat by using other light sources like lamps.
+               -- As there is no way to determine if light is sunlight that is just a shame.
+               -- To take care of some of it solar arrays do not work outside daylight hours or if
+               -- built below -10m
+               local pos1={}
+               pos1.y=pos.y+1
+               pos1.x=pos.x
+               pos1.z=pos.z
+               local light = minetest.env:get_node_light(pos1, nil)
+               local time_of_day = minetest.env:get_timeofday()
+               local meta = minetest.env:get_meta(pos)
+               if light == nil then light = 0 end
+               -- turn on array only during day time and if sufficient light
+               -- I know this is counter intuitive when cheating by using other light sources.
+               if light >= 12 and time_of_day>=0.24 and time_of_day<=0.76 and pos.y > -10 then
+                  local charge_to_give = math.floor(light*(light*0.5333+pos1.y/130*2.6667))
+                  if charge_to_give<0   then charge_to_give=0 end
+                  if charge_to_give>160 then charge_to_give=160 end
+                  meta:set_string("infotext", "Solar Array is active ("..charge_to_give.."EU)")
+                  meta:set_int("LV_EU_supply", charge_to_give)
+               else
+                  meta:set_string("infotext", "Solar Array is inactive");
+                  meta:set_int("LV_EU_supply", 0)
+               end
+            end,
+ })
+
+technic.register_LV_machine ("technic:solar_array_lv","PR")
+
diff --git a/technic/machines/lv/solar_panel.lua b/technic/machines/lv/solar_panel.lua
new file mode 100644 (file)
index 0000000..ff3e34a
--- /dev/null
@@ -0,0 +1,78 @@
+-- Solar panels are the building blocks of LV solar arrays
+-- They can however also be used separately but with reduced efficiency due to the missing transformer.
+-- Individual panels are 20% less efficient than when the panels are combined into full arrays.
+minetest.register_node("technic:solar_panel", {
+       tiles = {"technic_solar_panel_top.png", "technic_solar_panel_bottom.png", "technic_solar_panel_side.png",
+               "technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+       sounds = default.node_sound_wood_defaults(),
+       description="Solar Panel",
+       active = false,
+       drawtype = "nodebox",
+       paramtype = "light",
+       is_ground_content = true,       
+       node_box = {
+                       type = "fixed",
+                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
+               },
+               selection_box = {
+                       type = "fixed",
+                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
+               },
+       on_construct = function(pos)
+               local meta = minetest.env:get_meta(pos)
+               meta:set_int("technic_power_machine", 1)
+               meta:set_int("LV_EU_supply", 0)
+               meta:set_string("infotext", "LV Solar Panel")
+       end,
+})
+
+minetest.register_craft({
+       output = 'technic:solar_panel 1',
+       recipe = {
+               {'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer','technic:doped_silicon_wafer'},
+               {'technic:doped_silicon_wafer', 'technic:lv_cable',           'technic:doped_silicon_wafer'},
+               {'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer','technic:doped_silicon_wafer'},
+
+       }
+})
+
+minetest.register_abm(
+       {nodenames = {"technic:solar_panel"},
+       interval   = 1,
+       chance     = 1,
+       action = function(pos, node, active_object_count, active_object_count_wider)
+               -- The action here is to make the solar panel prodice power
+               -- Power is dependent on the light level and the height above ground
+               -- 130m and above is optimal as it would be above cloud level.
+                -- Height gives 1/4 of the effect, light 3/4. Max. effect is 26EU.
+                -- There are many ways to cheat by using other light sources like lamps.
+                -- As there is no way to determine if light is sunlight that is just a shame.
+                -- To take care of some of it solar panels do not work outside daylight hours or if
+                -- built below -10m
+               local pos1={}
+               pos1.y=pos.y+1
+               pos1.x=pos.x
+               pos1.z=pos.z
+
+               local light = minetest.env:get_node_light(pos1, nil)
+               local time_of_day = minetest.env:get_timeofday()
+               local meta = minetest.env:get_meta(pos)
+               if light == nil then light = 0 end
+               -- turn on panel only during day time and if sufficient light
+                -- I know this is counter intuitive when cheating by using other light sources underground.
+               if light >= 12 and time_of_day>=0.24 and time_of_day<=0.76 and pos.y > -10 then
+                       local charge_to_give=math.floor(light*(light*0.0867+pos1.y/130*0.4333))
+                       if charge_to_give<0 then charge_to_give=0 end
+                       if charge_to_give>26 then charge_to_give=26 end
+                       meta:set_string("infotext", "Solar Panel is active ("..charge_to_give.."EU)")
+                       meta:set_int("LV_EU_supply", charge_to_give)
+               else
+                       meta:set_string("infotext", "Solar Panel is inactive");
+                       meta:set_int("LV_EU_supply", 0)
+               end
+       end,
+}) 
+
+technic.register_LV_machine ("technic:solar_panel","PR")
+
diff --git a/technic/machines/lv/tool_workshop.lua b/technic/machines/lv/tool_workshop.lua
new file mode 100644 (file)
index 0000000..52cd044
--- /dev/null
@@ -0,0 +1,122 @@
+-- LV Tool workshop
+-- This machine repairs tools.
+minetest.register_alias("tool_workshop", "technic:tool_workshop")
+minetest.register_craft({
+       output = 'technic:tool_workshop',
+       recipe = {
+               {'default:wood', 'default:wood', 'default:wood'},
+               {'default:wood', 'default:diamond', 'default:wood'},
+               {'default:stone', 'default:copper_ingot', 'default:stone'},
+       }
+})
+
+minetest.register_craftitem("technic:tool_workshop", {
+       description = "Tool Workshop",
+       stack_max = 99,
+}) 
+
+local workshop_formspec =
+   "invsize[8,9;]"..
+   "list[current_name;src;3,1;1,1;]"..
+   "label[0,0;Tool Workshop]"..
+   "list[current_player;main;0,5;8,4;]"
+
+minetest.register_node(
+   "technic:tool_workshop",
+   {
+      description = "Tool Workshop",
+      tiles = {"technic_workshop_top.png", "technic_machine_bottom.png", "technic_workshop_side.png",
+              "technic_workshop_side.png", "technic_workshop_side.png", "technic_workshop_side.png"},
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+      sounds = default.node_sound_wood_defaults(),
+      on_construct = function(pos)
+                       local meta = minetest.env:get_meta(pos)
+                       meta:set_string("infotext", "Tool Workshop")
+                       meta:set_float("technic_power_machine", 1)
+                       meta:set_string("formspec", workshop_formspec)
+                       local inv = meta:get_inventory()
+                       inv:set_size("src", 1)
+                    end,       
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  end
+                  return true
+               end,
+   })
+
+minetest.register_abm(
+   { nodenames = {"technic:tool_workshop"},
+     interval = 1,
+     chance   = 1,
+     action = function(pos, node, active_object_count, active_object_count_wider)
+                local meta         = minetest.env:get_meta(pos)
+                local eu_input     = meta:get_int("LV_EU_input")
+                local state        = meta:get_int("state")
+                local next_state   = state
+
+                -- Machine information
+                local machine_name         = "Tool Workshop"
+                local machine_node         = "technic:tool_workshop"
+                local machine_state_demand = { 50, 150 }
+                        
+                -- Setup meta data if it does not exist. state is used as an indicator of this
+                if state == 0 then
+                   meta:set_int("state", 1)
+                   meta:set_int("LV_EU_demand", machine_state_demand[1])
+                   meta:set_int("LV_EU_input", 0)
+                   return
+                end
+                        
+                -- Power off automatically if no longer connected to a switching station
+                technic.switching_station_timeout_count(pos, "LV")
+                        
+                -- State machine
+                if eu_input == 0 then
+                   -- Unpowered - go idle
+                   --hacky_swap_node(pos, machine_node)
+                   meta:set_string("infotext", machine_name.." Unpowered")
+                   next_state = 1
+                elseif eu_input == machine_state_demand[state] then
+                   -- Powered - do the state specific actions
+                   local inv = meta:get_inventory()
+                           
+                   if state == 1 then
+                      --hacky_swap_node(pos, machine_node)
+                      meta:set_string("infotext", machine_name.." Idle")
+                      if not inv:is_empty("src") then
+                         next_state = 2
+                      end
+                   elseif state == 2 then
+                      --hacky_swap_node(pos, machine_node.."_active")
+                      meta:set_string("infotext", machine_name.." Active")
+
+                      if inv:is_empty("src") then
+                         next_state = 1
+                      else
+                         srcstack = inv:get_stack("src", 1)
+                         src_item=srcstack:to_table()
+                         -- Cannot charge cans
+                         if (src_item["name"]=="technic:water_can" or src_item["name"]=="technic:lava_can") then
+                            return
+                         end
+                         local wear=tonumber(src_item["wear"])
+                         wear = math.max(1, wear-2000) -- Improve the tool this much every tick
+                         src_item["wear"]=tostring(wear)
+                         inv:set_stack("src", 1, src_item)
+                      end
+                   end
+                end
+                -- Change state?
+                if next_state ~= state then
+                   meta:set_int("LV_EU_demand", machine_state_demand[next_state])
+                   meta:set_int("state", next_state)
+                end
+             end
+   }) 
+
+technic.register_LV_machine ("technic:tool_workshop","RE")
+
diff --git a/technic/machines/lv/water_mill.lua b/technic/machines/lv/water_mill.lua
new file mode 100644 (file)
index 0000000..a7e8ce4
--- /dev/null
@@ -0,0 +1,122 @@
+-- A water mill produces LV EUs by exploiting flowing water across it
+-- It is a LV EU supplyer and fairly low yield (max 120EUs)
+-- It is a little under half as good as the thermal generator.
+minetest.register_alias("water_mill", "technic:water_mill")
+
+minetest.register_craft({
+       output = 'technic:water_mill',
+       recipe = {
+               {'default:stone', 'default:stone', 'default:stone'},
+               {'default:wood', 'default:diamond', 'default:wood'},
+               {'default:stone', 'default:copper_ingot', 'default:stone'},
+       }
+})
+
+minetest.register_craftitem("technic:water_mill", {
+       description = "Water Mill",
+       stack_max = 99,
+}) 
+
+local water_mill_formspec =
+       "invsize[8,4;]"..
+       "image[1,1;1,2;technic_power_meter_bg.png]"..
+       "label[0,0;Water Mill]"..
+       "label[1,3;Power level]"..
+       "list[current_player;main;0,5;8,4;]"
+       
+
+minetest.register_node(
+   "technic:water_mill",
+   {
+      description = "Water Mill",
+      tiles = {"technic_water_mill_top.png", "technic_machine_bottom.png", "technic_water_mill_side.png",
+              "technic_water_mill_side.png", "technic_water_mill_side.png", "technic_water_mill_side.png"},
+      paramtype2 = "facedir",
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_wood_defaults(),
+      on_construct = function(pos)
+                       local meta = minetest.env:get_meta(pos)
+                       meta:set_string("infotext", "Water Mill")
+                       meta:set_float("technic_power_machine", 1)
+                       meta:set_int("LV_EU_supply", 0)
+                       meta:set_string("formspec", water_mill_formspec)        
+                    end,       
+   })
+
+minetest.register_node(
+   "technic:water_mill_active",
+   {
+      description = "Water Mill",
+      tiles = {"technic_water_mill_top_active.png", "technic_machine_bottom.png", "technic_water_mill_side.png",
+              "technic_water_mill_side.png", "technic_water_mill_side.png", "technic_water_mill_side.png"},
+      paramtype2 = "facedir",
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
+      legacy_facedir_simple = true,
+      sounds = default.node_sound_wood_defaults(),
+      drop="technic:water_mill",
+})
+
+local check_node_around_mill = function(pos)
+                                 local node=minetest.env:get_node(pos)
+                                 if node.name=="default:water_flowing" then return 1 end
+                                 return 0
+                              end
+
+minetest.register_abm(
+   {
+      nodenames = {"technic:water_mill","technic:water_mill_active"},
+      interval = 1,
+      chance   = 1,
+      action = function(pos, node, active_object_count, active_object_count_wider)
+                 local meta             = minetest.env:get_meta(pos)
+                 local water_nodes      = 0
+                 local lava_nodes       = 0
+                 local production_level = 0
+                 local eu_supply        = 0
+
+                 pos.x=pos.x+1
+                 local check=check_node_around_mill (pos)
+                 if check==1 then water_nodes=water_nodes+1 end
+                 pos.x=pos.x-2
+                 check=check_node_around_mill (pos)
+                 if check==1 then water_nodes=water_nodes+1 end
+                 pos.x=pos.x+1
+                 pos.z=pos.z+1
+                 check=check_node_around_mill (pos)
+                 if check==1 then water_nodes=water_nodes+1 end
+                 pos.z=pos.z-2
+                 check=check_node_around_mill (pos)
+                 if check==1 then water_nodes=water_nodes+1 end
+                 pos.z=pos.z+1
+       
+                 if water_nodes==1 then production_level =  25; eu_supply =  30 end
+                 if water_nodes==2 then production_level =  50; eu_supply =  60 end
+                 if water_nodes==3 then production_level =  75; eu_supply =  90 end
+                 if water_nodes==4 then production_level = 100; eu_supply = 120 end
+
+                 if production_level>0 then
+                    meta:set_int("LV_EU_supply", eu_supply)
+                 end
+
+                 local load = 1 -- math.floor((charge/max_charge)*100)
+                 meta:set_string("formspec",
+                                 "invsize[8,4;]"..
+                                    "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
+                                    (load)..":technic_power_meter_fg.png]"..
+                                 "label[0,0;Water Mill]"..
+                                 "label[1,3;Power level]"..
+                                 "label[4,0;Production at "..tostring(production_level).."%]"
+                           )
+                               
+                 if production_level>0 and minetest.env:get_node(pos).name=="technic:water_mill" then
+                    hacky_swap_node (pos,"technic:water_mill_active")
+                    meta:set_int("LV_EU_supply", 0)
+                    return
+                 end
+                 if production_level==0 then hacky_swap_node (pos,"technic:water_mill") end
+              end
+   }) 
+
+technic.register_LV_machine ("technic:water_mill","PR")
+technic.register_LV_machine ("technic:water_mill_active","PR")
diff --git a/technic/machines/lv/wires.lua b/technic/machines/lv/wires.lua
new file mode 100644 (file)
index 0000000..db8c823
--- /dev/null
@@ -0,0 +1,401 @@
+--LV cable node boxes
+
+
+minetest.register_alias("lv_cable", "technic:lv_cable")
+
+minetest.register_craft({
+       output = 'technic:lv_cable 6',
+       recipe = {
+               {'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
+       }
+}) 
+
+minetest.register_craftitem("technic:lv_cable", {
+       description = "Low Voltage Copper Cable",
+       stack_max = 99,
+}) 
+
+minetest.register_node("technic:lv_cable", {
+       description = "Low Voltage Copper Cable",
+       tiles = {"technic_lv_cable.png"},
+       inventory_image = "technic_lv_cable_wield.png",
+       wield_image = "technic_lv_cable_wield.png",
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+       sounds = default.node_sound_wood_defaults(),
+       drop = "technic:lv_cable",
+       cablelike=1,
+       rules_x1=0,
+       rules_x2=0,
+       rules_y1=0,
+       rules_y2=0,
+       rules_z1=0,
+       rules_z2=0,
+       paramtype = "light",
+        drawtype = "nodebox", 
+       selection_box = {
+               type = "fixed",
+                fixed = {
+               { -0.1 , -0.1 , -0.1 , 0.1 ,  0.1 , 0.1  },
+               }},
+       node_box = {
+               type = "fixed",
+                fixed = {
+               { -0.1 , -0.1 , -0.1 , 0.1 ,  0.1 , 0.1  },
+               }},
+       on_construct = function(pos)
+       meta=minetest.env:get_meta(pos)
+       meta:set_float("cablelike",1)
+       meta:set_float("x1",0)
+       meta:set_float("x2",0)
+       meta:set_float("y1",0)
+       meta:set_float("y2",0)
+       meta:set_float("z1",0)
+       meta:set_float("z2",0)
+       check_connections (pos)
+       end,
+
+       after_dig_node = function (pos, oldnode, oldmetadata, digger)
+       check_connections_on_destroy (pos)
+       end,
+
+})
+
+
+str_y1=                { -0.1 , -0.1 , -0.1 , 0.1 , 0.5, 0.1  }    --0 y+
+str_x1=                { -0.1 , -0.1 , -0.1 , 0.5, 0.1 , 0.1  }    --0 x+
+str_z1=                { -0.1 , -0.1 ,  0.1 ,  0.1 , 0.1 , 0.5 }   --0 z+
+str_z2=                { -0.1 , -0.1, -0.5 ,  0.1 ,  0.1 , 0.1  }  --0 z-
+str_y2=                { -0.1 , -0.5, -0.1 ,  0.1 ,  0.1 , 0.1  }  --0 y-
+str_x2=                { -0.5 , -0.1, -0.1 ,  0.1 ,  0.1 , 0.1  }  --0 x-
+
+
+
+local x1,x2,y1,y2,z1,z2
+local count=0
+
+for x1 = 0, 1, 1 do    --x-
+for x2 = 0, 1, 1 do    --x+
+for y1 = 0, 1, 1 do    --y-
+for y2 = 0, 1, 1 do    --y-    
+for z1 = 0, 1, 1 do    --z-
+for z2 = 0, 1, 1 do    --z+
+     
+temp_x1={} temp_x2={} temp_y1={} temp_y2={} temp_z1={} temp_z2={}
+
+if x1==1 then  temp_x1=str_x1  end 
+if x2==1 then  temp_x2=str_x2  end 
+if y1==1 then  temp_y1=str_y1  end 
+if y2==1 then  temp_y2=str_y2  end 
+if z1==1 then  temp_z1=str_z1  end 
+if z2==1 then  temp_z2=str_z2  end 
+
+
+minetest.register_node("technic:lv_cable"..count, {
+       description = "Low Voltage Copper Cable",
+       tiles = {"technic_lv_cable.png"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
+       sounds = default.node_sound_wood_defaults(),
+       drop = "technic:lv_cable",
+       rules_x1=0,
+       rules_x2=0,
+       rules_y1=0,
+       rules_y2=0,
+       rules_z1=0,
+       rules_z2=0,
+       cablelike=1,
+       paramtype = "light",
+        drawtype = "nodebox", 
+       selection_box = {
+               type = "fixed",
+           fixed = {
+               temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
+               }},
+
+       node_box = {
+               type = "fixed",
+           fixed = {
+               temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
+               }},
+
+       after_dig_node = function (pos, oldnode, oldmetadata, digger)
+       check_connections_on_destroy (pos)
+       end,
+       
+})
+
+count=count+1 end end end end end end
+
+check_connections = function(pos)
+               local pos1={}
+               pos1.x=pos.x
+               pos1.y=pos.y
+               pos1.z=pos.z
+               
+               pos1.x=pos1.x+1
+               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
+               x2=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:lv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("x2",x2)
+               meta=minetest.env:get_meta(pos)
+               x1=1
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("x1",x1)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:lv_cable"..rule)
+               end
+
+               pos1.x=pos1.x-2
+               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
+               x1=1
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:lv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("x1",x1)
+               meta=minetest.env:get_meta(pos)
+               x2=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("x2",x2)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:lv_cable"..rule)
+               end
+
+               pos1.x=pos1.x+1
+               
+               pos1.y=pos1.y+1
+               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
+               y2=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:lv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("y2",y2)
+               meta=minetest.env:get_meta(pos)
+               y1=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("y1",y1)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:lv_cable"..rule)
+               end
+               
+               if minetest.env:get_meta(pos1):get_float("technic_power_machine")==1 then
+               y1=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:lv_cable"..rule)
+               meta=minetest.env:get_meta(pos)
+               meta:set_float("y1",y1)
+               end
+
+
+               pos1.y=pos1.y-2
+               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
+               y1=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:lv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("y1",y1)
+               meta=minetest.env:get_meta(pos)
+               y2=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("y2",y2)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:lv_cable"..rule)
+               end
+               pos1.y=pos1.y+1
+
+               pos1.z=pos1.z+1
+               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
+               z2=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:lv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("z2",z2)
+               meta=minetest.env:get_meta(pos)
+               z1=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("z1",z1)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:lv_cable"..rule)
+               end
+               pos1.z=pos1.z-2
+               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
+               z1=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:lv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("z1",z1)
+               meta=minetest.env:get_meta(pos)
+               z2=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               meta:set_float("z2",z2)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:lv_cable"..rule)
+               end
+               pos1.z=pos1.z+1
+end    
+
+function make_rule_number (x1,x2,y1,y2,z1,z2)
+local temp= z2+z1*2+y2*4+y1*8+x2*16+x1*32
+return temp
+end
+
+check_connections_on_destroy = function(pos)
+               local pos1={}
+               pos1.x=pos.x
+               pos1.y=pos.y
+               pos1.z=pos.z
+               
+               pos1.x=pos1.x+1
+               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
+               x2=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("x2",x2)
+               end
+               
+               pos1.x=pos1.x-2
+               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
+               x1=0
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("x1",x1)
+               end
+               pos1.x=pos1.x+1
+
+               pos1.y=pos1.y+1
+               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
+               y2=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("y2",y2)
+               end
+               
+               pos1.y=pos1.y-2
+               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
+               y1=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("y1",y1)
+               end
+               pos1.y=pos1.y+1
+
+               pos1.z=pos1.z+1
+               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
+               z2=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("z2",z2)
+               end
+               
+               pos1.z=pos1.z-2
+               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
+               z1=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("z1",z1)
+               end
+               pos1.y=pos1.y+1
+               
+end    
+
diff --git a/technic/machines/mv/alloy_furnace.lua b/technic/machines/mv/alloy_furnace.lua
new file mode 100644 (file)
index 0000000..cadcb67
--- /dev/null
@@ -0,0 +1,459 @@
+-- MV alloy furnace
+
+minetest.register_craft({
+       output = 'technic:mv_alloy_furnace',
+       recipe = {
+               {'technic:stainless_steel_ingot', 'technic:alloy_furnace', 'technic:stainless_steel_ingot'},
+               {'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
+               {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
+       }
+})
+
+local mv_alloy_furnace_formspec =
+       "invsize[8,10;]"..
+       "label[0,0;MV Alloy Furnace]"..
+        "list[current_name;src;3,1;1,2;]"..
+       "list[current_name;dst;5,1;2,2;]"..
+       "list[current_player;main;0,6;8,4;]"..
+       "list[current_name;upgrade1;1,4;1,1;]"..
+       "list[current_name;upgrade2;2,4;1,1;]"..
+       "label[1,5;Upgrade Slots]"
+       
+minetest.register_node(
+   "technic:mv_alloy_furnace",
+   {description = "MV Alloy Furnace",
+    tiles = {"technic_mv_alloy_furnace_top.png", "technic_mv_alloy_furnace_bottom.png", "technic_mv_alloy_furnace_side_tube.png",
+            "technic_mv_alloy_furnace_side_tube.png", "technic_mv_alloy_furnace_side.png", "technic_mv_alloy_furnace_front.png"},
+    paramtype2 = "facedir",
+    groups = {cracky=2, tubedevice=1,tubedevice_receiver=1},
+    tube={insert_object=function(pos,node,stack,direction)
+                          local meta=minetest.env:get_meta(pos)
+                          local inv=meta:get_inventory()
+                          return inv:add_item("src",stack)
+                       end,
+         can_insert=function(pos,node,stack,direction)
+                       local meta=minetest.env:get_meta(pos)
+                       local inv=meta:get_inventory()
+                       return inv:room_for_item("src",stack)
+                    end,
+       },
+    legacy_facedir_simple = true,
+    sounds = default.node_sound_stone_defaults(),
+    on_construct = function(pos)
+                     local meta = minetest.env:get_meta(pos)
+                     meta:set_string("infotext", "MV Alloy furnace")
+                     meta:set_float("technic_mv_power_machine", 1)
+                     meta:set_int("tube_time",  0)
+                     meta:set_string("formspec", mv_alloy_furnace_formspec)
+                     local inv = meta:get_inventory()
+                     inv:set_size("src", 2)
+                     inv:set_size("dst", 4)
+                     inv:set_size("upgrade1", 1)
+                     inv:set_size("upgrade2", 1)
+                  end,
+    can_dig = function(pos,player)
+                local meta = minetest.env:get_meta(pos);
+                local inv = meta:get_inventory()
+                if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
+                   minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                   return false
+                else
+                   return true
+                end
+             end,
+})
+
+minetest.register_node(
+   "technic:mv_alloy_furnace_active",
+   {description = "MV Alloy Furnace",
+    tiles = {"technic_mv_alloy_furnace_top.png", "technic_mv_alloy_furnace_bottom.png", "technic_mv_alloy_furnace_side_tube.png",
+            "technic_mv_alloy_furnace_side_tube.png", "technic_mv_alloy_furnace_side.png", "technic_mv_alloy_furnace_front_active.png"},
+    paramtype2 = "facedir",
+    light_source = 8,
+    drop = "technic:mv_alloy_furnace",
+    groups = {cracky=2, tubedevice=1,tubedevice_receiver=1,not_in_creative_inventory=1},
+    tube={insert_object=function(pos,node,stack,direction)
+                          local meta=minetest.env:get_meta(pos)
+                          local inv=meta:get_inventory()
+                          return inv:add_item("src",stack)
+                       end,
+         can_insert=function(pos,node,stack,direction)
+                       local meta=minetest.env:get_meta(pos)
+                       local inv=meta:get_inventory()
+                       return inv:room_for_item("src",stack)
+                    end,
+       },
+    legacy_facedir_simple = true,
+    sounds = default.node_sound_stone_defaults(),
+    can_dig = function(pos,player)
+                local meta = minetest.env:get_meta(pos);
+                local inv = meta:get_inventory()
+                if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
+                   minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                   return false
+                else
+                   return true
+                end
+             end,
+    -- These three makes sure upgrades are not moved in or out while the furnace is active.
+    allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+                                      if listname == "src" or listname == "dst" then
+                                         return 99
+                                      else
+                                         return 0 -- Disallow the move
+                                      end
+                                  end,
+    allow_metadata_inventory_take = function(pos, listname, index, stack, player)
+                                      if listname == "src" or listname == "dst" then
+                                         return 99
+                                      else
+                                         return 0 -- Disallow the move
+                                      end
+                                   end,
+    allow_metadata_inventory_move = function(pos, from_list, to_list, to_list, to_index, count, player)
+                                   return 0
+                                end,
+})
+
+local send_cooked_items = function(pos,x_velocity,z_velocity)
+                            -- Send items on their way in the pipe system.
+                            local meta=minetest.env:get_meta(pos) 
+                            local inv = meta:get_inventory()
+                            local i=0
+                            for _,stack in ipairs(inv:get_list("dst")) do
+                               i=i+1
+                               if stack then
+                                  local item0=stack:to_table()
+                               if item0 then 
+                                  item0["count"]="1"
+                                  local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
+                                  item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
+                                  item1:setvelocity({x=x_velocity, y=0, z=z_velocity})
+                                  item1:setacceleration({x=0, y=0, z=0})
+                                  stack:take_item(1);
+                                  inv:set_stack("dst", i, stack)
+                                  return
+                               end
+                            end
+                         end
+                      end
+
+local smelt_item = function(pos)
+                     local meta=minetest.env:get_meta(pos) 
+                     local inv = meta:get_inventory()
+                     meta:set_int("src_time", meta:get_int("src_time") + 3) -- Cooking time 3x faster
+                     local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
+                     dst_stack={}
+                     dst_stack["name"]=alloy_recipes[dst_index].dst_name
+                     dst_stack["count"]=alloy_recipes[dst_index].dst_count
+
+                     if result and result.item and meta:get_int("src_time") >= result.time then
+                        meta:set_int("src_time", 0)
+                        -- check if there's room for output in "dst" list
+                        if inv:room_for_item("dst",result) then
+                           -- take stuff from "src" list
+                           srcstack = inv:get_stack("src", 1)
+                           srcstack:take_item()
+                           inv:set_stack("src", 1, srcstack)
+                           -- Put result in "dst" list
+                           inv:add_item("dst", result.item)
+                           return 1
+                        else
+                           return 0 -- done
+                        end
+                     end
+                     return 0 -- done
+                  end
+
+minetest.register_abm(
+   {nodenames = {"technic:mv_alloy_furnace","technic:mv_alloy_furnace_active"},
+    interval = 1,
+    chance = 1,
+
+    action = function(pos, node, active_object_count, active_object_count_wider)
+               local meta         = minetest.env:get_meta(pos)
+               local eu_input     = meta:get_int("MV_EU_input")
+               local state        = meta:get_int("state")
+               local next_state   = state
+
+               -- Machine information
+               local machine_name         = "MV Alloy Furnace"
+               local machine_node         = "technic:mv_alloy_furnace"
+               local machine_state_demand = { 50, 2000, 1500, 1000 }
+               
+               -- Setup meta data if it does not exist. state is used as an indicator of this
+               if state == 0 then
+                  meta:set_int("state", 1)
+                  meta:set_int("MV_EU_demand", machine_state_demand[1])
+                  meta:set_int("MV_EU_input", 0)
+                  return
+               end
+               
+               -- Power off automatically if no longer connected to a switching station
+               technic.switching_station_timeout_count(pos, "MV")
+               
+               -- Execute always logic
+               -- CODE HERE --
+
+               -- State machine
+               if eu_input == 0 then
+                  -- Unpowered - go idle
+                  hacky_swap_node(pos, machine_node)
+                  meta:set_string("infotext", machine_name.." Unpowered")
+                  next_state = 1
+               elseif eu_input == machine_state_demand[state] then
+                  -- Powered - do the state specific actions
+                  
+                  -- Execute always if powered logic
+                  local meta=minetest.env:get_meta(pos) 
+                  
+                  -- Get the names of the upgrades
+                  local meta=minetest.env:get_meta(pos) 
+                  local inv = meta:get_inventory()
+                  local upg_item1
+                  local upg_item1_name=""
+                  local upg_item2
+                  local upg_item2_name=""
+                  local srcstack = inv:get_stack("upgrade1", 1)
+                  if  srcstack then upg_item1=srcstack:to_table() end
+                  srcstack = inv:get_stack("upgrade2", 1)
+                  if  srcstack then upg_item2=srcstack:to_table() end
+                  if upg_item1 then upg_item1_name=upg_item1.name end
+                  if upg_item2 then upg_item2_name=upg_item2.name end
+                  
+                  -- Save some power by installing battery upgrades. Fully upgraded makes this
+                  -- furnace use the same amount of power as the LV version
+                  local EU_saving_upgrade = 0
+                  if upg_item1_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
+                  if upg_item2_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
+                  
+                  -- Tube loading speed can be upgraded using control logic units
+                  local tube_speed_upgrade = 0
+                  if upg_item1_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
+                  if upg_item2_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
+                  
+                  -- Handle pipeworks (consumes tube_speed_upgrade)
+                  local pos1={x=pos.x, y=pos.y, z=pos.z}
+                  local x_velocity=0
+                  local z_velocity=0
+                  
+                  -- Output is on the left side of the furnace
+                  if node.param2==3 then pos1.z=pos1.z-1 z_velocity =-1 end
+                  if node.param2==2 then pos1.x=pos1.x-1 x_velocity =-1 end
+                  if node.param2==1 then pos1.z=pos1.z+1 z_velocity = 1 end
+                  if node.param2==0 then pos1.x=pos1.x+1 x_velocity = 1 end
+                  
+                  local output_tube_connected = false
+                  local meta1 = minetest.env:get_meta(pos1) 
+                  if meta1:get_int("tubelike") == 1 then
+                     output_tube_connected=true
+                  end
+                  tube_time = meta:get_int("tube_time")
+                  tube_time = tube_time + tube_speed_upgrade
+                  if tube_time > 3 then
+                     tube_time = 0
+                     if output_tube_connected then
+                        send_cooked_items(pos,x_velocity,z_velocity)
+                     end
+                  end
+                  meta:set_int("tube_time", tube_time)
+
+                  -- The machine shuts down if we have nothing to smelt and no tube is connected
+                  -- or if we have nothing to send with a tube connected.
+                  if    (not output_tube_connected and inv:is_empty("src"))
+                     or (    output_tube_connected and inv:is_empty("dst")) then
+                     next_state = 1
+                  end
+                  ----------------------
+                  local empty  = 1
+                  local recipe = nil
+                  local result = nil
+
+                  -- Get what to cook if anything
+                  local srcstack  = inv:get_stack("src", 1)
+                  local src2stack = inv:get_stack("src", 2)
+                  local src_item1 = nil
+                  local src_item2 = nil
+                  if srcstack and src2stack then
+                     src_item1 = srcstack:to_table()
+                     src_item2 = src2stack:to_table()
+                     empty     = 0
+                  end
+                  
+                  if src_item1 and src_item2 then
+                     recipe = technic.get_alloy_recipe(src_item1,src_item2)
+                  end
+                  if recipe then
+                     result = { name=recipe.dst_name, count=recipe.dst_count}
+                  end
+                  
+                  if state == 1 then
+                     hacky_swap_node(pos, machine_node)
+                     meta:set_string("infotext", machine_name.." Idle")
+                     
+                     local meta=minetest.env:get_meta(pos) 
+                     local inv = meta:get_inventory()
+                     if not inv:is_empty("src") then
+                        if empty == 0 and recipe and inv:room_for_item("dst", result) then
+                           meta:set_string("infotext", machine_name.." Active")
+                           meta:set_int("src_time",     0)
+                           next_state = 2+EU_saving_upgrade -- Next state is decided by the battery upgrade (state 2= 0 batteries, state 3 = 1 battery, 4 = 2 batteries)
+                        end
+                     end
+                     
+                  elseif state == 2 or state == 3 or state == 4 then
+                     hacky_swap_node(pos, machine_node.."_active")
+                     meta:set_int("src_time", meta:get_int("src_time") + 1)
+                     if meta:get_int("src_time") == 4 then -- 4 ticks per output
+                        meta:set_string("src_time", 0)
+                        -- check if there's room for output in "dst" list and that we have the materials
+                        if recipe and inv:room_for_item("dst", result) then
+                           -- Take stuff from "src" list
+                           srcstack:take_item(recipe.src1_count)
+                           inv:set_stack("src", 1, srcstack)
+                           src2stack:take_item(recipe.src2_count)
+                           inv:set_stack("src2", 1, src2stack)
+                           -- Put result in "dst" list
+                           inv:add_item("dst",result)
+                        else
+                           next_state = 1
+                        end
+                     end
+                  end
+               end
+               -- Change state?
+               if next_state ~= state then
+                  meta:set_int("MV_EU_demand", machine_state_demand[next_state])
+                  meta:set_int("state", next_state)
+               end
+
+
+
+            ------------------------------------
+
+--          local pos1={}
+--          pos1.x=pos.x
+--          pos1.y=pos.y
+--          pos1.z=pos.z
+--          local x_velocity=0
+--          local z_velocity=0
+--
+--          -- output is on the left side of the furnace
+--          if node.param2==3 then pos1.z=pos1.z-1 z_velocity =-1 end
+--          if node.param2==2 then pos1.x=pos1.x-1 x_velocity =-1 end
+--          if node.param2==1 then pos1.z=pos1.z+1 z_velocity = 1 end
+--          if node.param2==0 then pos1.x=pos1.x+1 x_velocity = 1 end
+--
+--          local output_tube_connected = false
+--          local meta=minetest.env:get_meta(pos1) 
+--          if meta:get_int("tubelike")==1 then output_tube_connected=true end
+--          meta = minetest.env:get_meta(pos)
+--          local inv = meta:get_inventory()
+--          local upg_item1
+--          local upg_item1_name=""
+--          local upg_item2
+--          local upg_item2_name=""
+--          local srcstack = inv:get_stack("upgrade1", 1)
+--          if srcstack then upg_item1=srcstack:to_table() end
+--          srcstack = inv:get_stack("upgrade2", 1)
+--          if srcstack then upg_item2=srcstack:to_table() end
+--          if upg_item1 then upg_item1_name=upg_item1.name end
+--          if upg_item2 then upg_item2_name=upg_item2.name end
+--
+--          local speed=0
+--          if upg_item1_name=="technic:control_logic_unit" then speed=speed+1 end
+--          if upg_item2_name=="technic:control_logic_unit" then speed=speed+1 end
+--          tube_time=meta:get_float("tube_time")
+--          tube_time=tube_time+speed
+--          if tube_time>3 then 
+--             tube_time=0
+--             if output_tube_connected then send_cooked_items(pos,x_velocity,z_velocity) end
+--          end
+--          meta:set_float("tube_time", tube_time)
+--
+--          local extra_buffer_size = 0
+--          if upg_item1_name=="technic:battery" then extra_buffer_size =extra_buffer_size + 10000 end
+--          if upg_item2_name=="technic:battery" then extra_buffer_size =extra_buffer_size + 10000 end
+--          local internal_EU_buffer_size=2000+extra_buffer_size
+--          meta:set_float("internal_EU_buffer_size",internal_EU_buffer_size)
+--
+--          internal_EU_buffer=meta:get_float("internal_EU_buffer")
+--          if internal_EU_buffer > internal_EU_buffer_size then internal_EU_buffer = internal_EU_buffer_size end
+--          local meta = minetest.env:get_meta(pos)
+--          local load = math.floor(internal_EU_buffer/internal_EU_buffer_size * 100)
+--          meta:set_string("formspec",
+--                          MV_alloy_furnace_formspec..
+--                             "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
+--                             (load)..":technic_power_meter_fg.png]")
+--
+--          local inv = meta:get_inventory()
+--
+--          local furnace_is_cookin = meta:get_int("furnace_is_cookin")
+--
+--          local srclist = inv:get_list("src")
+--          local srclist2 = inv:get_list("src2")
+--          
+--          srcstack = inv:get_stack("src", 1)
+--          if srcstack then src_item1=srcstack:to_table() end
+--          srcstack = inv:get_stack("src", 2)
+--          if srcstack then src_item2=srcstack:to_table() end
+--          dst_index=nil
+--
+--          if src_item1 and src_item2 then 
+--             dst_index=get_cook_result(src_item1,src_item2) 
+--          end
+--
+--
+--          if (furnace_is_cookin == 1) then
+--             if internal_EU_buffer>=150 then
+--                internal_EU_buffer=internal_EU_buffer-150;
+--                meta:set_float("internal_EU_buffer",internal_EU_buffer)
+--                meta:set_float("src_time", meta:get_float("src_time") + 1)
+--                if dst_index and meta:get_float("src_time") >= 4 then
+--                   -- check if there's room for output in "dst" list
+--                   dst_stack={}
+--                   dst_stack["name"]=alloy_recipes[dst_index].dst_name
+--                   dst_stack["count"]=alloy_recipes[dst_index].dst_count
+--                   if inv:room_for_item("dst",dst_stack) then
+--                      -- Put result in "dst" list
+--                      inv:add_item("dst",dst_stack)
+--                      -- take stuff from "src" list
+--                      for i=1,alloy_recipes[dst_index].src1_count,1 do
+--                         srcstack = inv:get_stack("src", 1)
+--                         srcstack:take_item()
+--                         inv:set_stack("src", 1, srcstack)
+--                      end
+--                      for i=1,alloy_recipes[dst_index].src2_count,1 do
+--                         srcstack = inv:get_stack("src", 2)
+--                         srcstack:take_item()
+--                         inv:set_stack("src", 2, srcstack)
+--                      end
+--
+--                   else
+--                      print("Furnace inventory full!")
+--                   end
+--                   meta:set_string("src_time", 0)
+--                end
+--             end
+--          end
+--
+--          if dst_index and meta:get_int("furnace_is_cookin")==0 then
+--             hacky_swap_node(pos,"technic:mv_alloy_furnace_active")
+--             meta:set_string("infotext","MV Alloy Furnace active")
+--             meta:set_int("furnace_is_cookin",1)
+--             meta:set_string("src_time", 0)
+--             return
+--          end
+--
+--          if meta:get_int("furnace_is_cookin")==0 or dst_index==nil then
+--             hacky_swap_node(pos,"technic:mv_alloy_furnace")
+--             meta:set_string("infotext","MV Alloy Furnace inactive")
+--             meta:set_int("furnace_is_cookin",0)
+--             meta:set_string("src_time", 0)
+--          end
+--
+         end,
+ })
+
+technic.register_MV_machine ("technic:mv_alloy_furnace","RE")
+technic.register_MV_machine ("technic:mv_alloy_furnace_active","RE")
diff --git a/technic/machines/mv/battery_box.lua b/technic/machines/mv/battery_box.lua
new file mode 100644 (file)
index 0000000..e1295ce
--- /dev/null
@@ -0,0 +1,233 @@
+-- MV Battery box
+minetest.register_craft(
+   {output = 'technic:mv_battery_box 1',
+    recipe = {
+       {'technic:battery_box', 'technic:battery_box', 'technic:battery_box'},
+       {'technic:battery_box', 'technic:mv_transformer', 'technic:battery_box'},
+       {'', 'technic:mv_cable', ''},
+    }
+ })
+
+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;]"
+
+minetest.register_node(
+   "technic:mv_battery_box", {
+      description = "MV Battery Box",
+      tiles  = {"technic_mv_battery_box_top.png", "technic_mv_battery_box_bottom.png", "technic_mv_battery_box_side0.png",
+               "technic_mv_battery_box_side0.png", "technic_mv_battery_box_side0.png", "technic_mv_battery_box_side0.png"},
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+      sounds = default.node_sound_wood_defaults(),
+      drop   = "technic:mv_battery_box",
+      on_construct = function(pos)
+                       if pos==nil then return end
+                       local meta = minetest.env:get_meta(pos);
+                       local inv = meta:get_inventory()
+                       meta:set_string("infotext", "MV Battery box")
+                       meta:set_float("technic_mv_power_machine", 1)
+                       meta:set_string("formspec", battery_box_formspec)
+                       meta:set_int("MV_EU_demand", 0) -- How much can this node charge
+                       meta:set_int("MV_EU_supply", 0) -- How much can this node discharge
+                       meta:set_int("MV_EU_input",  0) -- How much power is this machine getting.
+                       meta:set_float("internal_EU_charge", 0)
+                       inv:set_size("src", 1)
+                       inv:set_size("dst", 1)
+                    end,
+      can_dig = function(pos,player)
+                  local meta = minetest.env:get_meta(pos);
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") or not inv:is_empty("dst") then
+                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                     return false
+                  else
+                     return true
+                  end
+               end,
+   })
+
+
+for i=1,8,1 do
+   minetest.register_node(
+      "technic:mv_battery_box"..i,
+      {
+        description = "MV Battery Box",
+        tiles  = {"technic_mv_battery_box_top.png", "technic_mv_battery_box_bottom.png", "technic_mv_battery_box_side0.png^technic_power_meter"..i..".png",
+                  "technic_mv_battery_box_side0.png^technic_power_meter"..i..".png", "technic_mv_battery_box_side0.png^technic_power_meter"..i..".png", "technic_mv_battery_box_side0.png^technic_power_meter"..i..".png"},
+        groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
+        sounds = default.node_sound_wood_defaults(),
+        drop   = "technic:mv_battery_box",
+        can_dig = function(pos,player)
+                     local meta = minetest.env:get_meta(pos);
+                     local inv = meta:get_inventory()
+                     if not inv:is_empty("src") or not inv:is_empty("dst") then
+                        minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                        return false
+                     else
+                        return true
+                     end
+                  end,
+      })
+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",
+                  "technic:mv_battery_box5","technic:mv_battery_box6","technic:mv_battery_box7","technic:mv_battery_box8"
+               },
+      interval = 1,
+      chance   = 1,
+      action = function(pos, node, active_object_count, active_object_count_wider)
+               local meta               = minetest.env:get_meta(pos)
+               local max_charge         = 300000 -- Set maximum charge for the device here
+               local max_charge_rate    = 2000   -- Set maximum rate of charging (4000)
+               local max_discharge_rate = 3000   -- Set maximum rate of discharging
+               local eu_input           = meta:get_int("MV_EU_input")
+               local current_charge     = meta:get_int("internal_EU_charge") -- Battery charge right now
+
+               -- Power off automatically if no longer connected to a switching station
+               technic.switching_station_timeout_count(pos, "MV")
+
+               -- Charge/discharge the battery with the input EUs
+               if eu_input >=0 then
+                  current_charge = math.min(current_charge+eu_input, max_charge)
+               else
+                  current_charge = math.max(current_charge+eu_input, 0)
+               end
+
+               -- Charging/discharging tools here
+               current_charge = charge_MV_tools(meta, current_charge)
+               current_charge = discharge_MV_tools(meta, current_charge, max_charge)
+
+               -- 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))
+
+               -- Set how much we can supply
+               meta:set_int("MV_EU_supply", math.min(max_discharge_rate, current_charge))
+
+               meta:set_int("internal_EU_charge", current_charge)
+               --dprint("BA: input:"..eu_input.." supply="..meta:get_int("MV_EU_supply").." demand="..meta:get_int("MV_EU_demand").." current:"..current_charge)
+
+               -- Select node textures
+               local i=math.ceil((current_charge/max_charge)*8)
+               if i > 8 then i = 8 end
+               local j = meta:get_float("last_side_shown")
+               if i~=j then
+                  if i>0 then hacky_swap_node(pos,"technic:mv_battery_box"..i)
+                  elseif i==0 then hacky_swap_node(pos,"technic:mv_battery_box") end
+                  meta:set_float("last_side_shown",i)
+               end
+
+               local load = math.floor(current_charge/max_charge * 100)
+               meta:set_string("formspec",
+                               battery_box_formspec..
+                                  "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
+                                  (load)..":technic_power_meter_fg.png]"
+                            )
+
+               if eu_input == 0 then
+                  meta:set_string("infotext", "MV Battery box: "..current_charge.."/"..max_charge.." (idle)")
+               else
+                  meta:set_string("infotext", "MV Battery box: "..current_charge.."/"..max_charge)
+               end
+            end
+   })
+
+-- Register as a battery type
+-- Battery type machines function as power reservoirs and can both receive and give back power
+technic.register_MV_machine("technic:mv_battery_box","BA")
+for i=1,8,1 do
+   technic.register_MV_machine("technic:mv_battery_box"..i,"BA")
+end
+
diff --git a/technic/machines/mv/electric_furnace.lua b/technic/machines/mv/electric_furnace.lua
new file mode 100644 (file)
index 0000000..7f205b5
--- /dev/null
@@ -0,0 +1,304 @@
+-- MV Electric Furnace
+-- This is a faster version of the stone furnace which runs on EUs
+-- In addition to this it can be upgraded with microcontrollers and batteries
+-- This new version uses the batteries to lower the power consumption of the machine
+-- Also in addition this furnace can be attached to the pipe system from the pipeworks mod.
+
+-- FIXME: kpoppel I'd like to introduce an induction heating element here also
+minetest.register_craft(
+   {output = 'technic:mv_electric_furnace',
+    recipe = {
+       {'technic:stainless_steel_ingot', 'technic:electric_furnace', 'technic:stainless_steel_ingot'},
+       {'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
+       {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
+    }
+ })
+
+local mv_electric_furnace_formspec =
+   "invsize[8,10;]"..
+   "list[current_name;src;3,1;1,1;]"..
+   "list[current_name;dst;5,1;2,2;]"..
+   "list[current_player;main;0,6;8,4;]"..
+   "label[0,0;MV Electric Furnace]"..
+   "list[current_name;upgrade1;1,4;1,1;]"..
+   "list[current_name;upgrade2;2,4;1,1;]"..
+   "label[1,5;Upgrade Slots]"
+
+minetest.register_node(
+   "technic:mv_electric_furnace",
+   {description = "MV Electric furnace",
+    tiles = {"technic_mv_electric_furnace_top.png", "technic_mv_electric_furnace_bottom.png", "technic_mv_electric_furnace_side_tube.png",
+            "technic_mv_electric_furnace_side_tube.png", "technic_mv_electric_furnace_side.png", "technic_mv_electric_furnace_front.png"},
+    paramtype2 = "facedir",
+    groups = {cracky=2, tubedevice=1,tubedevice_receiver=1,},
+    tube={insert_object=function(pos,node,stack,direction)
+                          local meta=minetest.env:get_meta(pos)
+                          local inv=meta:get_inventory()
+                          return inv:add_item("src",stack)
+                       end,
+         can_insert=function(pos,node,stack,direction)
+                       local meta=minetest.env:get_meta(pos)
+                       local inv=meta:get_inventory()
+                       return inv:room_for_item("src",stack)
+                    end,
+       },
+    legacy_facedir_simple = true,
+    sounds = default.node_sound_stone_defaults(),
+    on_construct = function(pos)
+                     local meta = minetest.env:get_meta(pos)
+                     meta:set_string("infotext", "MV Electric furnace")
+                     meta:set_float("technic_mv_power_machine", 1)
+                     meta:set_int("tube_time",  0)
+                     meta:set_string("formspec", mv_electric_furnace_formspec)
+                     local inv = meta:get_inventory()
+                     inv:set_size("src", 1)
+                     inv:set_size("dst", 4)
+                     inv:set_size("upgrade1", 1)
+                     inv:set_size("upgrade2", 1)
+                  end,
+    can_dig = function(pos,player)
+                local meta = minetest.env:get_meta(pos);
+                local inv = meta:get_inventory()
+                if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
+                   minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                   return false
+                else
+                   return true
+                end
+             end,
+ })
+
+minetest.register_node(
+   "technic:mv_electric_furnace_active",
+   {description = "MV Electric Furnace",
+    tiles = {"technic_mv_electric_furnace_top.png", "technic_mv_electric_furnace_bottom.png", "technic_mv_electric_furnace_side_tube.png",
+            "technic_mv_electric_furnace_side_tube.png", "technic_mv_electric_furnace_side.png", "technic_mv_electric_furnace_front_active.png"},
+    paramtype2 = "facedir",
+    light_source = 8,
+    drop = "technic:mv_electric_furnace",
+    groups = {cracky=2, tubedevice=1,tubedevice_receiver=1,not_in_creative_inventory=1},
+    tube={insert_object=function(pos,node,stack,direction)
+                          local meta=minetest.env:get_meta(pos)
+                          local inv=meta:get_inventory()
+                          return inv:add_item("src",stack)
+                       end,
+         can_insert=function(pos,node,stack,direction)
+                       local meta=minetest.env:get_meta(pos)
+                       local inv=meta:get_inventory()
+                       return inv:room_for_item("src",stack)
+                    end,
+       },
+    legacy_facedir_simple = true,
+    sounds = default.node_sound_stone_defaults(),
+    can_dig = function(pos,player)
+                local meta = minetest.env:get_meta(pos);
+                local inv = meta:get_inventory()
+                if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
+                   minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
+                   return false
+                else
+                   return true
+                end
+             end,
+    -- These three makes sure upgrades are not moved in or out while the furnace is active.
+    allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+                                      if listname == "src" or listname == "dst" then
+                                         return 99
+                                      else
+                                         return 0 -- Disallow the move
+                                      end
+                                  end,
+    allow_metadata_inventory_take = function(pos, listname, index, stack, player)
+                                      if listname == "src" or listname == "dst" then
+                                         return 99
+                                      else
+                                         return 0 -- Disallow the move
+                                      end
+                                   end,
+    allow_metadata_inventory_move = function(pos, from_list, to_list, to_list, to_index, count, player)
+                                   return 0
+                                end,
+ })
+
+local send_cooked_items = function(pos,x_velocity,z_velocity)
+                            -- Send items on their way in the pipe system.
+                            local meta=minetest.env:get_meta(pos) 
+                            local inv = meta:get_inventory()
+                            local i=0
+                            for _,stack in ipairs(inv:get_list("dst")) do
+                               i=i+1
+                               if stack then
+                                  local item0=stack:to_table()
+                               if item0 then 
+                                  item0["count"]="1"
+                                  local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
+                                  item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
+                                  item1:setvelocity({x=x_velocity, y=0, z=z_velocity})
+                                  item1:setacceleration({x=0, y=0, z=0})
+                                  stack:take_item(1);
+                                  inv:set_stack("dst", i, stack)
+                                  return
+                               end
+                            end
+                         end
+                      end
+
+local smelt_item = function(pos)
+                     local meta=minetest.env:get_meta(pos) 
+                     local inv = meta:get_inventory()
+                     meta:set_int("src_time", meta:get_int("src_time") + 3) -- Cooking time 3x faster
+                     local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
+                     if result and result.item and meta:get_int("src_time") >= result.time then
+                        meta:set_int("src_time", 0)
+                        -- check if there's room for output in "dst" list
+                        if inv:room_for_item("dst",result) then
+                           -- take stuff from "src" list
+                           srcstack = inv:get_stack("src", 1)
+                           srcstack:take_item()
+                           inv:set_stack("src", 1, srcstack)
+                           -- Put result in "dst" list
+                           inv:add_item("dst", result.item)
+                           return 1
+                        else
+                           return 0 -- done
+                        end
+                     end
+                     return 0 -- done
+                  end
+
+minetest.register_abm(
+   {nodenames = {"technic:mv_electric_furnace","technic:mv_electric_furnace_active"},
+    interval = 1,
+    chance   = 1,
+    action = function(pos, node, active_object_count, active_object_count_wider)
+               local meta         = minetest.env:get_meta(pos)
+               local eu_input     = meta:get_int("MV_EU_input")
+               local state        = meta:get_int("state")
+               local next_state   = state
+
+               -- Machine information
+               local machine_name         = "MV Electric Furnace"
+               local machine_node         = "technic:mv_electric_furnace"
+               local machine_state_demand = { 50, 2000, 1500, 1000 }
+                        
+               -- Setup meta data if it does not exist. state is used as an indicator of this
+               if state == 0 then
+                  meta:set_int("state", 1)
+                  meta:set_int("MV_EU_demand", machine_state_demand[1])
+                  meta:set_int("MV_EU_input", 0)
+                  return
+               end
+                        
+               -- Power off automatically if no longer connected to a switching station
+               technic.switching_station_timeout_count(pos, "MV")
+               
+               -- Execute always logic
+               -- CODE HERE --
+               
+               -- State machine
+               if eu_input == 0 then
+                  -- Unpowered - go idle
+                  hacky_swap_node(pos, machine_node)
+                  meta:set_string("infotext", machine_name.." Unpowered")
+                  next_state = 1
+               elseif eu_input == machine_state_demand[state] then
+                  -- Powered - do the state specific actions
+                           
+                  -- Execute always if powered logic
+                  local meta=minetest.env:get_meta(pos) 
+                         
+                  -- Get the names of the upgrades
+                  local meta=minetest.env:get_meta(pos) 
+                  local inv = meta:get_inventory()
+                  local upg_item1
+                  local upg_item1_name=""
+                  local upg_item2
+                  local upg_item2_name=""
+                  local srcstack = inv:get_stack("upgrade1", 1)
+                  if  srcstack then upg_item1=srcstack:to_table() end
+                  srcstack = inv:get_stack("upgrade2", 1)
+                  if  srcstack then upg_item2=srcstack:to_table() end
+                  if upg_item1 then upg_item1_name=upg_item1.name end
+                  if upg_item2 then upg_item2_name=upg_item2.name end
+                  
+                  -- Save some power by installing battery upgrades. Fully upgraded makes this
+                  -- furnace use the same amount of power as the LV version
+                  local EU_saving_upgrade = 0
+                  if upg_item1_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
+                  if upg_item2_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
+                  
+                  -- Tube loading speed can be upgraded using control logic units
+                  local tube_speed_upgrade = 0
+                  if upg_item1_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
+                  if upg_item2_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
+                  
+                  -- Handle pipeworks (consumes tube_speed_upgrade)
+                  local pos1={x=pos.x, y=pos.y, z=pos.z}
+                  local x_velocity=0
+                  local z_velocity=0
+                  
+                  -- Output is on the left side of the furnace
+                  if node.param2==3 then pos1.z=pos1.z-1 z_velocity =-1 end
+                  if node.param2==2 then pos1.x=pos1.x-1 x_velocity =-1 end
+                  if node.param2==1 then pos1.z=pos1.z+1 z_velocity = 1 end
+                  if node.param2==0 then pos1.x=pos1.x+1 x_velocity = 1 end
+                  
+                  local output_tube_connected = false
+                  local meta1 = minetest.env:get_meta(pos1) 
+                  if meta1:get_int("tubelike") == 1 then
+                     output_tube_connected=true
+                  end
+                  tube_time = meta:get_int("tube_time")
+                  tube_time = tube_time + tube_speed_upgrade
+                  if tube_time > 3 then
+                     tube_time = 0
+                     if output_tube_connected then
+                        send_cooked_items(pos,x_velocity,z_velocity)
+                     end
+                  end
+                  meta:set_int("tube_time", tube_time)
+                  
+                  -- The machine shuts down if we have nothing to smelt and no tube is connected
+                  -- or if we have nothing to send with a tube connected.
+                  if    (not output_tube_connected and inv:is_empty("src"))
+                  or (    output_tube_connected and inv:is_empty("dst")) then
+                  next_state = 1
+               end
+               ----------------------
+               
+               if state == 1 then
+                  hacky_swap_node(pos, machine_node)
+                  meta:set_string("infotext", machine_name.." Idle")
+                  
+                  local meta=minetest.env:get_meta(pos) 
+                  local inv = meta:get_inventory()
+                  if not inv:is_empty("src") then
+                     local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
+                     if result then
+                        meta:set_string("infotext", machine_name.." Active")
+                        meta:set_int("src_time",     0)
+                        next_state = 2+EU_saving_upgrade -- Next state is decided by the battery upgrade (state 2= 0 batteries, state 3 = 1 battery, 4 = 2 batteries)
+                     end
+                  else
+                     meta:set_string("infotext", "Electric Furnace Idle")
+                  end
+                  
+               elseif state == 2 or state == 3 or state == 4 then
+                  hacky_swap_node(pos, machine_node.."_active")
+                  meta:set_string("infotext", machine_name.." Active")
+                  result = smelt_item(pos, data)
+                  if result == 0 then
+                     next_state = 1
+                  end
+               end
+            end
+            -- Change state?
+            if next_state ~= state then
+               meta:set_int("MV_EU_demand", machine_state_demand[next_state])
+               meta:set_int("state", next_state)
+            end
+         end,
+ })
+
+technic.register_MV_machine ("technic:mv_electric_furnace","RE")
+technic.register_MV_machine ("technic:mv_electric_furnace_active","RE")
diff --git a/technic/machines/mv/init.lua b/technic/machines/mv/init.lua
new file mode 100644 (file)
index 0000000..1e1147c
--- /dev/null
@@ -0,0 +1,13 @@
+local path = technic.modpath.."/machines/mv"
+
+dofile(path.."/wires.lua")
+dofile(path.."/battery_box.lua")
+dofile(path.."/solar_array.lua")
+dofile(path.."/electric_furnace.lua")
+dofile(path.."/alloy_furnace.lua")
+
+-- The power radiator supplies appliances with inductive coupled power:
+-- Lighting and associated textures is taken directly from VanessaE's homedecor and made electric.
+dofile(path.."/power_radiator.lua")
+dofile(path.."/lighting.lua")
+
diff --git a/technic/machines/mv/lighting.lua b/technic/machines/mv/lighting.lua
new file mode 100644 (file)
index 0000000..546e42c
--- /dev/null
@@ -0,0 +1,590 @@
+-- NOTE: The code is takes directly from VanessaE's homedecor mod.
+-- I just made it the lights into indictive appliances for this mod.
+
+-- This file supplies electric powered glowlights
+
+-- Boilerplate to support localized strings if intllib mod is installed.
+local S
+if (minetest.get_modpath("intllib")) then
+    dofile(minetest.get_modpath("intllib").."/intllib.lua")
+    S = intllib.Getter(minetest.get_current_modname())
+else
+    S = function ( s ) return s end
+end
+
+function technic_homedecor_node_is_owned(pos, placer)
+        local ownername = false
+        if type(IsPlayerNodeOwner) == "function" then                                   -- node_ownership mod
+                if HasOwner(pos, placer) then                                           -- returns true if the node is owned
+                        if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
+                                if type(getLastOwner) == "function" then                -- ...is an old version
+                                        ownername = getLastOwner(pos)
+                                elseif type(GetNodeOwnerName) == "function" then        -- ...is a recent version
+                                        ownername = GetNodeOwnerName(pos)
+                                else
+                                        ownername = S("someone")
+                                end
+                        end
+                end
+
+        elseif type(isprotect)=="function" then                                         -- glomie's protection mod
+                if not isprotect(5, pos, placer) then
+                        ownername = S("someone")
+                end
+        elseif type(protector)=="table" and type(protector.can_dig)=="function" then                                    -- Zeg9's protection mod
+                if not protector.can_dig(5, pos, placer) then
+                        ownername = S("someone")
+                end
+        end
+
+        if ownername ~= false then
+                minetest.chat_send_player( placer:get_player_name(), S("Sorry, %s owns that spot."):format(ownername) )
+                return true
+        else
+                return false
+        end
+end
+
+local dirs1 = { 20, 23, 22, 21 }
+local dirs2 = { 9, 18, 7, 12 }
+
+local technic_homedecor_rotate_and_place = function(itemstack, placer, pointed_thing)
+       if not technic_homedecor_node_is_owned(pointed_thing.under, placer) 
+          and not technic_homedecor_node_is_owned(pointed_thing.above, placer) then
+               local node = minetest.env:get_node(pointed_thing.under)
+               if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
+
+                       local above = pointed_thing.above
+                       local under = pointed_thing.under
+                       local pitch = placer:get_look_pitch()
+                       local pname = minetest.env:get_node(under).name
+                       local node = minetest.env:get_node(above)
+                       local fdir = minetest.dir_to_facedir(placer:get_look_dir())
+                       local wield_name = itemstack:get_name()
+
+                       if not minetest.registered_nodes[pname]
+                           or not minetest.registered_nodes[pname].on_rightclick then
+
+                               local iswall = (above.x ~= under.x) or (above.z ~= under.z)
+                               local isceiling = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
+                               local pos1 = above
+
+                               if minetest.registered_nodes[pname]["buildable_to"] then
+                                       pos1 = under
+                                       iswall = false
+                               end
+
+                               if not minetest.registered_nodes[minetest.env:get_node(pos1).name]["buildable_to"] then return end
+
+                               if iswall then 
+                                       minetest.env:add_node(pos1, {name = wield_name, param2 = dirs2[fdir+1] }) -- place wall variant
+                               elseif isceiling then
+                                       minetest.env:add_node(pos1, {name = wield_name, param2 = 20 }) -- place upside down variant
+                               else
+                                       minetest.env:add_node(pos1, {name = wield_name, param2 = 0 }) -- place right side up
+                               end
+
+                               if not homedecor_expect_infinite_stacks then
+                                       itemstack:take_item()
+                                       return itemstack
+                               end
+                       end
+               else
+                       minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack)
+               end
+       end
+end
+
+-- Yellow -- Half node
+minetest.register_node('technic:homedecor_glowlight_half_yellow', {
+       description = S("Yellow Glowlight (thick)"),
+       drawtype = "nodebox",
+       tiles = {
+               'technic_homedecor_glowlight_yellow_tb.png',
+               'technic_homedecor_glowlight_yellow_tb.png',
+               'technic_homedecor_glowlight_thick_yellow_sides.png',
+               'technic_homedecor_glowlight_thick_yellow_sides.png',
+               'technic_homedecor_glowlight_thick_yellow_sides.png',
+               'technic_homedecor_glowlight_thick_yellow_sides.png'
+       },
+        selection_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
+        },
+        node_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
+        },
+
+       sunlight_propagates = false,
+       paramtype = "light",
+       paramtype2 = "facedir",
+       walkable = true,
+       sounds = default.node_sound_wood_defaults(),
+
+       groups = { snappy = 3 },
+       on_place = function(itemstack, placer, pointed_thing)
+               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
+               return itemstack
+            end,
+       on_construct = function(pos)
+                         technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thick)")
+                      end,
+       on_punch = function(pos, node, puncher)
+                     technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_half_yellow_active")
+                  end
+})
+
+minetest.register_node('technic:homedecor_glowlight_half_yellow_active', {
+       description = S("Yellow Glowlight (thick)"),
+       drawtype = "nodebox",
+       tiles = {
+               'technic_homedecor_glowlight_yellow_tb.png',
+               'technic_homedecor_glowlight_yellow_tb.png',
+               'technic_homedecor_glowlight_thick_yellow_sides.png',
+               'technic_homedecor_glowlight_thick_yellow_sides.png',
+               'technic_homedecor_glowlight_thick_yellow_sides.png',
+               'technic_homedecor_glowlight_thick_yellow_sides.png'
+       },
+        selection_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
+        },
+        node_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
+        },
+
+       sunlight_propagates = false,
+       paramtype = "light",
+       paramtype2 = "facedir",
+       walkable = true,
+       light_source = LIGHT_MAX,
+       sounds = default.node_sound_wood_defaults(),
+
+       groups = { snappy = 3, not_in_creative_inventory=1},
+       drop="technic:homedecor_glowlight_half_yellow",
+       on_place = function(itemstack, placer, pointed_thing)
+               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
+               return itemstack
+            end,
+       on_construct = function(pos)
+                         technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thick)")
+                      end,
+       on_punch = function(pos, node, puncher)
+                     technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_half_yellow")
+                  end
+})
+
+-- Yellow -- Quarter node
+minetest.register_node('technic:homedecor_glowlight_quarter_yellow', {
+       description = S("Yellow Glowlight (thin)"),
+       drawtype = "nodebox",
+       tiles = {
+               'technic_homedecor_glowlight_yellow_tb.png',
+               'technic_homedecor_glowlight_yellow_tb.png',
+               'technic_homedecor_glowlight_thin_yellow_sides.png',
+               'technic_homedecor_glowlight_thin_yellow_sides.png',
+               'technic_homedecor_glowlight_thin_yellow_sides.png',
+               'technic_homedecor_glowlight_thin_yellow_sides.png'
+       },
+        selection_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
+        },
+        node_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
+        },
+
+       sunlight_propagates = false,
+       paramtype = "light",
+       paramtype2 = "facedir",
+       walkable = true,
+       sounds = default.node_sound_wood_defaults(),
+
+       groups = { snappy = 3 },
+       on_place = function(itemstack, placer, pointed_thing)
+               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
+               return itemstack
+            end,
+       on_construct = function(pos)
+                         technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thin)")
+                      end,
+       on_punch = function(pos, node, puncher)
+                     technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_quarter_yellow_active")
+                  end
+})
+
+minetest.register_node('technic:homedecor_glowlight_quarter_yellow_active', {
+       description = S("Yellow Glowlight (thin)"),
+       drawtype = "nodebox",
+       tiles = {
+               'technic_homedecor_glowlight_yellow_tb.png',
+               'technic_homedecor_glowlight_yellow_tb.png',
+               'technic_homedecor_glowlight_thin_yellow_sides.png',
+               'technic_homedecor_glowlight_thin_yellow_sides.png',
+               'technic_homedecor_glowlight_thin_yellow_sides.png',
+               'technic_homedecor_glowlight_thin_yellow_sides.png'
+       },
+        selection_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
+        },
+        node_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
+        },
+
+       sunlight_propagates = false,
+       paramtype = "light",
+       paramtype2 = "facedir",
+       walkable = true,
+       light_source = LIGHT_MAX-1,
+       sounds = default.node_sound_wood_defaults(),
+
+       groups = { snappy = 3, not_in_creative_inventory=1},
+       drop="technic:homedecor_glowlight_quarter_yellow",
+       on_place = function(itemstack, placer, pointed_thing)
+               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
+               return itemstack
+            end,
+       on_construct = function(pos)
+                         technic.inductive_on_construct(pos, 100, "Yellow Glowlight (thin)")
+                      end,
+       on_punch = function(pos, node, puncher)
+                     technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_quarter_yellow")
+                  end
+})
+
+
+-- White -- half node
+minetest.register_node('technic:homedecor_glowlight_half_white', {
+       description = S("White Glowlight (thick)"),
+       drawtype = "nodebox",
+       tiles = {
+               'technic_homedecor_glowlight_white_tb.png',
+               'technic_homedecor_glowlight_white_tb.png',
+               'technic_homedecor_glowlight_thick_white_sides.png',
+               'technic_homedecor_glowlight_thick_white_sides.png',
+               'technic_homedecor_glowlight_thick_white_sides.png',
+               'technic_homedecor_glowlight_thick_white_sides.png'
+       },
+        selection_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
+        },
+        node_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
+        },
+
+       sunlight_propagates = false,
+       paramtype = "light",
+       paramtype2 = "facedir",
+       walkable = true,
+       sounds = default.node_sound_wood_defaults(),
+
+       groups = { snappy = 3 },
+       on_place = function(itemstack, placer, pointed_thing)
+               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
+               return itemstack
+            end,
+       on_construct = function(pos)
+                         technic.inductive_on_construct(pos, 100, "White Glowlight (thick)")
+                      end,
+       on_punch = function(pos, node, puncher)
+                     technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_half_white_active")
+                  end
+})
+
+minetest.register_node('technic:homedecor_glowlight_half_white_active', {
+       description = S("White Glowlight (thick)"),
+       drawtype = "nodebox",
+       tiles = {
+               'technic_homedecor_glowlight_white_tb.png',
+               'technic_homedecor_glowlight_white_tb.png',
+               'technic_homedecor_glowlight_thick_white_sides.png',
+               'technic_homedecor_glowlight_thick_white_sides.png',
+               'technic_homedecor_glowlight_thick_white_sides.png',
+               'technic_homedecor_glowlight_thick_white_sides.png'
+       },
+        selection_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
+        },
+        node_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, 0, 0.5 }
+        },
+
+       sunlight_propagates = false,
+       paramtype = "light",
+       paramtype2 = "facedir",
+       walkable = true,
+       light_source = LIGHT_MAX,
+       sounds = default.node_sound_wood_defaults(),
+
+       groups = { snappy = 3, not_in_creative_inventory=1},
+       drop="technic:homedecor_glowlight_half_white",
+       on_place = function(itemstack, placer, pointed_thing)
+               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
+               return itemstack
+            end,
+       on_construct = function(pos)
+                         technic.inductive_on_construct(pos, 100, "White Glowlight (thick)")
+                      end,
+       on_punch = function(pos, node, puncher)
+                     technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_half_white")
+                  end
+})
+
+-- White -- Quarter node
+minetest.register_node('technic:homedecor_glowlight_quarter_white', {
+       description = S("White Glowlight (thin)"),
+       drawtype = "nodebox",
+       tiles = {
+               'technic_homedecor_glowlight_white_tb.png',
+               'technic_homedecor_glowlight_white_tb.png',
+               'technic_homedecor_glowlight_thin_white_sides.png',
+               'technic_homedecor_glowlight_thin_white_sides.png',
+               'technic_homedecor_glowlight_thin_white_sides.png',
+               'technic_homedecor_glowlight_thin_white_sides.png'
+       },
+        selection_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
+        },
+        node_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
+        },
+
+       sunlight_propagates = false,
+       paramtype = "light",
+       paramtype2 = "facedir",
+       walkable = true,
+       sounds = default.node_sound_wood_defaults(),
+
+       groups = { snappy = 3 },
+       on_place = function(itemstack, placer, pointed_thing)
+               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
+               return itemstack
+            end,
+       on_construct = function(pos)
+                         technic.inductive_on_construct(pos, 100, "White Glowlight (thin)")
+                      end,
+       on_punch = function(pos, node, puncher)
+                     technic.inductive_on_punch_off(pos, 100, "technic:homedecor_glowlight_quarter_white_active")
+                  end
+})
+
+minetest.register_node('technic:homedecor_glowlight_quarter_white_active', {
+       description = S("White Glowlight (thin)"),
+       drawtype = "nodebox",
+       tiles = {
+               'technic_homedecor_glowlight_white_tb.png',
+               'technic_homedecor_glowlight_white_tb.png',
+               'technic_homedecor_glowlight_thin_white_sides.png',
+               'technic_homedecor_glowlight_thin_white_sides.png',
+               'technic_homedecor_glowlight_thin_white_sides.png',
+               'technic_homedecor_glowlight_thin_white_sides.png'
+       },
+        selection_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
+        },
+        node_box = {
+                type = "fixed",
+                fixed = { -0.5, -0.5, -0.5, 0.5, -0.25, 0.5 }
+        },
+
+       sunlight_propagates = false,
+       paramtype = "light",
+       paramtype2 = "facedir",
+       walkable = true,
+       light_source = LIGHT_MAX-1,
+       sounds = default.node_sound_wood_defaults(),
+
+       groups = { snappy = 3, not_in_creative_inventory=1},
+       drop="technic:homedecor_glowlight_quarter_white",
+       on_place = function(itemstack, placer, pointed_thing)
+               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
+               return itemstack
+            end,
+       on_construct = function(pos)
+                         technic.inductive_on_construct(pos, 100, "White Glowlight (thin)")
+                      end,
+       on_punch = function(pos, node, puncher)
+                     technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_quarter_white")
+                  end
+})
+
+-- Glowlight "cubes" - yellow
+minetest.register_node('technic:homedecor_glowlight_small_cube_yellow', {
+       description = S("Yellow Glowlight (small cube)"),
+       drawtype = "nodebox",
+       tiles = {
+               'technic_homedecor_glowlight_cube_yellow_tb.png',
+               'technic_homedecor_glowlight_cube_yellow_tb.png',
+               'technic_homedecor_glowlight_cube_yellow_sides.png',
+               'technic_homedecor_glowlight_cube_yellow_sides.png',
+               'technic_homedecor_glowlight_cube_yellow_sides.png',
+               'technic_homedecor_glowlight_cube_yellow_sides.png'
+       },
+        selection_box = {
+                type = "fixed",
+                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
+        },
+        node_box = {
+                type = "fixed",
+                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
+        },
+
+       sunlight_propagates = false,
+       paramtype = "light",
+       paramtype2 = "facedir",
+       walkable = true,
+       sounds = default.node_sound_wood_defaults(),
+
+       groups = { snappy = 3 },
+       on_place = function(itemstack, placer, pointed_thing)
+               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
+               return itemstack
+            end,
+       on_construct = function(pos)
+                         technic.inductive_on_construct(pos, 50, "Yellow Glowlight (small cube)")
+                      end,
+       on_punch = function(pos, node, puncher)
+                     technic.inductive_on_punch_off(pos, 50, "technic:homedecor_glowlight_small_cube_yellow_active")
+                  end
+})
+
+minetest.register_node('technic:homedecor_glowlight_small_cube_yellow_active', {
+       description = S("Yellow Glowlight (small cube)"),
+       drawtype = "nodebox",
+       tiles = {
+               'technic_homedecor_glowlight_cube_yellow_tb.png',
+               'technic_homedecor_glowlight_cube_yellow_tb.png',
+               'technic_homedecor_glowlight_cube_yellow_sides.png',
+               'technic_homedecor_glowlight_cube_yellow_sides.png',
+               'technic_homedecor_glowlight_cube_yellow_sides.png',
+               'technic_homedecor_glowlight_cube_yellow_sides.png'
+       },
+        selection_box = {
+                type = "fixed",
+                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
+        },
+        node_box = {
+                type = "fixed",
+                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
+        },
+
+       sunlight_propagates = false,
+       paramtype = "light",
+       paramtype2 = "facedir",
+       walkable = true,
+       light_source = LIGHT_MAX-1,
+       sounds = default.node_sound_wood_defaults(),
+
+       groups = { snappy = 3, not_in_creative_inventory=1},
+       drop="technic:homedecor_glowlight_small_cube_yellow",
+       on_place = function(itemstack, placer, pointed_thing)
+               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
+               return itemstack
+            end,
+       on_construct = function(pos)
+                         technic.inductive_on_construct(pos, 50, "Yellow Glowlight (small cube)")
+                      end,
+       on_punch = function(pos, node, puncher)
+                     technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_small_cube_yellow")
+                  end
+})
+
+-- Glowlight "cubes" - white
+minetest.register_node('technic:homedecor_glowlight_small_cube_white', {
+       description = S("White Glowlight (small cube)"),
+       drawtype = "nodebox",
+       tiles = {
+               'technic_homedecor_glowlight_cube_white_tb.png',
+               'technic_homedecor_glowlight_cube_white_tb.png',
+               'technic_homedecor_glowlight_cube_white_sides.png',
+               'technic_homedecor_glowlight_cube_white_sides.png',
+               'technic_homedecor_glowlight_cube_white_sides.png',
+               'technic_homedecor_glowlight_cube_white_sides.png'
+       },
+        selection_box = {
+                type = "fixed",
+                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
+        },
+        node_box = {
+                type = "fixed",
+                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
+        },
+
+       sunlight_propagates = false,
+       paramtype = "light",
+       paramtype2 = "facedir",
+       walkable = true,
+       sounds = default.node_sound_wood_defaults(),
+
+       groups = { snappy = 3 },
+       on_place = function(itemstack, placer, pointed_thing)
+               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
+               return itemstack
+            end,
+       on_construct = function(pos)
+                         technic.inductive_on_construct(pos, 50, "White Glowlight (small cube)")
+                      end,
+       on_punch = function(pos, node, puncher)
+                     technic.inductive_on_punch_off(pos, 50, "technic:homedecor_glowlight_small_cube_white_active")
+                  end
+})
+
+minetest.register_node('technic:homedecor_glowlight_small_cube_white_active', {
+       description = S("White Glowlight (small cube)"),
+       drawtype = "nodebox",
+       tiles = {
+               'technic_homedecor_glowlight_cube_white_tb.png',
+               'technic_homedecor_glowlight_cube_white_tb.png',
+               'technic_homedecor_glowlight_cube_white_sides.png',
+               'technic_homedecor_glowlight_cube_white_sides.png',
+               'technic_homedecor_glowlight_cube_white_sides.png',
+               'technic_homedecor_glowlight_cube_white_sides.png'
+       },
+        selection_box = {
+                type = "fixed",
+                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
+        },
+        node_box = {
+                type = "fixed",
+                fixed = { -0.25, -0.5, -0.25, 0.25, 0, 0.25 }
+        },
+
+       sunlight_propagates = false,
+       paramtype = "light",
+       paramtype2 = "facedir",
+       walkable = true,
+       light_source = LIGHT_MAX-1,
+       sounds = default.node_sound_wood_defaults(),
+
+       groups = { snappy = 3, not_in_creative_inventory=1},
+       drop="technic:homedecor_glowlight_small_cube_white",
+       on_place = function(itemstack, placer, pointed_thing)
+               technic_homedecor_rotate_and_place(itemstack, placer, pointed_thing)
+               return itemstack
+            end,
+       on_construct = function(pos)
+                         technic.inductive_on_construct(pos, 50, "White Glowlight (small cube)")
+                      end,
+       on_punch = function(pos, node, puncher)
+                     technic.inductive_on_punch_on(pos, 0, "technic:homedecor_glowlight_small_cube_white")
+                  end
+})
+
+technic.register_inductive_machine("technic:homedecor_glowlight_half_yellow")
+technic.register_inductive_machine("technic:homedecor_glowlight_half_white")
+technic.register_inductive_machine("technic:homedecor_glowlight_quarter_yellow")
+technic.register_inductive_machine("technic:homedecor_glowlight_quarter_white")
+technic.register_inductive_machine("technic:homedecor_glowlight_small_cube_yellow")
+technic.register_inductive_machine("technic:homedecor_glowlight_small_cube_white")
diff --git a/technic/machines/mv/power_radiator.lua b/technic/machines/mv/power_radiator.lua
new file mode 100644 (file)
index 0000000..86a770e
--- /dev/null
@@ -0,0 +1,226 @@
+-- The power radiator fuctions like an inductive charger
+-- only better in the game setting.
+-- The purpose is to allow small appliances to receive power
+-- without the overhead of the wiring needed for larger machines.
+--
+-- The power radiator will consume power corresponding to the
+-- sum(power rating of the attached appliances)/0.6
+-- Using inductive power transfer is very inefficient so this is
+-- set to the factor 0.6.
+--
+-- Punching the radiator will toggle the power state of all attached appliances.
+--
+local power_radius = 6
+
+------------------------------------------------------------------
+-- API for inductive powered nodes:
+-- Use the functions below to set the corresponding callbacks
+-- Also two nodes are needed: The inactive and the active one. The active must be called <name>_active .
+------------------------------------------------------------------
+-- Register a new appliance using this function
+technic.inductive_nodes = {}
+technic.register_inductive_machine = function(name)
+                                       table.insert(technic.inductive_nodes, name)
+                                       table.insert(technic.inductive_nodes, name.."_active")
+                                    end
+
+-- Appliances:
+--  has_supply: pos of supply node if the appliance has a power radiator near with sufficient power for the demand else ""
+--  EU_demand: The power demand of the device.
+--  EU_charge: Actual use. set to EU_demand if active==1
+--  active: set to 1 if the device is on
+technic.inductive_on_construct = function(pos, eu_demand, infotext)
+                                   local meta = minetest.env:get_meta(pos)
+                                   meta:set_string("infotext", infotext)
+                                   meta:set_int("technic_inductive_power_machine", 1)
+                                   meta:set_int("EU_demand",eu_demand)     -- The power demand of this appliance
+                                   meta:set_int("EU_charge",0)       -- The actual power draw of this appliance
+                                   meta:set_string("has_supply","") -- Register whether we are powered or not. For use with several radiators.
+                                   meta:set_int("active", 0)    -- If the appliance can be turned on and off by using it use this.
+                                end
+
+technic.inductive_on_punch_off = function(pos, eu_charge, swapnode)
+                   local meta = minetest.env:get_meta(pos)
+                   if meta:get_string("has_supply") ~= "" then
+                      hacky_swap_node(pos, swapnode)
+                      meta:set_int("active", 1)
+                      meta:set_int("EU_charge",eu_charge)
+                      --print("-----------")
+                      --print("Turn on:")
+                      --print("EUcha:"..meta:get_int("EU_charge"))
+                      --print("has_supply:"..meta:get_string("has_supply"))
+                      --print("<----------->")
+                   end
+                end
+
+technic.inductive_on_punch_on = function(pos, eu_charge, swapnode)
+                   local meta = minetest.env:get_meta(pos)
+                   hacky_swap_node(pos, swapnode)
+                   meta:set_int("active", 0)
+                   meta:set_int("EU_charge",eu_charge)
+                   --print("-----------")
+                   --print("Turn off:")
+                   --print("EUcha:"..meta:get_int("EU_charge"))
+                   --print("has_supply:"..meta:get_string("has_supply"))
+                   --print("<---------->")
+                end
+
+local shutdown_inductive_appliances = function(pos)
+                                        -- The supply radius
+                                        local rad = power_radius
+                                        -- If the radiator is removed. turn off all appliances in region
+                                        -- If another radiator is near it will turn on the appliances again
+                                        local positions = minetest.env:find_nodes_in_area({x=pos.x-rad,y=pos.y-rad,z=pos.z-rad},{x=pos.x+rad,y=pos.y+rad,z=pos.z+rad}, technic.inductive_nodes)
+                                        for _,pos1 in pairs(positions) do
+                                           local meta1 = minetest.env:get_meta(pos1)
+                                           -- If the appliance is belonging to this node
+                                           if meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
+                                              local nodename = minetest.env:get_node(pos1).name
+                                              -- Swap the node and make sure it is off and unpowered
+                                              if string.sub(nodename, -7) == "_active" then
+                                                 hacky_swap_node(pos1, string.sub(nodename, 1, -8))
+                                                 meta1:set_int("active", 0)
+                                                 meta1:set_int("EU_charge", 0)
+                                              end
+                                              meta1:set_string("has_supply", "")
+                                          end
+                                       end
+                                    end
+
+local toggle_on_off_inductive_appliances = function(pos, node, puncher)
+                                             if pos == nil then return end
+                                             -- The supply radius
+                                             local rad = power_radius
+                                             local positions = minetest.env:find_nodes_in_area({x=pos.x-rad,y=pos.y-rad,z=pos.z-rad},{x=pos.x+rad,y=pos.y+rad,z=pos.z+rad}, technic.inductive_nodes)
+                                             for _,pos1 in pairs(positions) do
+                                                local meta1 = minetest.env:get_meta(pos1)
+                                                if meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
+                                                   minetest.env:punch_node(pos1)
+                                                end
+                                             end
+                                          end
+
+minetest.register_node(
+   "technic:power_radiator", {
+      description = "Power Radiator",
+      tiles  = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
+               "technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+      sounds = default.node_sound_wood_defaults(),
+      drawtype = "nodebox",
+      paramtype = "light",
+      is_ground_content = true,
+      node_box = {
+        type = "fixed",
+        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
+      },
+      selection_box = {
+        type = "fixed",
+        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
+      },
+      on_construct = function(pos)
+                       local meta = minetest.env:get_meta(pos)
+                       meta:set_int("technic_mv_power_machine", 1)  -- MV machine
+                       meta:set_int("MV_EU_demand",1)               -- Demand on the primary side when idle
+                       meta:set_int("connected_EU_demand",0)        -- Potential demand of connected appliances
+                       meta:set_string("infotext", "Power Radiator")
+--                     meta:set_int("active", 0)
+                    end,
+      on_dig = function(pos, node, digger)
+                 shutdown_inductive_appliances(pos)
+                 return minetest.node_dig(pos, node, digger)
+              end,
+      on_punch = function(pos, node, puncher)
+                   toggle_on_off_inductive_appliances(pos, node, puncher)
+                end
+   })
+
+minetest.register_craft(
+   {
+      output = 'technic:power_radiator 1',
+      recipe = {
+        {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
+        {'technic:copper_coil',           'technic:mv_transformer',        'technic:copper_coil'},
+        {'technic:rubber',                'technic:mv_cable',              'technic:rubber'},
+      }
+   })
+
+minetest.register_abm(
+   {nodenames = {"technic:power_radiator"},
+    interval   = 1,
+    chance     = 1,
+    action = function(pos, node, active_object_count, active_object_count_wider)
+               local meta             = minetest.env:get_meta(pos)
+               local eu_input  = meta:get_int("MV_EU_input")
+               local eu_demand = meta:get_int("MV_EU_demand")
+
+               -- Power off automatically if no longer connected to a switching station
+               technic.switching_station_timeout_count(pos, "MV")
+
+               if eu_input == 0 then
+                  -- No power
+                  meta:set_string("infotext", "Power Radiator is unpowered");
+--                   meta:set_int("active",1) -- used for setting textures someday maybe
+                  shutdown_inductive_appliances(pos)
+                  meta:set_int("connected_EU_demand", 0)
+                  meta:set_int("MV_EU_demand",1)
+               elseif eu_input == eu_demand then
+                  -- Powered and ready
+
+                  -- The maximum EU sourcing a single radiator can provide.
+                  local max_charge          = 3000 -- == the max EU demand of the radiator
+                  local connected_EU_demand = meta:get_int("connected_EU_demand")
+
+                  -- Efficiency factor
+                  local eff_factor = 0.6
+                  -- The supply radius
+                  local rad = power_radius
+                  
+                  local meta1            = nil
+                  local pos1             = {}
+                  local used_charge      = 0
+                  
+                  -- Index all nodes within supply range
+                  local positions = minetest.env:find_nodes_in_area({x=pos.x-rad,y=pos.y-rad,z=pos.z-rad},{x=pos.x+rad,y=pos.y+rad,z=pos.z+rad}, technic.inductive_nodes)
+                  for _,pos1 in pairs(positions) do
+                     local meta1 = minetest.env:get_meta(pos1)
+                     -- If not supplied see if this node can handle it.
+                     if meta1:get_string("has_supply") == "" then
+                        -- if demand surpasses the capacity of this node, don't bother adding it.
+                        local app_eu_demand = math.floor(meta1:get_int("EU_demand")/eff_factor)
+                        if connected_EU_demand + app_eu_demand <= max_charge then
+                           --print("I can supply this:"..connected_EU_demand.."|"..app_eu_demand.."<="..max_charge.."|act:"..meta1:get_int("EU_charge"))
+                           -- We can power the appliance. Register, and spend power if it is on.
+                           connected_EU_demand = connected_EU_demand + app_eu_demand
+
+                           meta1:set_string("has_supply", pos.x..pos.y..pos.z)
+                           --Always 0: used_charge = math.floor(used_charge+meta1:get_int("EU_charge")/eff_factor)
+                        end
+                     elseif meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
+                        -- The appliance has power from this node. Spend power if it is on.
+                        used_charge = used_charge+math.floor(meta1:get_int("EU_charge")/eff_factor)
+                        --print("My Lamp ("..pos.x..","..pos.y..","..pos.z..") Used:"..used_charge.."Max:"..max_charge)
+                     end
+                     meta:set_string("infotext", "Power Radiator is powered ("..math.floor(used_charge/max_charge*100).."% of maximum power)");
+                     if used_charge == 0 then
+                        meta:set_int("MV_EU_demand", 1) -- Still idle
+                     else
+                        meta:set_int("MV_EU_demand", used_charge)
+                     end
+--                   meta:set_int("active",1) -- used for setting textures someday maybe
+                  end
+                  -- Save state
+                  meta:set_int("connected_EU_demand",connected_EU_demand)
+               else
+                  -- This is the case where input ~= demand. Overloaded or underpowered!
+--                --If demand surpasses actual supply turn off everything - we are out of power
+--                if used_charge>eu_input then
+--                   meta:set_string("infotext", "Power Radiator is overloaded ("..math.floor(used_charge/eu_input*100).."% of available power)");
+----                 meta:set_int("active",1) -- used for setting textures someday maybe
+--                   shutdown_inductive_appliances(pos)
+--                   connected_EU_demand = 0
+               end
+            end,
+ })
+
+technic.register_MV_machine ("technic:power_radiator","RE")
diff --git a/technic/machines/mv/solar_array.lua b/technic/machines/mv/solar_array.lua
new file mode 100644 (file)
index 0000000..f389a9f
--- /dev/null
@@ -0,0 +1,82 @@
+-- The medium voltage solar array is an assembly of low voltage arrays.
+-- The assembly can deliver medium voltage levels and is a 10% less efficient
+-- compared to 5 individual low voltage arrays due to losses in the transformer.
+-- However medium voltage is supplied.
+-- Solar arrays are not able to store large amounts of energy.
+-- The MV arrays are used to make high voltage arrays.
+minetest.register_node("technic:solar_array_mv", {
+       tiles = {"technic_mv_solar_array_top.png", "technic_mv_solar_array_bottom.png", "technic_mv_solar_array_side.png",
+                "technic_mv_solar_array_side.png", "technic_mv_solar_array_side.png", "technic_mv_solar_array_side.png"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+       sounds = default.node_sound_wood_defaults(),
+       description="MV Solar Array",
+       active = false,
+       drawtype = "nodebox",
+       paramtype = "light",
+       is_ground_content = true,       
+       node_box = {
+                       type = "fixed",
+                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
+               },
+               selection_box = {
+                       type = "fixed",
+                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
+               },
+       on_construct = function(pos)
+               local meta = minetest.env:get_meta(pos)
+               meta:set_float("technic_mv_power_machine", 1)
+               meta:set_int("MV_EU_supply", 0)
+               meta:set_string("infotext", "MV Solar Array")
+       end,
+})
+
+minetest.register_craft(
+   {
+      output = 'technic:solar_array_mv 1',
+      recipe = {
+        {'technic:solar_array_lv', 'technic:solar_array_lv','technic:solar_array_lv'},
+        {'technic:solar_array_lv', 'technic:mv_transformer','technic:solar_array_lv'},
+        {'default:steel_ingot',    'technic:mv_cable',      'default:steel_ingot'},
+      }
+})
+
+minetest.register_abm(
+   {nodenames = {"technic:solar_array_mv"},
+    interval   = 1,
+    chance     = 1,
+    action = function(pos, node, active_object_count, active_object_count_wider)
+               -- The action here is to make the solar array produce power
+               -- Power is dependent on the light level and the height above ground
+               -- 130m and above is optimal as it would be above cloud level.
+               -- Height gives 1/4 of the effect, light 3/4. Max. effect is 720EU for the array.
+               -- There are many ways to cheat by using other light sources like lamps.
+               -- As there is no way to determine if light is sunlight that is just a shame.
+               -- To take care of some of it solar panels do not work outside daylight hours or if
+               -- built below -10m
+               local pos1={}
+               pos1.y=pos.y+1
+               pos1.x=pos.x
+               pos1.z=pos.z
+
+               local light = minetest.env:get_node_light(pos1, nil)
+               local time_of_day = minetest.env:get_timeofday()
+               local meta = minetest.env:get_meta(pos)
+               if light == nil then light = 0 end
+               -- turn on array only during day time and if sufficient light
+               -- I know this is counter intuitive when cheating by using other light sources.
+               if light >= 12 and time_of_day>=0.24 and time_of_day<=0.76 and pos.y > -10 then
+                  local charge_to_give = math.floor(light*(light*2.4+pos1.y/130*12))
+                  if charge_to_give<0   then charge_to_give=0 end
+                  if charge_to_give>160 then charge_to_give=160 end
+                  meta:set_string("infotext", "Solar Array is active ("..charge_to_give.."EU)")
+                  --                   meta:set_float("active",1)
+                  meta:set_int("MV_EU_supply", charge_to_give)
+               else
+                  meta:set_string("infotext", "Solar Array is inactive");
+                  meta:set_int("MV_EU_supply", 0)
+               end
+            end,
+ }) 
+
+technic.register_MV_machine ("technic:solar_array_mv","PR")
+
diff --git a/technic/machines/mv/wires.lua b/technic/machines/mv/wires.lua
new file mode 100644 (file)
index 0000000..7924956
--- /dev/null
@@ -0,0 +1,400 @@
+--MV cable node boxes
+
+
+minetest.register_alias("mv_cable", "technic:mv_cable")
+
+minetest.register_craft({
+       output = 'technic:mv_cable 3',
+       recipe ={
+               {'technic:rubber','technic:rubber','technic:rubber'},
+               {'technic:lv_cable','technic:lv_cable','technic:lv_cable'},
+               {'technic:rubber','technic:rubber','technic:rubber'},
+               }
+}) 
+
+
+minetest.register_craftitem("technic:mv_cable", {
+       description = "Medium Voltage Copper Cable",
+       stack_max = 99,
+}) 
+
+minetest.register_node("technic:mv_cable", {
+       description = "Medium Voltage Copper Cable",
+       tiles = {"technic_mv_cable.png"},
+       inventory_image = "technic_mv_cable_wield.png",
+       wield_image = "technic_mv_cable_wield.png",
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+       sounds = default.node_sound_wood_defaults(),
+       drop = "technic:mv_cable",
+       mv_cablelike=1,
+       rules_x1=0,
+       rules_x2=0,
+       rules_y1=0,
+       rules_y2=0,
+       rules_z1=0,
+       rules_z2=0,
+       paramtype = "light",
+        drawtype = "nodebox", 
+       selection_box = {
+               type = "fixed",
+                fixed = {
+               { -0.1 , -0.1 , -0.1 , 0.1 ,  0.1 , 0.1  },
+               }},
+       node_box = {
+               type = "fixed",
+                fixed = {
+               { -0.1 , -0.1 , -0.1 , 0.1 ,  0.1 , 0.1  },
+               }},
+       on_construct = function(pos)
+       meta=minetest.env:get_meta(pos)
+       meta:set_float("mv_cablelike",1)
+       meta:set_float("x1",0)
+       meta:set_float("x2",0)
+       meta:set_float("y1",0)
+       meta:set_float("y2",0)
+       meta:set_float("z1",0)
+       meta:set_float("z2",0)
+       MV_check_connections (pos)
+       end,
+
+       after_dig_node = function (pos, oldnode, oldmetadata, digger)
+       MV_check_connections_on_destroy (pos)
+       end,
+
+})
+
+
+str_y1=                { -0.1 , -0.1 , -0.1 , 0.1 , 0.5, 0.1  }    --0 y+
+str_x1=                { -0.1 , -0.1 , -0.1 , 0.5, 0.1 , 0.1  }    --0 x+
+str_z1=                { -0.1 , -0.1 ,  0.1 ,  0.1 , 0.1 , 0.5 }   --0 z+
+str_z2=                { -0.1 , -0.1, -0.5 ,  0.1 ,  0.1 , 0.1  }  --0 z-
+str_y2=                { -0.1 , -0.5, -0.1 ,  0.1 ,  0.1 , 0.1  }  --0 y-
+str_x2=                { -0.5 , -0.1, -0.1 ,  0.1 ,  0.1 , 0.1  }  --0 x-
+
+
+
+local x1,x2,y1,y2,z1,z2
+local count=0
+
+for x1 = 0, 1, 1 do    --x-
+for x2 = 0, 1, 1 do    --x+
+for y1 = 0, 1, 1 do    --y-
+for y2 = 0, 1, 1 do    --y-    
+for z1 = 0, 1, 1 do    --z-
+for z2 = 0, 1, 1 do    --z+
+     
+temp_x1={} temp_x2={} temp_y1={} temp_y2={} temp_z1={} temp_z2={}
+
+if x1==1 then  temp_x1=str_x1  end 
+if x2==1 then  temp_x2=str_x2  end 
+if y1==1 then  temp_y1=str_y1  end 
+if y2==1 then  temp_y2=str_y2  end 
+if z1==1 then  temp_z1=str_z1  end 
+if z2==1 then  temp_z2=str_z2  end 
+
+
+minetest.register_node("technic:mv_cable"..count, {
+       description = "Medium Voltage Copper Cable",
+       tiles = {"technic_mv_cable.png"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
+       sounds = default.node_sound_wood_defaults(),
+       drop = "technic:mv_cable",
+       rules_x1=0,
+       rules_x2=0,
+       rules_y1=0,
+       rules_y2=0,
+       rules_z1=0,
+       rules_z2=0,
+       cablelike=1,
+       paramtype = "light",
+        drawtype = "nodebox", 
+       selection_box = {
+               type = "fixed",
+           fixed = {
+               temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
+               }},
+
+       node_box = {
+               type = "fixed",
+           fixed = {
+               temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
+               }},
+
+       after_dig_node = function (pos, oldnode, oldmetadata, digger)
+       MV_check_connections_on_destroy (pos)
+       end,
+       
+})
+
+count=count+1 end end end end end end
+
+MV_check_connections = function(pos)
+               local pos1={}
+               pos1.x=pos.x
+               pos1.y=pos.y
+               pos1.z=pos.z
+               
+               pos1.x=pos1.x+1
+               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
+               x2=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:mv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("x2",x2)
+               meta=minetest.env:get_meta(pos)
+               x1=1
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("x1",x1)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:mv_cable"..rule)
+               end
+
+               pos1.x=pos1.x-2
+               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
+               x1=1
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:mv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("x1",x1)
+               meta=minetest.env:get_meta(pos)
+               x2=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("x2",x2)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:mv_cable"..rule)
+               end
+
+               pos1.x=pos1.x+1
+               
+               pos1.y=pos1.y+1
+               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
+               y2=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:mv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("y2",y2)
+               meta=minetest.env:get_meta(pos)
+               y1=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("y1",y1)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:mv_cable"..rule)
+               end
+               
+               if minetest.env:get_meta(pos1):get_float("technic_mv_power_machine")==1 then
+               y1=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:mv_cable"..rule)
+               meta=minetest.env:get_meta(pos)
+               meta:set_float("y1",y1)
+               end
+
+
+               pos1.y=pos1.y-2
+               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
+               y1=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:mv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("y1",y1)
+               meta=minetest.env:get_meta(pos)
+               y2=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("y2",y2)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:mv_cable"..rule)
+               end
+               pos1.y=pos1.y+1
+
+               pos1.z=pos1.z+1
+               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
+               z2=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:mv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("z2",z2)
+               meta=minetest.env:get_meta(pos)
+               z1=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z2=minetest.env:get_meta(pos):get_float("z2")
+               meta:set_float("z1",z1)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:mv_cable"..rule)
+               end
+               pos1.z=pos1.z-2
+               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
+               z1=1
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos1,"technic:mv_cable"..rule)
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("z1",z1)
+               meta=minetest.env:get_meta(pos)
+               z2=1
+               x1=minetest.env:get_meta(pos):get_float("x1")
+               x2=minetest.env:get_meta(pos):get_float("x2")
+               y1=minetest.env:get_meta(pos):get_float("y1")
+               y2=minetest.env:get_meta(pos):get_float("y2")
+               z1=minetest.env:get_meta(pos):get_float("z1")
+               meta:set_float("z2",z2)
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               hacky_swap_node(pos,"technic:mv_cable"..rule)
+               end
+               pos1.z=pos1.z+1
+end    
+
+
+MV_check_connections_on_destroy = function(pos)
+               local pos1={}
+               pos1.x=pos.x
+               pos1.y=pos.y
+               pos1.z=pos.z
+               
+               pos1.x=pos1.x+1
+               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
+               x2=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("x2",x2)
+               end
+               
+               pos1.x=pos1.x-2
+               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
+               x1=0
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("x1",x1)
+               end
+               pos1.x=pos1.x+1
+
+               pos1.y=pos1.y+1
+               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
+               y2=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("y2",y2)
+               end
+               
+               pos1.y=pos1.y-2
+               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
+               y1=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("y1",y1)
+               end
+               pos1.y=pos1.y+1
+
+               pos1.z=pos1.z+1
+               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
+               z2=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z1=minetest.env:get_meta(pos1):get_float("z1")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("z2",z2)
+               end
+               
+               pos1.z=pos1.z-2
+               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
+               z1=0
+               x1=minetest.env:get_meta(pos1):get_float("x1")
+               x2=minetest.env:get_meta(pos1):get_float("x2")
+               y1=minetest.env:get_meta(pos1):get_float("y1")
+               y2=minetest.env:get_meta(pos1):get_float("y2")
+               z2=minetest.env:get_meta(pos1):get_float("z2")
+               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
+               if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
+               if rule>0  then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
+               meta=minetest.env:get_meta(pos1)
+               meta:set_float("z1",z1)
+               end
+               pos1.y=pos1.y+1
+               
+end    
+
diff --git a/technic/machines/other/constructor.lua b/technic/machines/other/constructor.lua
new file mode 100644 (file)
index 0000000..2b031e5
--- /dev/null
@@ -0,0 +1,344 @@
+
+minetest.register_craft({
+       type = "shapeless",
+       output = 'technic:constructor_mk1_off 1',
+       recipe = {'technic:nodebreaker_off', 'technic:deployer_off'},
+
+})
+minetest.register_craft({
+       type = "shapeless",
+       output = 'technic:constructor_mk2_off 1',
+       recipe = {'technic:constructor_mk1_off', 'technic:constructor_mk1_off'},
+
+})
+
+minetest.register_craft({
+       type = "shapeless",
+       output = 'technic:constructor_mk3_off 1',
+       recipe = {'technic:constructor_mk2_off', 'technic:constructor_mk2_off'},
+
+})
+
+mk1_on = function(pos, node)
+       local meta = minetest.env:get_meta(pos)
+       local inv = meta:get_inventory()
+       local pos1={}
+       pos1.x=pos.x
+       pos1.y=pos.y
+       pos1.z=pos.z
+       if node.param2==3 then pos1.x=pos1.x+1 end
+       if node.param2==2 then pos1.z=pos1.z+1 end
+       if node.param2==1 then pos1.x=pos1.x-1 end
+       if node.param2==0 then pos1.z=pos1.z-1 end
+
+       if node.name == "technic:constructor_mk1_off" then
+               hacky_swap_node(pos,"technic:constructor_mk1_on")
+               nodeupdate(pos)
+               local node1=minetest.env:get_node(pos1)
+               deploy_node (inv,"slot1",pos1,node1,node)
+       end
+end
+
+mk1_off = function(pos, node)
+       if node.name == "technic:constructor_mk1_on" then
+               hacky_swap_node(pos,"technic:constructor_mk1_off")
+               nodeupdate(pos)
+       end
+end
+
+
+minetest.register_node("technic:constructor_mk1_off", {
+       description = "Constructor MK1",
+       tile_images = {"technic_constructor_mk1_top_off.png","technic_constructor_mk1_bottom_off.png","technic_constructor_mk1_side2_off.png","technic_constructor_mk1_side1_off.png",
+                       "technic_constructor_back.png","technic_constructor_front_off.png"},
+       is_ground_content = true,
+       paramtype2 = "facedir",
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2},
+       mesecons= {effector={action_on=mk1_on}},
+       sounds = default.node_sound_stone_defaults(),
+       on_construct = function(pos)
+       local meta = minetest.env:get_meta(pos)
+       meta:set_string("formspec",
+                               "invsize[8,9;]"..
+                               "label[0,0;Constructor MK1]"..
+                               "label[5,0;Slot 1]"..
+                               "list[current_name;slot1;6,0;1,1;]"..
+                               "list[current_player;main;0,5;8,4;]")
+               meta:set_string("infotext", "Constructor MK1")
+               local inv = meta:get_inventory()
+               inv:set_size("slot1", 1)
+       end,
+
+       can_dig = function(pos,player)
+               local meta = minetest.env:get_meta(pos)
+               local inv = meta:get_inventory()
+               return inv:is_empty("slot1")
+       end,    
+})
+
+minetest.register_node("technic:constructor_mk1_on", {
+       description = "Constructor MK1",
+       tile_images = {"technic_constructor_mk1_top_on.png","technic_constructor_mk1_bottom_on.png","technic_constructor_mk1_side2_on.png","technic_constructor_mk1_side1_on.png",
+                       "technic_constructor_back.png","technic_constructor_front_on.png"},
+       is_ground_content = true,
+       paramtype2 = "facedir",
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon = 2,not_in_creative_inventory=1},
+       mesecons= {effector={action_off=mk1_off}},
+       sounds = default.node_sound_stone_defaults(),
+})
+
+
+--Constructor MK2
+
+mk2_on = function(pos, node)
+       local meta = minetest.env:get_meta(pos)
+       local inv = meta:get_inventory()
+       local pos1={}
+       local pos2={}
+       pos1.x=pos.x
+       pos1.y=pos.y
+       pos1.z=pos.z
+       pos2.x=pos.x
+       pos2.y=pos.y
+       pos2.z=pos.z
+       if node.param2==3 then pos1.x=pos1.x+1 pos2.x=pos2.x+2 end
+       if node.param2==2 then pos1.z=pos1.z+1 pos2.z=pos2.z+2 end
+       if node.param2==1 then pos1.x=pos1.x-1 pos2.x=pos2.x-2 end
+       if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 end
+
+       if node.name == "technic:constructor_mk2_off" then
+               hacky_swap_node(pos,"technic:constructor_mk2_on")
+               nodeupdate(pos)
+               local node1=minetest.env:get_node(pos1)
+               deploy_node (inv,"slot1",pos1,node1,node)
+               local node1=minetest.env:get_node(pos2) 
+               deploy_node (inv,"slot2",pos2,node1,node)
+       end
+end
+
+mk2_off = function(pos, node)
+       if node.name == "technic:constructor_mk2_on" then
+               hacky_swap_node(pos,"technic:constructor_mk2_off")
+               nodeupdate(pos)
+       end
+end
+
+minetest.register_node("technic:constructor_mk2_off", {
+       description = "Constructor MK2",
+       tile_images = {"technic_constructor_mk2_top_off.png","technic_constructor_mk2_bottom_off.png","technic_constructor_mk2_side2_off.png","technic_constructor_mk2_side1_off.png",
+                       "technic_constructor_back.png","technic_constructor_front_off.png"},
+       is_ground_content = true,
+       paramtype2 = "facedir",
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2},
+       mesecons= {effector={action_on=mk2_on}},
+       sounds = default.node_sound_stone_defaults(),
+       on_construct = function(pos)
+       local meta = minetest.env:get_meta(pos)
+       meta:set_string("formspec",
+                               "invsize[8,9;]"..
+                               "label[0,0;Constructor MK2]"..
+                               "label[5,0;Slot 1]"..
+                               "list[current_name;slot1;6,0;1,1;]"..
+                               "label[5,1;Slot 2]"..
+                               "list[current_name;slot2;6,1;1,1;]"..
+                               "list[current_player;main;0,5;8,4;]")
+               meta:set_string("infotext", "Constructor MK2")
+               local inv = meta:get_inventory()
+               inv:set_size("slot1", 1)
+               inv:set_size("slot2", 1)
+       end,
+
+       can_dig = function(pos,player)
+               local meta = minetest.env:get_meta(pos)
+               local inv = meta:get_inventory()
+               if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false then return false end
+               return true
+       end,    
+})
+
+minetest.register_node("technic:constructor_mk2_on", {
+       description = "Constructor MK2",
+       tile_images = {"technic_constructor_mk2_top_on.png","technic_constructor_mk2_bottom_on.png","technic_constructor_mk2_side2_on.png","technic_constructor_mk2_side1_on.png",
+                       "technic_constructor_back.png","technic_constructor_front_on.png"},
+       is_ground_content = true,
+       paramtype2 = "facedir",
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2, not_in_creative_inventory=1},
+       mesecons= {effector={action_off=mk2_off}},
+       sounds = default.node_sound_stone_defaults(),
+})
+
+
+-- Constructor MK3
+mk3_on = function(pos, node)
+       local meta = minetest.env:get_meta(pos)
+       local inv = meta:get_inventory()
+       
+       local pos1={}
+       local pos2={}
+       local pos3={}
+       local pos4={}
+       
+       pos1.x=pos.x
+       pos1.y=pos.y
+       pos1.z=pos.z
+       
+       pos2.x=pos.x
+       pos2.y=pos.y
+       pos2.z=pos.z
+       
+       pos3.x=pos.x
+       pos3.y=pos.y
+       pos3.z=pos.z
+
+       pos4.x=pos.x
+       pos4.y=pos.y
+       pos4.z=pos.z
+
+       if node.param2==3 then pos1.x=pos1.x+1 pos2.x=pos2.x+2 pos3.x=pos3.x+3 pos4.x=pos4.x+4 end
+       if node.param2==2 then pos1.z=pos1.z+1 pos2.z=pos2.z+2 pos3.z=pos3.z+3 pos4.z=pos4.z+4 end
+       if node.param2==1 then pos1.x=pos1.x-1 pos2.x=pos2.x-2 pos3.x=pos3.x-3 pos4.x=pos4.x-4 end
+       if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 pos3.z=pos3.z-3 pos4.z=pos4.z-4 end
+
+       if node.name == "technic:constructor_mk3_off" then
+               hacky_swap_node(pos,"technic:constructor_mk3_on")
+               nodeupdate(pos)
+               local node1=minetest.env:get_node(pos1)
+               deploy_node (inv,"slot1",pos1,node1,node)
+               local node1=minetest.env:get_node(pos2) 
+               deploy_node (inv,"slot2",pos2,node1,node)
+               local node1=minetest.env:get_node(pos3) 
+               deploy_node (inv,"slot3",pos3,node1,node)
+               local node1=minetest.env:get_node(pos4) 
+               deploy_node (inv,"slot4",pos4,node1,node)
+       end
+end
+
+mk3_off = function(pos, node)
+       if node.name == "technic:constructor_mk3_on" then
+               hacky_swap_node(pos,"technic:constructor_mk3_off")
+               nodeupdate(pos)
+       end
+end
+
+minetest.register_node("technic:constructor_mk3_off", {
+       description = "Constructor MK3",
+       tile_images = {"technic_constructor_mk3_top_off.png","technic_constructor_mk3_bottom_off.png","technic_constructor_mk3_side2_off.png","technic_constructor_mk3_side1_off.png",
+                       "technic_constructor_back.png","technic_constructor_front_off.png"},
+       is_ground_content = true,
+       paramtype2 = "facedir",
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2},
+       mesecons= {effector={action_on=mk3_on}},
+       sounds = default.node_sound_stone_defaults(),
+       on_construct = function(pos)
+       local meta = minetest.env:get_meta(pos)
+       meta:set_string("formspec",
+                               "invsize[8,9;]"..
+                               "label[0,0;Constructor MK2]"..
+                               "label[5,0;Slot 1]"..
+                               "list[current_name;slot1;6,0;1,1;]"..
+                               "label[5,1;Slot 2]"..
+                               "list[current_name;slot2;6,1;1,1;]"..
+                               "label[5,2;Slot 3]"..
+                               "list[current_name;slot3;6,2;1,1;]"..
+                               "label[5,3;Slot 4]"..
+                               "list[current_name;slot4;6,3;1,1;]"..
+                               "list[current_player;main;0,5;8,4;]")
+               meta:set_string("infotext", "Constructor MK3")
+               local inv = meta:get_inventory()
+               inv:set_size("slot1", 1)
+               inv:set_size("slot2", 1)
+               inv:set_size("slot3", 1)
+               inv:set_size("slot4", 1)
+
+       end,
+
+       can_dig = function(pos,player)
+               local meta = minetest.env:get_meta(pos)
+               local inv = meta:get_inventory()
+               if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false or inv:is_empty("slot3")==false or inv:is_empty("slot4")==false then return false end
+               return true
+       end,    
+})
+
+minetest.register_node("technic:constructor_mk3_on", {
+       description = "Constructor MK3",
+       tile_images = {"technic_constructor_mk3_top_on.png","technic_constructor_mk3_bottom_on.png","technic_constructor_mk3_side2_on.png","technic_constructor_mk3_side1_on.png",
+                       "technic_constructor_back.png","technic_constructor_front_on.png"},
+       is_ground_content = true,
+       paramtype2 = "facedir",
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,not_in_creative_inventory=1},
+       mesecons= {effector={action_off=mk3_off}},
+       sounds = default.node_sound_stone_defaults(),
+})
+
+
+deploy_node =function (inv, slot_name, pos1, node1, node)
+       if node1.name == "air" then 
+               if not inv:is_empty(slot_name) then
+                       stack1=inv:get_list(slot_name)
+                       local def = stack1[1]:get_definition()
+                       if def.type == "node" then
+                               node_to_be_placed={name=stack1[1]:get_name(), param1=0, param2=node.param2}
+                               minetest.env:set_node(pos1,node_to_be_placed)
+                               stack1[1]:take_item()
+                               inv:set_stack(slot_name, 1, stack1[1])
+                       elseif def.type == "craft" then
+                               if def.on_place then
+                                       -- print("deploy_node: item has on_place. trying...")
+                                       local ok, stk = pcall(def.on_place, stack1[1], nil, {
+                                               -- Fake pointed_thing
+                                               type = "node",
+                                               above = pos1,
+                                               under = { x=pos1.x, y=pos1.y-1, z=pos1.z },
+                                       })
+                                       if ok then
+                                               -- print("deploy_node: on_place succeeded!")
+                                               inv:set_stack(slot_name, 1, stk or stack1[1])
+                                               return
+                                       -- else
+                                               -- print("deploy_node: WARNING: error while running on_place: "..tostring(stk))
+                                       end
+                               end
+                               minetest.item_place_object(stack1[1], nil, {
+                                       -- Fake pointed_thing
+                                       type = "node",
+                                       above = pos1,
+                                       under = pos1,
+                               })
+                               inv:set_stack(slot_name, 1, nil)
+                       end
+               end
+               return 
+       end
+       if node1.name == "ignore" or
+          node1.name == "default:lava_source" or
+          node1.name == "default:lava_flowing" or
+          node1.name == "default:water_source" or
+          node1.name == "default:water_flowing" 
+          then return end
+       if inv:room_for_item(slot_name,node1) then
+               local def = minetest.registered_nodes[node1.name]
+               if not def then return end
+               local drop = def.drop or node1.name
+               if type(drop) == "table" then
+                       local pr = PseudoRandom(math.random())
+                       local c = 0
+                       local loop = 0 -- Prevent infinite loop
+                       while (c < (drop.max_items or 1)) and (loop < 1000) do
+                               local i = math.floor(pr:next(1, #drop.items))
+                               if pr:next(1, drop.items[i].rarity or 1) == 1 then
+                                       for _,item in ipairs(drop.items[i].items) do
+                                               inv:add_item(slot_name,item)
+                                       end
+                                       c = c + 1
+                               end
+                               loop = loop + 1
+                       end
+                       minetest.env:remove_node(pos1)
+               elseif type(drop) == "string" then
+                       inv:add_item(slot_name,drop)
+                       minetest.env:remove_node(pos1)
+               end
+       end
+
+end
diff --git a/technic/machines/other/deployer.lua b/technic/machines/other/deployer.lua
new file mode 100644 (file)
index 0000000..c5dba2a
--- /dev/null
@@ -0,0 +1,113 @@
+minetest.register_craft({
+       output = 'technic:deployer_off 1',
+       recipe = {
+               {'default:wood', 'default:chest','default:wood'},
+               {'default:stone', 'mesecons:piston','default:stone'},
+               {'default:stone', 'mesecons:mesecon','default:stone'},
+
+       }
+})
+
+deployer_signal_on = function(pos, node)
+       local pos1={}
+       pos1.x=pos.x
+       pos1.y=pos.y
+       pos1.z=pos.z
+       if node.param2==3 then pos1.x=pos1.x+1 end
+       if node.param2==2 then pos1.z=pos1.z+1 end
+       if node.param2==1 then pos1.x=pos1.x-1 end
+       if node.param2==0 then pos1.z=pos1.z-1 end
+
+       if node.name == "technic:deployer_off" then
+               local node1=minetest.env:get_node(pos1)
+               if node1.name == "air" then 
+                       hacky_swap_node(pos,"technic:deployer_on")
+                       nodeupdate(pos)
+                       local meta = minetest.env:get_meta(pos);
+                       local inv = meta:get_inventory()
+                       local i=0
+                       for _,stack in ipairs(inv:get_list("main")) do
+                       i=i+1
+                       if stack:get_name() ~=nil and minetest.registered_nodes[stack:get_name()]~=nil then 
+                               node1={name=stack:get_name(), param1=0, param2=node.param2}
+                               minetest.env:place_node(pos1,node1)
+                               stack:take_item(1);
+                               inv:set_stack("main", i, stack)
+                               return
+                               end
+                       end
+       end
+       end
+end
+
+deployer_signal_off = function(pos, node)
+       if node.name == "technic:deployer_on" then
+               hacky_swap_node(pos,"technic:deployer_off")
+               nodeupdate(pos)
+       end
+end
+
+minetest.register_node("technic:deployer_off", {
+       description = "Deployer",
+       tile_images = {"technic_deployer_top.png","technic_deployer_bottom.png","technic_deployer_side2.png","technic_deployer_side1.png",
+                       "technic_deployer_back.png","technic_deployer_front_off.png"},
+       is_ground_content = true,
+       paramtype2 = "facedir",
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, tubedevice_receiver=1},
+       mesecons = {effector={action_on=deployer_signal_on}},
+       tube={insert_object=function(pos,node,stack,direction)
+                       local meta=minetest.env:get_meta(pos)
+                       local inv=meta:get_inventory()
+                       return inv:add_item("main",stack)
+               end,
+               can_insert=function(pos,node,stack,direction)
+                       local meta=minetest.env:get_meta(pos)
+                       local inv=meta:get_inventory()
+                       return inv:room_for_item("main",stack)
+               end,
+               input_inventory="main"},
+       sounds = default.node_sound_stone_defaults(),
+       on_construct = function(pos)
+       local meta = minetest.env:get_meta(pos)
+       meta:set_string("formspec",
+                               "invsize[8,9;]"..
+                               "label[0,0;Deployer]"..
+                               "list[current_name;main;4,1;3,3;]"..
+                               "list[current_player;main;0,5;8,4;]")
+               meta:set_string("infotext", "Deployer")
+               local inv = meta:get_inventory()
+               inv:set_size("main", 3*3)
+       end,
+
+       can_dig = function(pos,player)
+               local meta = minetest.env:get_meta(pos);
+               local inv = meta:get_inventory()
+               if not inv:is_empty("main") then
+                       return false
+               end
+               return true
+               end,
+       
+})
+
+minetest.register_node("technic:deployer_on", {
+       description = "Deployer",
+       tile_images = {"technic_deployer_top.png","technic_deployer_bottom.png","technic_deployer_side2.png","technic_deployer_side1.png",
+                       "technic_deployer_back.png","technic_deployer_front_on.png"},
+       is_ground_content = true,
+       paramtype2 = "facedir",
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, tubedevice_receiver=1,not_in_creative_inventory=1},
+       mesecons = {effector={action_off=deployer_signal_off}},
+               tube={insert_object=function(pos,node,stack,direction)
+                       local meta=minetest.env:get_meta(pos)
+                       local inv=meta:get_inventory()
+                       return inv:add_item("main",stack)
+               end,
+               can_insert=function(pos,node,stack,direction)
+                       local meta=minetest.env:get_meta(pos)
+                       local inv=meta:get_inventory()
+                       return inv:room_for_item("main",stack)
+               end,
+               input_inventory="main"},
+       sounds = default.node_sound_stone_defaults(),
+})
diff --git a/technic/machines/other/frames.lua b/technic/machines/other/frames.lua
new file mode 100644 (file)
index 0000000..7d141dc
--- /dev/null
@@ -0,0 +1,439 @@
+frames={}
+
+function get_face(pos,ppos,pvect)
+       ppos={x=ppos.x-pos.x,y=ppos.y-pos.y+1.5,z=ppos.z-pos.z}
+       if pvect.x>0 then
+               local t=(-0.5-ppos.x)/pvect.x
+               local y_int=ppos.y+t*pvect.y
+               local z_int=ppos.z+t*pvect.z
+               if y_int>-0.4 and y_int<0.4 and z_int>-0.4 and z_int<0.4 then return 1 end 
+       elseif pvect.x<0 then
+               local t=(0.5-ppos.x)/pvect.x
+               local y_int=ppos.y+t*pvect.y
+               local z_int=ppos.z+t*pvect.z
+               if y_int>-0.4 and y_int<0.4 and z_int>-0.4 and z_int<0.4 then return 2 end 
+       end
+       if pvect.y>0 then
+               local t=(-0.5-ppos.y)/pvect.y
+               local x_int=ppos.x+t*pvect.x
+               local z_int=ppos.z+t*pvect.z
+               if x_int>-0.4 and x_int<0.4 and z_int>-0.4 and z_int<0.4 then return 3 end 
+       elseif pvect.y<0 then
+               local t=(0.5-ppos.y)/pvect.y
+               local x_int=ppos.x+t*pvect.x
+               local z_int=ppos.z+t*pvect.z
+               if x_int>-0.4 and x_int<0.4 and z_int>-0.4 and z_int<0.4 then return 4 end 
+       end
+       if pvect.z>0 then
+               local t=(-0.5-ppos.z)/pvect.z
+               local x_int=ppos.x+t*pvect.x
+               local y_int=ppos.y+t*pvect.y
+               if x_int>-0.4 and x_int<0.4 and y_int>-0.4 and y_int<0.4 then return 5 end 
+       elseif pvect.z<0 then
+               local t=(0.5-ppos.z)/pvect.z
+               local x_int=ppos.x+t*pvect.x
+               local y_int=ppos.y+t*pvect.y
+               if x_int>-0.4 and x_int<0.4 and y_int>-0.4 and y_int<0.4 then return 6 end 
+       end
+end
+
+
+for xm=0,1 do
+for xp=0,1 do
+for ym=0,1 do
+for yp=0,1 do
+for zm=0,1 do
+for zp=0,1 do
+
+local a=8/16
+local b=7/16
+local nodeboxes= {
+       { -a, -a, -a, -b,  a, -b },
+       { -a, -a,  b, -b,  a,  a },
+       {  b, -a,  b,  a,  a,  a },
+       {  b, -a, -a,  a,  a, -b },
+
+       { -b,  b, -a,  b,  a, -b },
+       { -b, -a, -a,  b, -b, -b },
+       
+       { -b,  b,  b,  b,  a,  a },
+       { -b, -a,  b,  b, -b,  a },
+
+       {  b,  b, -b,  a,  a,  b },
+       {  b, -a, -b,  a, -b,  b },
+
+       { -a,  b, -b, -b,  a,  b },
+       { -a, -a, -b, -b, -b,  b },
+       }
+       
+       if yp==0 then
+               table.insert(nodeboxes, {-b,b,-b, b,a,b})
+       end
+       if ym==0 then
+               table.insert(nodeboxes, {-b,-a,-b, b,-b,b})
+       end
+       if xp==0 then
+               table.insert(nodeboxes, {b,b,b,a,-b,-b})
+       end
+       if xm==0 then
+               table.insert(nodeboxes, {-a,-b,-b,-b,b,b})
+       end
+       if zp==0 then
+               table.insert(nodeboxes, {-b,-b,b, b,b,a})
+       end
+       if zm==0 then
+               table.insert(nodeboxes, {-b,-b,-a, b,b,-b})
+       end
+       
+       local nameext=tostring(xm)..tostring(xp)..tostring(ym)..tostring(yp)..tostring(zm)..tostring(zp)
+       local groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}
+       if nameext~="111111" then groups.not_in_creative_inventory=1 end
+       
+
+       minetest.register_node("technic:frame_"..nameext,{
+               description = "Frame",
+               tiles = {"technic_frame.png"},
+               groups=groups,
+               drawtype = "nodebox",
+               node_box = {
+                       type = "fixed",
+               fixed=nodeboxes,
+               },
+               selection_box = {
+                       type="fixed",
+                       fixed={-0.5,-0.5,-0.5,0.5,0.5,0.5}
+               },
+               paramtype = "light",
+               frame=1,
+               drop="technic:frame_111111",
+               frame_connect_all=function(pos)
+                       local nodename=minetest.env:get_node(pos).name
+                       l2={}
+                       l1={{x=-1,y=0,z=0},{x=1,y=0,z=0},{x=0,y=-1,z=0},{x=0,y=1,z=0},{x=0,y=0,z=-1},{x=0,y=0,z=1}}
+                       for i,dir in ipairs(l1) do
+                               if string.sub(nodename,-7+i,-7+i)=="1" then
+                                       l2[#(l2)+1]=dir
+                               end
+                       end
+                       return l2
+               end,
+               on_punch=function(pos,node,puncher)
+                       local ppos=puncher:getpos()
+                       local pvect=puncher:get_look_dir()
+                       local pface=get_face(pos,ppos,pvect)
+                       if pface==nil then return end
+                       local nodename=node.name
+                       local newstate=tostring(1-tonumber(string.sub(nodename,-7+pface,-7+pface)))
+                       if pface<=5 then
+                               nodename=string.sub(nodename,1,-7+pface-1)..newstate..string.sub(nodename,-7+pface+1)
+                       else
+                               nodename=string.sub(nodename,1,-2)..newstate
+                       end
+                       node.name=nodename
+                       minetest.env:set_node(pos,node)
+               end
+       })
+
+end
+end
+end
+end
+end
+end
+
+
+function frame_motor1_on(pos,node)
+       local npos={x=pos.x,y=pos.y+1,z=pos.z}
+       local nnode=minetest.env:get_node(npos)
+       if node.param2==0 then
+               dir={x=1,y=0,z=0}
+       elseif node.param2==1 then
+               dir={x=0,y=0,z=-1}
+       elseif node.param2==2 then
+               dir={x=-1,y=0,z=0}
+       else
+               dir={x=0,y=0,z=1}
+       end
+       if minetest.registered_nodes[nnode.name].frame==1 then
+               local connected_nodes=get_connected_nodes(npos)
+               move_nodes_vect(connected_nodes,dir)
+       end
+end
+
+function frame_motor2_on(pos,node)
+       local npos={x=pos.x,y=pos.y-1,z=pos.z}
+       local nnode=minetest.env:get_node(npos)
+       if node.param2==0 then
+               dir={x=1,y=0,z=0}
+       elseif node.param2==1 then
+               dir={x=0,y=0,z=-1}
+       elseif node.param2==2 then
+               dir={x=-1,y=0,z=0}
+       else
+               dir={x=0,y=0,z=1}
+       end
+       if minetest.registered_nodes[nnode.name].frame==1 then
+               local connected_nodes=get_connected_nodes(npos)
+               move_nodes_vect(connected_nodes,dir)
+       end
+end
+
+function frame_motor3_on(pos,node)
+       local npos={x=pos.x,y=pos.y,z=pos.z}
+       if node.param2==0 then
+               dir={x=1,y=0,z=0}
+               npos.z=npos.z-1
+       elseif node.param2==1 then
+               dir={x=0,y=0,z=-1}
+               npos.x=npos.x-1
+       elseif node.param2==2 then
+               dir={x=-1,y=0,z=0}
+               npos.z=npos.z+1
+       else
+               dir={x=0,y=0,z=1}
+               npos.x=npos.x+1
+       end
+       local nnode=minetest.env:get_node(npos)
+       if minetest.registered_nodes[nnode.name].frame==1 then
+               local connected_nodes=get_connected_nodes(npos)
+               move_nodes_vect(connected_nodes,dir)
+       end
+end
+
+function frame_motor4_on(pos,node)
+       local npos={x=pos.x,y=pos.y,z=pos.z}
+       if node.param2==0 then
+               dir={x=-1,y=0,z=0}
+               npos.z=npos.z-1
+       elseif node.param2==1 then
+               dir={x=0,y=0,z=1}
+               npos.x=npos.x-1
+       elseif node.param2==2 then
+               dir={x=1,y=0,z=0}
+               npos.z=npos.z+1
+       else
+               dir={x=0,y=0,z=-1}
+               npos.x=npos.x+1
+       end
+       local nnode=minetest.env:get_node(npos)
+       if minetest.registered_nodes[nnode.name].frame==1 then
+               local connected_nodes=get_connected_nodes(npos)
+               move_nodes_vect(connected_nodes,dir)
+       end
+end
+
+function frame_motor5_on(pos,node)
+       local npos={x=pos.x,y=pos.y,z=pos.z}
+       if node.param2==0 then
+               npos.z=npos.z-1
+       elseif node.param2==1 then
+               npos.x=npos.x-1
+       elseif node.param2==2 then
+               npos.z=npos.z+1
+       else
+               npos.x=npos.x+1
+       end
+       dir={x=0,y=1,z=0}
+       local nnode=minetest.env:get_node(npos)
+       if minetest.registered_nodes[nnode.name].frame==1 then
+               local connected_nodes=get_connected_nodes(npos)
+               move_nodes_vect(connected_nodes,dir)
+       end
+end
+
+function frame_motor6_on(pos,node)
+       local npos={x=pos.x,y=pos.y,z=pos.z}
+       if node.param2==0 then
+               npos.z=npos.z-1
+       elseif node.param2==1 then
+               npos.x=npos.x-1
+       elseif node.param2==2 then
+               npos.z=npos.z+1
+       else
+               npos.x=npos.x+1
+       end
+       dir={x=0,y=-1,z=0}
+       local nnode=minetest.env:get_node(npos)
+       if minetest.registered_nodes[nnode.name].frame==1 then
+               local connected_nodes=get_connected_nodes(npos)
+               move_nodes_vect(connected_nodes,dir)
+       end
+end
+
+
+minetest.register_node("technic:frame_motor1",{
+       description = "Frame motor 1",
+       tiles = {"pipeworks_filter_top.png", "technic_lv_cable.png", "technic_lv_cable.png",
+               "technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
+       paramtype2 = "facedir",
+       mesecons={effector={action_on=frame_motor1_on}},
+       frames_can_connect=function(pos,dir)
+               return dir.y~=-1
+       end
+})
+
+minetest.register_node("technic:frame_motor2",{
+       description = "Frame motor 2",
+       tiles = {"technic_lv_cable.png", "pipeworks_filter_top.png", "technic_lv_cable.png",
+               "technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
+       paramtype2 = "facedir",
+       mesecons={effector={action_on=frame_motor2_on}},
+       frames_can_connect=function(pos,dir)
+               return dir.y~=1
+       end
+})
+
+minetest.register_node("technic:frame_motor3",{
+       description = "Frame motor 3",
+       tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
+               "technic_lv_cable.png", "technic_lv_cable.png", "pipeworks_filter_top.png"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
+       paramtype2 = "facedir",
+       mesecons={effector={action_on=frame_motor3_on}},
+       frames_can_connect=function(pos,dir)
+               local node=minetest.env:get_node(pos)
+               if node.param2==0 then return dir.z~=1
+               elseif node.param2==1 then return dir.x~=1
+               elseif node.param2==2 then return dir.z~=-1
+               else return dir.x~=-1 end
+       end
+})
+
+minetest.register_node("technic:frame_motor4",{
+       description = "Frame motor 4",
+       tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
+               "technic_lv_cable.png", "technic_lv_cable.png", "pipeworks_filter_top.png^[transformR180"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
+       paramtype2 = "facedir",
+       mesecons={effector={action_on=frame_motor4_on}},
+       frames_can_connect=function(pos,dir)
+               local node=minetest.env:get_node(pos)
+               if node.param2==0 then return dir.z~=1
+               elseif node.param2==1 then return dir.x~=1
+               elseif node.param2==2 then return dir.z~=-1
+               else return dir.x~=-1 end
+       end
+})
+
+minetest.register_node("technic:frame_motor5",{
+       description = "Frame motor 5",
+       tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
+               "technic_lv_cable.png", "technic_lv_cable.png", "pipeworks_filter_top.png^[transformR90"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
+       paramtype2 = "facedir",
+       mesecons={effector={action_on=frame_motor5_on}},
+       frames_can_connect=function(pos,dir)
+               local node=minetest.env:get_node(pos)
+               if node.param2==0 then return dir.z~=1
+               elseif node.param2==1 then return dir.x~=1
+               elseif node.param2==2 then return dir.z~=-1
+               else return dir.x~=-1 end
+       end
+})
+
+minetest.register_node("technic:frame_motor6",{
+       description = "Frame motor 6",
+       tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
+               "technic_lv_cable.png", "technic_lv_cable.png", "pipeworks_filter_top.png^[transformR270"},
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
+       paramtype2 = "facedir",
+       mesecons={effector={action_on=frame_motor6_on}},
+       frames_can_connect=function(pos,dir)
+               local node=minetest.env:get_node(pos)
+               if node.param2==0 then return dir.z~=1
+               elseif node.param2==1 then return dir.x~=1
+               elseif node.param2==2 then return dir.z~=-1
+               else return dir.x~=-1 end
+       end
+})
+
+function add_table(table,toadd)
+       local i=1
+       while true do
+               o=table[i]
+               if o==toadd then return end
+               if o==nil then break end
+               i=i+1
+       end
+       table[i]=toadd
+end
+
+function move_nodes_vect(poslist,vect)
+               for _,pos in ipairs(poslist) do
+               local npos=frames.addVect(pos,vect)
+               local name = minetest.env:get_node(npos).name
+               if (name~="air" and minetest.registered_nodes[name].liquidtype=="none") and not(pos_in_list(poslist,npos)) then
+ return end
+       end
+       nodelist={}
+       for _,pos in ipairs(poslist) do
+               local node=minetest.env:get_node(pos)
+               local meta=minetest.env:get_meta(pos):to_table()
+               nodelist[#(nodelist)+1]={pos=pos,node=node,meta=meta}
+       end
+       objects={}
+       for _,pos in ipairs(poslist) do
+               for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
+                       add_table(objects,object)
+               end
+       end
+       for _,obj in ipairs(objects) do
+               obj:setpos(frames.addVect(obj:getpos(),vect))
+               le=obj:get_luaentity()
+               if le and le.name == "pipeworks:tubed_item" then
+                       le.start_pos=frames.addVect(le.start_pos,vect)
+               end
+       end
+       for _,n in ipairs(nodelist) do
+               local npos=frames.addVect(n.pos,vect)
+               minetest.env:set_node(npos,n.node)
+               local meta=minetest.env:get_meta(npos)
+               meta:from_table(n.meta)
+               for __,pos in ipairs(poslist) do
+                       if npos.x==pos.x and npos.y==pos.y and npos.z==pos.z then
+                               table.remove(poslist, __)
+                               break
+                       end
+               end
+       end
+       for __,pos in ipairs(poslist) do
+               minetest.env:remove_node(pos)
+       end
+end
+
+function get_connected_nodes(pos)
+       c={pos}
+       local nodename=minetest.env:get_node(pos).name
+       connected(pos,c,minetest.registered_nodes[nodename].frame_connect_all(pos))
+       return c
+end
+
+function frames.addVect(pos,vect)
+       return {x=pos.x+vect.x,y=pos.y+vect.y,z=pos.z+vect.z}
+end
+
+function pos_in_list(l,pos)
+       for _,p in ipairs(l) do
+               if p.x==pos.x and p.y==pos.y and p.z==pos.z then return true end
+       end
+       return false
+end
+
+function connected(pos,c,adj)
+       for _,vect in ipairs(adj) do
+               local pos1=frames.addVect(pos,vect)
+               local nodename=minetest.env:get_node(pos1).name
+               if not(pos_in_list(c,pos1)) and nodename~="air" and
+               (minetest.registered_nodes[nodename].frames_can_connect==nil or
+               minetest.registered_nodes[nodename].frames_can_connect(pos1,vect)) then
+                       c[#(c)+1]=pos1
+                       if minetest.registered_nodes[nodename].frame==1 then
+                               local adj=minetest.registered_nodes[nodename].frame_connect_all(pos1)
+                               connected(pos1,c,adj)
+                       end
+               end
+       end
+end
+
diff --git a/technic/machines/other/init.lua b/technic/machines/other/init.lua
new file mode 100644 (file)
index 0000000..766e0eb
--- /dev/null
@@ -0,0 +1,8 @@
+local path = technic.modpath.."/machines/other"
+
+-- mesecons and tubes related
+dofile(path.."/injector.lua")
+dofile(path.."/node_breaker.lua")
+dofile(path.."/deployer.lua")
+dofile(path.."/constructor.lua")
+dofile(path.."/frames.lua")
diff --git a/technic/machines/other/injector.lua b/technic/machines/other/injector.lua
new file mode 100644 (file)
index 0000000..c493744
--- /dev/null
@@ -0,0 +1,117 @@
+minetest.register_craftitem("technic:injector", {
+       description = "Injector",
+       stack_max = 99,
+})
+
+minetest.register_craft({
+       output = 'technic:injector 1',
+       recipe = {
+               {'', 'technic:control_logic_unit',''},
+               {'', 'default:chest',''},
+               {'', 'pipeworks:tube_000000',''},
+       }
+})
+
+minetest.register_node("technic:injector", {
+       description = "Injector",
+       tiles = {"technic_injector_top.png", "technic_injector_bottom.png", "technic_injector_side.png",
+               "technic_injector_side.png", "technic_injector_side.png", "technic_injector_side.png"},
+       groups = chest_groups1,
+       tube = tubes_properties,
+       sounds = default.node_sound_wood_defaults(),
+       on_construct = function(pos)
+               local meta = minetest.env:get_meta(pos)
+               meta:set_string("formspec",
+                               "invsize[8,9;]"..
+                               "label[0,0;Injector]"..
+                               "button[0,1;.8,.8;mode;]"..
+                               "label[.8,1;Mode: single items]"..
+                               "list[current_name;main;0,2;8,2;]"..
+                               "list[current_player;main;0,5;8,4;]")
+               meta:set_string("infotext", "Injector")
+               local inv = meta:get_inventory()
+               inv:set_size("main", 8*4)
+               meta:set_string("mode","single items")
+       end,
+       can_dig = function(pos,player)
+               local meta = minetest.env:get_meta(pos);
+               local inv = meta:get_inventory()
+               return inv:is_empty("main")
+       end,
+       on_receive_fields = function(pos, formanme, fields, sender)
+       local meta = minetest.env:get_meta(pos)
+       local mode=meta:get_string("mode")
+       if fields.mode then 
+               if mode=="single items" then mode="whole stacks" 
+                else mode="single items"
+               end
+       local mode=meta:set_string("mode",mode)
+       end
+       meta:set_string("formspec",
+                               "invsize[8,9;]"..
+                               "label[0,0;Injector]"..
+                               "button[0,1;.8,.8;mode;]"..
+                               "label[.8,1;Mode: "..mode.."]"..
+                               "list[current_name;main;0,2;8,2;]"..
+                               "list[current_player;main;0,5;8,4;]")
+       end,
+})
+
+minetest.register_abm({
+       nodenames = {"technic:injector"},
+       interval = 1,
+       chance = 1,
+
+       action = function(pos, node, active_object_count, active_object_count_wider)
+       local pos1={}
+       pos1.x = pos.x
+       pos1.y = pos.y-1
+       pos1.z = pos.z
+       local meta=minetest.env:get_meta(pos1) 
+               if meta:get_int("tubelike")==1 then inject_items (pos) end
+       end,
+})
+
+function inject_items (pos)
+               local meta=minetest.env:get_meta(pos) 
+               local inv = meta:get_inventory()
+               local mode=meta:get_string("mode")
+               if mode=="single items" then
+                       local i=0
+                       for _,stack in ipairs(inv:get_list("main")) do
+                       i=i+1
+                               if stack then
+                               local item0=stack:to_table()
+                               if item0 then 
+                                       item0["count"]="1"
+                                       local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
+                                       item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
+                                       item1:setvelocity({x=0, y=-1, z=0})
+                                       item1:setacceleration({x=0, y=0, z=0})
+                                       stack:take_item(1);
+                                       inv:set_stack("main", i, stack)
+                                       return
+                                       end
+                               end
+                       end
+               end
+               if mode=="whole stacks" then
+                       local i=0
+                       for _,stack in ipairs(inv:get_list("main")) do
+                       i=i+1
+                               if stack then
+                               local item0=stack:to_table()
+                               if item0 then 
+                                       local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
+                                       item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
+                                       item1:setvelocity({x=0, y=-1, z=0})
+                                       item1:setacceleration({x=0, y=0, z=0})
+                                       stack:clear()
+                                       inv:set_stack("main", i, stack)
+                                       return
+                                       end
+                               end
+                       end
+               end
+               
+end
diff --git a/technic/machines/other/node_breaker.lua b/technic/machines/other/node_breaker.lua
new file mode 100644 (file)
index 0000000..06de700
--- /dev/null
@@ -0,0 +1,89 @@
+minetest.register_craft({
+       output = 'technic:nodebreaker_off 1',
+       recipe = {
+               {'default:wood', 'default:pick_mese','default:wood'},
+               {'default:stone', 'mesecons:piston','default:stone'},
+               {'default:stone', 'mesecons:mesecon','default:stone'},
+
+       }
+})
+
+node_breaker_on = function(pos, node)
+       if node.name == "technic:nodebreaker_off" then
+               hacky_swap_node(pos,"technic:nodebreaker_on")
+               break_node (pos,node.param2)
+               nodeupdate(pos)
+       end
+end
+
+node_breaker_off = function(pos, node)
+       if node.name == "technic:nodebreaker_on" then
+               hacky_swap_node(pos,"technic:nodebreaker_off")
+               nodeupdate(pos)
+       end
+end
+
+minetest.register_node("technic:nodebreaker_off", {
+       description = "Node Breaker",
+       tile_images = {"technic_nodebreaker_top_off.png","technic_nodebreaker_bottom_off.png","technic_nodebreaker_side2_off.png","technic_nodebreaker_side1_off.png",
+                       "technic_nodebreaker_back.png","technic_nodebreaker_front_off.png"},
+       is_ground_content = true,
+       paramtype2 = "facedir",
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1},
+       mesecons= {effector={action_on=node_breaker_on, action_off=node_breaker_off}},
+       sounds = default.node_sound_stone_defaults(),
+       on_construct = function(pos)
+       local meta = minetest.env:get_meta(pos)
+       end,
+       
+})
+
+minetest.register_node("technic:nodebreaker_on", {
+       description = "Node Breaker",
+       tile_images = {"technic_nodebreaker_top_on.png","technic_nodebreaker_bottom_on.png","technic_nodebreaker_side2_on.png","technic_nodebreaker_side1_on.png",
+                       "technic_nodebreaker_back.png","technic_nodebreaker_front_on.png"},
+       mesecons= {effector={action_on=node_breaker_on, action_off=node_breaker_off}},
+       is_ground_content = true,
+       paramtype2 = "facedir",
+       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1,not_in_creative_inventory=1},
+       sounds = default.node_sound_stone_defaults(),
+})
+
+
+function break_node (pos,n_param)              
+       local pos1={}
+       local pos2={}
+       pos1.x=pos.x
+       pos1.y=pos.y
+       pos1.z=pos.z
+       pos2.x=pos.x
+       pos2.y=pos.y
+       pos2.z=pos.z
+
+       --param2 3=x+ 1=x- 2=z+ 0=z-
+       local x_velocity=0
+       local z_velocity=0
+
+       if n_param==3 then pos2.x=pos2.x+1 pos1.x=pos1.x-1 x_velocity=-1 end
+       if n_param==2 then pos2.z=pos2.z+1 pos1.z=pos1.z-1 z_velocity=-1 end
+       if n_param==1 then pos2.x=pos2.x-1 pos1.x=pos1.x+1 x_velocity=1 end
+       if n_param==0 then pos2.z=pos2.z-1 pos1.x=pos1.z+1 z_velocity=1 end
+
+       local node=minetest.env:get_node(pos2)
+       if node.name == "air" then return nil end
+       if node.name == "default:lava_source" then return nil end
+       if node.name == "default:lava_flowing" then return nil end
+       if node.name == "default:water_source" then minetest.env:remove_node(pos2) return nil end
+       if node.name == "default:water_flowing" then minetest.env:remove_node(pos2) return nil end
+       if node.name == "ignore" then minetest.env:remove_node(pos2) return nil end
+       local drops = minetest.get_node_drops(node.name, "default:pick_mese")
+               local _, dropped_item
+               for _, dropped_item in ipairs(drops) do
+                       local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},dropped_item)
+                       item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
+                       item1:setvelocity({x=x_velocity, y=0, z=z_velocity})
+                       item1:setacceleration({x=0, y=0, z=0})
+               end
+       minetest.env:remove_node(pos2)
+end
+
diff --git a/technic/machines/other/tetris.lua b/technic/machines/other/tetris.lua
new file mode 100644 (file)
index 0000000..3b14c47
--- /dev/null
@@ -0,0 +1,17 @@
+minetest.register_node("technic:tetris_machine_node1", {
+       tiles = {"tetris_machine_top.png", "technic_mv_battery_box_bottom.png", "tetris_machine_front1.png",
+               "tetris_machine_side1B.png", "tetris_machine_side1P.png", "tetris_machine_side1L.png"},
+       tile_images = {"technic_tetris_machine.png",},
+       is_ground_content = true,
+       groups = {cracky=1},
+       sounds = default.node_sound_stone_defaults(),
+})
+
+minetest.register_node("technic:tetris_machine_node2", {
+       tiles = {"tetris_machine_top.png", "technic_mv_battery_box_bottom.png", "tetris_machine_front2.png",
+               "tetris_machine_side2B.png", "tetris_machine_side2P.png", "tetris_machine_side2L.png"},
+       tile_images = {"technic_tetris_machine.png",},
+       is_ground_content = true,
+       groups = {cracky=1},
+       sounds = default.node_sound_stone_defaults(),
+})
diff --git a/technic/machines/supply_converter.lua b/technic/machines/supply_converter.lua
new file mode 100644 (file)
index 0000000..bee99d2
--- /dev/null
@@ -0,0 +1,232 @@
+-- The supply converter is a generic device which can convert from
+-- LV to MV and back, and HV to MV and back.
+-- The machine will not convert from HV directly to LV.
+-- The machine is configured by the wiring below and above it.
+-- It is prepared for an upgrade slot if this is to be implemented later.
+--
+-- The conversion factor is a constant and the conversion is a lossy operation.
+--
+-- It works like this:
+--   The top side is setup as the "RE" side, the bottom as the "PR" side.
+--   Once the RE side is powered it will deliver power to the other side.
+--   Unused power is wasted just like any other producer!
+--   
+minetest.register_node(
+   "technic:supply_converter", {
+      description = "Supply Converter",
+      tiles  = {"technic_supply_converter_top.png", "technic_supply_converter_bottom.png", "technic_supply_converter_side.png",
+               "technic_supply_converter_side.png", "technic_supply_converter_side.png", "technic_supply_converter_side.png"},
+      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+      sounds = default.node_sound_wood_defaults(),
+      drawtype = "nodebox",
+      paramtype = "light",
+      is_ground_content = true,
+      node_box = {
+        type = "fixed",
+        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
+      },
+      selection_box = {
+        type = "fixed",
+        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
+      },
+      on_construct = function(pos)
+                       local meta = minetest.env:get_meta(pos)
+                       meta:set_float("technic_hv_power_machine", 1)
+                       meta:set_float("technic_mv_power_machine", 1)
+                       meta:set_float("technic_power_machine", 1)
+                       meta:set_string("infotext", "Supply Converter")
+                         meta:set_float("active", false)
+                      end,
+   })
+
+minetest.register_craft({
+       output = 'technic:supply_converter 1',
+       recipe = {
+               {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot','technic:stainless_steel_ingot'},
+               {'technic:mv_transformer',        'technic:mv_cable',             'technic:lv_transformer'},
+               {'technic:mv_cable',              'technic:rubber',               'technic:lv_cable'},
+       }
+})
+
+minetest.register_abm(
+   { nodenames = {"technic:supply_converter"},
+     interval   = 1,
+     chance     = 1,
+     action = function(pos, node, active_object_count, active_object_count_wider)
+                -- Conversion factors (a picture of V*A - loss) Asymmetric.
+                local lv_mv_factor  = 5 -- division (higher is less efficient)
+                local mv_lv_factor  = 4 -- multiplication (higher is more efficient)
+                local mv_hv_factor  = 5 -- division
+                local hv_mv_factor  = 4 -- multiplication
+                local max_lv_demand = 2000 -- The increment size power supply tier. Determines how many are needed
+                local max_mv_demand = 2000 -- -""-
+                local max_hv_demand = 2000 -- -""-
+
+                -- Machine information
+                local machine_name  = "Supply Converter"
+                local meta          = minetest.env:get_meta(pos)
+                local upgrade       = "" -- Replace with expansion slot later??
+                
+                -- High voltage on top, low at bottom regardless of converter direction
+                local pos_up        = {x=pos.x, y=pos.y+1, z=pos.z}
+                local pos_down      = {x=pos.x, y=pos.y-1, z=pos.z}
+                local meta_up       = minetest.env:get_meta(pos_up)
+                local meta_down     = minetest.env:get_meta(pos_down)
+                local convert_MV_LV = 0
+                local convert_LV_MV = 0
+                local convert_MV_HV = 0
+                local convert_HV_MV = 0
+                -- check cabling
+                if meta_up:get_float("mv_cablelike") == 1 and meta_down:get_float("cablelike") == 1 then
+                   convert_MV_LV = 1
+                   upgrade = "MV-LV step down"
+                end
+                if meta_up:get_float("cablelike") == 1 and meta_down:get_float("mv_cablelike") == 1 then
+                   convert_LV_MV = 1
+                   upgrade = "LV-MV step up"
+                end
+                if meta_up:get_float("mv_cablelike") == 1 and meta_down:get_float("hv_cablelike") == 1 then
+                   convert_MV_HV = 1
+                   upgrade = "MV-HV step up"
+                end
+                if meta_up:get_float("hv_cablelike") == 1 and meta_down:get_float("mv_cablelike") == 1 then
+                   convert_HV_MV = 1
+                   upgrade = "HV-MV step down"
+                end
+                --print("Cabling:"..convert_MV_LV.."|"..convert_LV_MV.."|"..convert_HV_MV.."|"..convert_MV_HV)
+
+                if convert_MV_LV == 0 and convert_LV_MV == 0 and convert_HV_MV == 0 and convert_MV_HV == 0 then
+                   meta:set_string("infotext", machine_name.." has bad cabling")
+                   meta:set_int("LV_EU_demand", 0)
+                   meta:set_int("LV_EU_supply", 0)
+                   meta:set_int("LV_EU_input",  0)
+                   meta:set_int("MV_EU_demand", 0)
+                   meta:set_int("MV_EU_supply", 0)
+                   meta:set_int("MV_EU_input",  0)
+                   meta:set_int("HV_EU_demand", 0)
+                   meta:set_int("HV_EU_supply", 0)
+                   meta:set_int("HV_EU_input",  0)
+                   return
+                end
+
+                -- The node is programmed with an upgrade slot
+                -- containing a MV-LV step down, LV-MV step up, HV-MV step down or MV-HV step up unit
+
+                if upgrade == "" then
+                   meta:set_string("infotext", machine_name.." has an empty converter slot");
+                   technic.unregister_LV_machine("technic:supply_converter")
+                   technic.unregister_MV_machine("technic:supply_converter")
+                   technic.unregister_HV_machine("technic:supply_converter")
+                   meta:set_int("LV_EU_demand", 0)
+                   meta:set_int("LV_EU_supply", 0)
+                   meta:set_int("LV_EU_input",  0)
+                   meta:set_int("MV_EU_demand", 0)
+                   meta:set_int("MV_EU_supply", 0)
+                   meta:set_int("MV_EU_input",  0)
+                   meta:set_int("HV_EU_demand", 0)
+                   meta:set_int("HV_EU_supply", 0)
+                   meta:set_int("HV_EU_input",  0)
+                   return
+                end
+
+                -- State machine
+                if upgrade == "MV-LV step down" and convert_MV_LV then
+                   -- Register machine type
+                   technic.register_LV_machine("technic:supply_converter","PR")
+                   technic.register_MV_machine("technic:supply_converter","RE")
+
+                   -- Power off automatically if no longer connected to a switching station
+                   technic.switching_station_timeout_count(pos, "MV")
+
+                   local eu_input  = meta:get_int("MV_EU_input")
+                   if eu_input == 0 then
+                      -- Unpowered - go idle
+                      --hacky_swap_node(pos, machine_node)
+                      meta:set_string("infotext", machine_name.." Unpowered")
+                      meta:set_int("LV_EU_supply", 0)
+                      meta:set_int("MV_EU_supply", 0)
+
+                      meta:set_int("LV_EU_demand", 0)
+                      meta:set_int("MV_EU_demand", max_mv_demand)
+                   else
+                      -- MV side has got power to spare
+                      meta:set_string("infotext", machine_name.." is active (MV:"..max_mv_demand.."->LV:"..eu_input*mv_lv_factor..")");
+                      meta:set_int("LV_EU_supply", eu_input*mv_lv_factor)
+                   end
+                   ---------------------------------------------------
+                elseif upgrade == "LV-MV step up"   and convert_LV_MV then
+                   -- Register machine type
+                   technic.register_LV_machine("technic:supply_converter","RE")
+                   technic.register_MV_machine("technic:supply_converter","PR")
+
+                   -- Power off automatically if no longer connected to a switching station
+                   technic.switching_station_timeout_count(pos, "LV")
+
+                   local eu_input  = meta:get_int("LV_EU_input")
+                   if eu_input == 0 then
+                      -- Unpowered - go idle
+                      --hacky_swap_node(pos, machine_node)
+                      meta:set_string("infotext", machine_name.." Unpowered")
+                      meta:set_int("LV_EU_supply", 0)
+                      meta:set_int("MV_EU_supply", 0)
+
+                      meta:set_int("LV_EU_demand", max_lv_demand)
+                      meta:set_int("MV_EU_demand", 0)
+                   else
+                      -- LV side has got power to spare
+                      meta:set_string("infotext", machine_name.." is active (LV:"..max_lv_demand.."->MV:"..eu_input/lv_mv_factor..")");
+                      meta:set_int("MV_EU_supply", eu_input/lv_mv_factor)
+                   end
+                   ---------------------------------------------------
+
+                elseif upgrade == "HV-MV step down" and convert_HV_MV then
+                   -- Register machine type
+                   technic.register_MV_machine("technic:supply_converter","PR")
+                   technic.register_HV_machine("technic:supply_converter","RE")
+
+                   -- Power off automatically if no longer connected to a switching station
+                   technic.switching_station_timeout_count(pos, "HV")
+
+                   local eu_input  = meta:get_int("HV_EU_input")
+                   if eu_input == 0 then
+                      -- Unpowered - go idle
+                      --hacky_swap_node(pos, machine_node)
+                      meta:set_string("infotext", machine_name.." Unpowered")
+                      meta:set_int("MV_EU_supply", 0)
+                      meta:set_int("HV_EU_supply", 0)
+
+                      meta:set_int("MV_EU_demand", 0)
+                      meta:set_int("HV_EU_demand", max_hv_demand)
+                   else
+                      -- HV side has got power to spare
+                      meta:set_string("infotext", machine_name.." is active (HV:"..max_hv_demand.."->MV:"..eu_input*hv_mv_factor..")");
+                      meta:set_int("MV_EU_supply", eu_input*hv_mv_factor)
+                   end
+                   ---------------------------------------------------
+                elseif upgrade == "MV-HV step up"   and convert_MV_HV then
+                   -- Register machine type
+                   technic.register_MV_machine("technic:supply_converter","RE")
+                   technic.register_HV_machine("technic:supply_converter","PR")
+
+                   -- Power off automatically if no longer connected to a switching station
+                   technic.switching_station_timeout_count(pos, "MV")
+
+                   local eu_input  = meta:get_int("MV_EU_input")
+                   if eu_input == 0 then
+                      -- Unpowered - go idle
+                      --hacky_swap_node(pos, machine_node)
+                      meta:set_string("infotext", machine_name.." Unpowered")
+                      meta:set_int("MV_EU_supply", 0)
+                      meta:set_int("HV_EU_supply", 0)
+
+                      meta:set_int("MV_EU_demand", max_mv_demand)
+                      meta:set_int("HV_EU_demand", 0)
+                   else
+                      -- MV side has got power to spare
+                      meta:set_string("infotext", machine_name.." is active (MV:"..max_mv_demand.."->HV:"..eu_input/mv_hv_factor..")");
+                      meta:set_int("HV_EU_supply", eu_input/mv_hv_factor)
+                   end
+                   ---------------------------------------------------
+                end
+       end,
+})
diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua
new file mode 100644 (file)
index 0000000..36133fa
--- /dev/null
@@ -0,0 +1,352 @@
+-- SWITCHING STATION
+-- The switching station is the center of all power distribution on an electric network.
+-- The station will collect all produced power from producers (PR) and batteries (BA)
+-- and distribute it to receivers (RE) and depleted batteries (BA).
+--
+-- It works like this:
+--  All PR,BA,RE nodes are indexed and tagged with the switching station.
+-- The tagging is to allow more stations to be built without allowing a cheat
+-- with duplicating power.
+--  All the RE nodes are queried for their current EU demand. Those which are off
+-- would require no or a small standby EU demand, while those which are on would
+-- require more.
+-- If the total demand is less than the available power they are all updated with the
+-- demand number.
+-- If any surplus exists from the PR nodes the batteries will be charged evenly with this.
+-- If the total demand requires draw on the batteries they will be discharged evenly.
+--
+-- If the total demand is more than the available power all RE nodes will be shut down.
+-- We have a brown-out situation.
+--
+-- Hence all the power distribution logic resides in this single node.
+--
+--  Nodes connected to the network will have one or more of these parameters as meta data:
+--   <LV|MV|HV>_EU_supply : Exists for PR and BA node types. This is the EU value supplied by the node. Output
+--   <LV|MV|HV>_EU_demand : Exists for RE and BA node types. This is the EU value the node requires to run. Output
+--   <LV|MV|HV>_EU_input  : Exists for RE and BA node types. This is the actual EU value the network can give the node. Input
+--
+--  The reason the LV|MV|HV type is prepended toe meta data is because some machine could require several supplies to work.
+--  This way the supplies are separated per network.
+technic.DBG = 1
+local dprint = technic.dprint
+
+minetest.register_craft(
+   {
+      output = 'technic:switching_station 1',
+      recipe = {
+        {'technic:lv_transformer', 'technic:mv_transformer', 'technic:hv_transformer'},
+        {'technic:lv_transformer', 'technic:mv_transformer', 'technic:hv_transformer'},
+        {'technic:lv_cable',       'technic:mv_cable',       'technic:hv_cable'},
+      }
+   })
+
+minetest.register_node(
+   "technic:switching_station",
+   {description = "Switching Station",
+    tiles  = {"technic_water_mill_top_active.png", "technic_water_mill_top_active.png", "technic_water_mill_top_active.png",
+             "technic_water_mill_top_active.png", "technic_water_mill_top_active.png", "technic_water_mill_top_active.png"},
+    groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
+    sounds = default.node_sound_wood_defaults(),
+    drawtype = "nodebox",
+    paramtype = "light",
+    is_ground_content = true,
+    node_box = {
+        type = "fixed",
+       fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
+    },
+    selection_box = {
+       type = "fixed",
+       fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
+    },
+    on_construct = function(pos)
+                     local meta = minetest.env:get_meta(pos)
+                     meta:set_string("infotext", "Switching Station")
+--                     minetest.chat_send_player(puncher:get_player_name(), "Switching station constructed. Punch the station to shut down the network.");
+--                     meta:set_int("active", 1)
+                  end,
+--      on_punch = function(pos, node, puncher)
+--                 local meta   = minetest.env:get_meta(pos)
+--                 local active = meta:get_int("active")
+--                 if active == 1 then
+--                    meta:set_int("active", 0)
+--                    minetest.chat_send_player(puncher:get_player_name(), "Electrical network shut down. Punch again to turn it on.");
+--                 else
+--                    meta:set_int("active", 1)
+--                    minetest.chat_send_player(puncher:get_player_name(), "Electrical network turned on. Punch again to shut it down.");
+--                 end
+--              end
+ })
+
+--------------------------------------------------
+-- Functions to help the machines on the electrical network
+--------------------------------------------------
+-- This one provides a timeout for a node in case it was disconnected from the network
+-- A node must be touched by the station continuously in order to function
+technic.switching_station_timeout_count = function(pos, machine_tier)
+                                            local meta = minetest.env:get_meta(pos)
+                                            timeout =  meta:get_int(machine_tier.."_EU_timeout")
+                                            --print("Counting timeout "..timeout)
+                                            if timeout == 0 then
+                                               --print("OFF")
+                                               meta:set_int(machine_tier.."_EU_input", 0)
+                                            else
+                                               --print("ON")
+                                               meta:set_int(machine_tier.."_EU_timeout", timeout-1)
+                                            end
+                                         end
+
+--------------------------------------------------
+-- Functions to traverse the electrical network
+--------------------------------------------------
+
+-- Add a wire node to the LV/MV/HV network
+local add_new_cable_node = function(nodes,pos)
+                             local i = 1
+                             repeat
+                                if nodes[i]==nil then break end
+                                if pos.x==nodes[i].x and pos.y==nodes[i].y and pos.z==nodes[i].z then return false end
+                                i=i+1
+                             until false
+                             nodes[i] = {x=pos.x, y=pos.y, z=pos.z, visited=1} -- copy position
+                             return true
+                          end
+
+-- Generic function to add found connected nodes to the right classification array
+local check_node_subp = function(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos,machines,cablename)
+                          local meta = minetest.env:get_meta(pos)
+                          local name = minetest.env:get_node(pos).name
+                          if meta:get_float(cablename)==1 then
+                             add_new_cable_node(all_nodes,pos)
+                          elseif machines[name] then
+                             --dprint(name.." is a "..machines[name])
+                             if     machines[name] == "PR" then
+                                add_new_cable_node(PR_nodes,pos)
+                             elseif machines[name] == "RE" then
+                                add_new_cable_node(RE_nodes,pos)
+                             elseif machines[name] == "BA" then
+                                add_new_cable_node(BA_nodes,pos)
+                             end
+                             if cablename == "cablelike" then
+                                meta:set_int("LV_EU_timeout", 2) -- Touch node
+                             elseif cablename == "mv_cablelike" then
+                                meta:set_int("MV_EU_timeout", 2) -- Touch node
+                             elseif cablename == "hv_cablelike" then
+                                meta:set_int("HV_EU_timeout", 2) -- Touch node
+                             end
+                          end
+                       end
+
+-- Traverse a network given a list of machines and a cable type name
+local traverse_network = function(PR_nodes,RE_nodes,BA_nodes,all_nodes, i, machines, cablename)
+                           local pos = {x=all_nodes[i].x, y=all_nodes[i].y, z=all_nodes[i].z} -- copy position
+                           pos.x=pos.x+1
+                           check_node_subp(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos, machines, cablename)
+                           pos.x=pos.x-2
+                           check_node_subp(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos, machines, cablename)
+                           pos.x=pos.x+1
+                           
+                           pos.y=pos.y+1
+                           check_node_subp(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos, machines, cablename)
+                           pos.y=pos.y-2
+                           check_node_subp(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos, machines, cablename)
+                           pos.y=pos.y+1
+                           
+                           pos.z=pos.z+1
+                           check_node_subp(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos, machines, cablename)
+                           pos.z=pos.z-2
+                           check_node_subp(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos, machines, cablename)
+                           pos.z=pos.z+1
+                     end
+
+----------------------------------------------
+-- The action code for the switching station
+----------------------------------------------
+minetest.register_abm(
+       {nodenames = {"technic:switching_station"},
+       interval   = 1,
+       chance     = 1,
+       action = function(pos, node, active_object_count, active_object_count_wider)
+                   local meta             = minetest.env:get_meta(pos)
+                   local meta1            = nil
+                   local pos1             = {}
+                   local PR_EU            = 0 -- EUs from PR nodes
+                   local BA_PR_EU         = 0 -- EUs from BA nodes (discharching)
+                   local BA_RE_EU         = 0 -- EUs to BA nodes (charging)
+                   local RE_EU            = 0 -- EUs to RE nodes
+
+                   local network   = ""
+                   local all_nodes = {}
+                   local PR_nodes  = {}
+                   local BA_nodes  = {} 
+                   local RE_nodes  = {}
+
+--                 -- Possible to turn off the entire network
+--                 if meta:get_int("active") == 0 then
+--                    for _,pos1 in pairs(RE_nodes) do
+--                       meta1  = minetest.env:get_meta(pos1)
+--                       meta1:set_int("EU_input", 0)
+--                    end
+--                    for _,pos1 in pairs(BA_nodes) do
+--                       meta1  = minetest.env:get_meta(pos1)
+--                       meta1:set_int("EU_input", 0)
+--                    end
+--                    return
+--                 end
+
+                   -- Which kind of network are we on:
+                   pos1 = {x=pos.x, y=pos.y-1, z=pos.z}
+                   all_nodes[1] = pos1
+
+                   meta1  = minetest.env:get_meta(pos1)
+                   if meta1:get_float("cablelike") ==1 then
+                      -- LV type
+                      --dprint("LV type")
+                      network = "LV"
+                      local table_index = 1
+                      repeat
+                         traverse_network(PR_nodes,RE_nodes,BA_nodes,all_nodes,table_index, technic.LV_machines, "cablelike")
+                         table_index = table_index + 1
+                         if all_nodes[table_index] == nil then break end
+                      until false
+                   elseif meta1:get_float("mv_cablelike") ==1 then
+                      -- MV type
+                      --dprint("MV type")
+                      network = "MV"
+                      local table_index = 1
+                      repeat
+                         traverse_network(PR_nodes,RE_nodes,BA_nodes,all_nodes,table_index, technic.MV_machines, "mv_cablelike")
+                         table_index = table_index + 1
+                         if all_nodes[table_index] == nil then break end
+                      until false
+                   elseif meta1:get_float("hv_cablelike") ==1 then
+                      -- HV type
+                      --dprint("HV type")
+                      network = "HV"
+                      local table_index = 1
+                      repeat
+                         traverse_network(PR_nodes,RE_nodes,BA_nodes,all_nodes,table_index, technic.HV_machines, "hv_cablelike")
+                         table_index = table_index + 1
+                         if all_nodes[table_index] == nil then break end
+                      until false
+                   else
+                      -- No type :-)
+                      --dprint("Not connected to a network")
+                      meta:set_string("infotext", "Switching Station - no network")
+                      return
+                   end
+                   --dprint("nodes="..table.getn(all_nodes).." PR="..table.getn(PR_nodes).." BA="..table.getn(BA_nodes).." RE="..table.getn(RE_nodes))
+
+                   -- Strings for the meta data
+                   local eu_demand_str    = network.."_EU_demand"
+                   local eu_input_str     = network.."_EU_input"
+                   local eu_supply_str    = network.."_EU_supply"
+                   local eu_from_fuel_str = network.."_EU_from_fuel"
+
+                   -- Get all the power from the PR nodes
+                   local PR_eu_supply = 0 -- Total power
+                   for _,pos1 in pairs(PR_nodes) do
+                      meta1  = minetest.env:get_meta(pos1)
+                      PR_eu_supply = PR_eu_supply + meta1:get_int(eu_supply_str)
+                   end
+                   --dprint("Total PR supply:"..PR_eu_supply)
+
+                   -- Get all the demand from the RE nodes
+                   local RE_eu_demand = 0
+                   for _,pos1 in pairs(RE_nodes) do
+                      meta1  = minetest.env:get_meta(pos1)
+                      RE_eu_demand = RE_eu_demand + meta1:get_int(eu_demand_str)
+                   end
+                   --dprint("Total RE demand:"..RE_eu_demand)
+
+                   -- Get all the power from the BA nodes
+                   local BA_eu_supply = 0
+                   for _,pos1 in pairs(BA_nodes) do
+                      meta1  = minetest.env:get_meta(pos1)
+                      BA_eu_supply = BA_eu_supply + meta1:get_int(eu_supply_str)
+                   end
+                   --dprint("Total BA supply:"..BA_eu_supply)
+
+                   -- Get all the demand from the BA nodes
+                   local BA_eu_demand = 0
+                   for _,pos1 in pairs(BA_nodes) do
+                      meta1  = minetest.env:get_meta(pos1)
+                      BA_eu_demand = BA_eu_demand + meta1:get_int(eu_demand_str)
+                   end
+                   --dprint("Total BA demand:"..BA_eu_demand)
+
+                   meta:set_string("infotext", "Switching Station. PR("..(PR_eu_supply+BA_eu_supply)..") RE("..(RE_eu_demand+BA_eu_demand)..")")
+
+                   -- If the PR supply is enough for the RE demand supply them all
+                   if PR_eu_supply >= RE_eu_demand then
+                      --dprint("PR_eu_supply"..PR_eu_supply.." >= RE_eu_demand"..RE_eu_demand)
+                      for _,pos1 in pairs(RE_nodes) do
+                         meta1  = minetest.env:get_meta(pos1)
+                         local eu_demand = meta1:get_int(eu_demand_str)
+                         meta1:set_int(eu_input_str, eu_demand)
+                      end
+                      -- We have a surplus, so distribute the rest equally to the BA nodes
+                      -- Let's calculate the factor of the demand
+                      PR_eu_supply = PR_eu_supply - RE_eu_demand
+                      local charge_factor = 0 -- Assume all batteries fully charged
+                      if BA_eu_demand > 0 then
+                         charge_factor = PR_eu_supply / BA_eu_demand
+                      end
+                      for n,pos1 in pairs(BA_nodes) do
+                         meta1  = minetest.env:get_meta(pos1)
+                         local eu_demand = meta1:get_int(eu_demand_str)
+                         meta1:set_int(eu_input_str, math.floor(eu_demand*charge_factor))
+                         --dprint("Charging battery:"..math.floor(eu_demand*charge_factor))
+                      end
+                      -- If still a surplus we can start giving back to the fuel burning generators
+                      -- Only full EU packages are given back. The rest is wasted.
+                      if BA_eu_demand == 0 then
+                         for _,pos1 in pairs(PR_nodes) do
+                            meta1  = minetest.env:get_meta(pos1)
+                            if meta1:get_int(eu_from_fuel_str) == 1 then
+                               local eu_supply = meta1:get_int(eu_supply_str)
+                               if PR_eu_supply < eu_supply then
+                                  break
+                               else
+                                  -- Set the supply to 0 if we did not require it.
+                                  meta1:set_int(eu_supply_str, 0)
+                                  PR_eu_supply = PR_eu_supply - eu_supply
+                               end
+                            end
+                         end
+                      end
+                      return
+                   end
+
+                   -- If the PR supply is not enough for the RE demand we will discharge the batteries too
+                   if PR_eu_supply+BA_eu_supply >= RE_eu_demand then
+                      --dprint("PR_eu_supply "..PR_eu_supply.."+BA_eu_supply "..BA_eu_supply.." >= RE_eu_demand"..RE_eu_demand)
+                      for _,pos1 in pairs(RE_nodes) do
+                         meta1  = minetest.env:get_meta(pos1)
+                         local eu_demand = meta1:get_int(eu_demand_str)
+                         meta1:set_int(eu_input_str, eu_demand)
+                      end
+                      -- We have a deficit, so distribute to the BA nodes
+                      -- Let's calculate the factor of the supply
+                      local charge_factor = 0 -- Assume all batteries depleted
+                      if BA_eu_supply > 0 then
+                         charge_factor = (PR_eu_supply - RE_eu_demand) / BA_eu_supply
+                      end
+                      for n,pos1 in pairs(BA_nodes) do
+                         meta1  = minetest.env:get_meta(pos1)
+                         local eu_supply = meta1:get_int(eu_supply_str)
+                         meta1:set_int(eu_input_str, math.floor(eu_supply*charge_factor))
+                         --dprint("Discharging battery:"..math.floor(eu_supply*charge_factor))
+                      end
+                      return
+                   end
+
+                   -- If the PR+BA supply is not enough for the RE demand: Shut everything down!
+                   -- Note: another behaviour could also be imagined: provide the average power for all and let the node decide what happens.
+                   -- This is much simpler though: Not enough power for all==no power for all
+                   --print("NO POWER")
+                   for _,pos1 in pairs(RE_nodes) do
+                      meta1  = minetest.env:get_meta(pos1)
+                      meta1:set_int(eu_input_str, 0)
+                   end
+       end,
+})
diff --git a/technic/mining_drill.lua b/technic/mining_drill.lua
deleted file mode 100644 (file)
index 6df9e97..0000000
+++ /dev/null
@@ -1,384 +0,0 @@
-local mining_drill_max_charge=60000
-local mining_drill_mk2_max_charge=240000
-local mining_drill_mk3_max_charge=960000
-local mining_drill_power_usage=200
-local mining_drill_mk2_power_usage=600
-local mining_drill_mk3_power_usage=1800
-
-minetest.register_craft({
-       output = 'technic:mining_drill',
-       recipe = {
-               {'technic:stainless_steel_ingot',       'technic:diamond_drill_head',   'technic:stainless_steel_ingot'},
-               {'technic:stainless_steel_ingot',       'technic:motor',                                'technic:stainless_steel_ingot'},
-               {'',                                                            'technic:red_energy_crystal',   'moreores:copper_ingot'},
-       }
-})
-minetest.register_craft({
-       output = 'technic:mining_drill_mk2',
-       recipe = {
-               {'technic:diamond_drill_head',          'technic:diamond_drill_head',   'technic:diamond_drill_head'},
-               {'technic:stainless_steel_ingot',       'technic:mining_drill',                 'technic:stainless_steel_ingot'},
-               {'',                                                            'technic:green_energy_crystal', ''},
-       }
-})
-minetest.register_craft({
-       output = 'technic:mining_drill_mk3',
-       recipe = {
-               {'technic:diamond_drill_head',          'technic:diamond_drill_head',   'technic:diamond_drill_head'},
-               {'technic:stainless_steel_ingot',       'technic:mining_drill_mk2',     'technic:stainless_steel_ingot'},
-               {'',                                                            'technic:blue_energy_crystal',  ''},
-       }
-})
-
-function drill_dig_it (pos, player,drill_type,mode)
-       
-       local charge
-
-       if mode==1 then
-               drill_dig_it0 (pos,player)
-       end
-       
-       if mode==2 then -- 3 deep
-               dir=drill_dig_it1(player)
-               if dir==0 then -- x+
-                       drill_dig_it0 (pos,player)
-                       pos.x=pos.x+1
-                       drill_dig_it0 (pos,player)
-                       pos.x=pos.x+1
-                       drill_dig_it0 (pos,player)
-               end
-               if dir==1 then  -- x-
-                       drill_dig_it0 (pos,player)
-                       pos.x=pos.x-1
-                       drill_dig_it0 (pos,player)
-                       pos.x=pos.x-1
-                       drill_dig_it0 (pos,player)
-               end
-               if dir==2 then  -- z+
-                       drill_dig_it0 (pos,player)
-                       pos.z=pos.z+1
-                       drill_dig_it0 (pos,player)
-                       pos.z=pos.z+1
-                       drill_dig_it0 (pos,player)
-               end
-               if dir==3 then  -- z-
-                       drill_dig_it0 (pos,player)
-                       pos.z=pos.z+1
-                       drill_dig_it0 (pos,player)
-                       pos.z=pos.z+1
-                       drill_dig_it0 (pos,player)
-               end
-       end
-       
-       if mode==3 then -- 3 wide
-               dir=drill_dig_it1(player)
-               if dir==0 or dir==1 then -- x
-                       drill_dig_it0 (pos,player)
-                       pos.z=pos.z+1
-                       drill_dig_it0 (pos,player)
-                       pos.z=pos.z-2
-                       drill_dig_it0 (pos,player)
-               end
-               if dir==2 or dir==3 then  -- z
-                       drill_dig_it0 (pos,player)
-                       pos.x=pos.x+1
-                       drill_dig_it0 (pos,player)
-                       pos.x=pos.x-2
-                       drill_dig_it0 (pos,player)
-               end
-       end
-       
-       if mode==4 then -- 3 tall, selected in the middle
-               drill_dig_it0 (pos,player)
-               pos.y=pos.y+1
-               drill_dig_it0 (pos,player)
-               pos.y=pos.y-2
-               drill_dig_it0 (pos,player)
-       end
-
-       if mode==5 then -- 3 x 3
-               local dir=player:get_look_dir()
-               if math.abs(dir.y)<0.5 then
-                       dir=drill_dig_it1(player)
-                               if dir==0 or dir==1 then -- x
-                                       drill_dig_it2(pos,player)
-                               end
-                               if dir==2 or dir==3 then  -- z
-                                       drill_dig_it3(pos,player)
-                               end
-               else
-               drill_dig_it4(pos,player)
-               end
-       end
-       
-       if drill_type==1 then charge=mining_drill_power_usage end
-       if drill_type==2 then 
-               if  mode==1 then charge=mining_drill_mk2_power_usage end
-               if (mode==2 or mode==3 or mode==4) then charge=mining_drill_mk2_power_usage*3 end
-       end
-       if drill_type==3 then 
-               if  mode==1 then charge=mining_drill_power_usage end
-               if (mode==2 or mode==3 or mode==4) then charge=mining_drill_mk2_power_usage*6 end
-               if mode==5 then charge=mining_drill_mk2_power_usage*9 end
-       end
-       minetest.sound_play("mining_drill", {pos = pos, gain = 1.0, max_hear_distance = 10,})
-       return charge
-end
-
-function drill_dig_it0 (pos,player)
-       local node=minetest.env:get_node(pos)
-       if node.name == "air" or node.name == "ignore" then return end
-       if node.name == "default:lava_source" then return end
-       if node.name == "default:lava_flowing" then return end
-       if node.name == "default:water_source" then minetest.env:remove_node(pos) return end
-       if node.name == "default:water_flowing" then minetest.env:remove_node(pos) return end
-       minetest.node_dig(pos,node,player)
-end
-
-function drill_dig_it1 (player)
-       local dir=player:get_look_dir()
-       if math.abs(dir.x)>math.abs(dir.z) then 
-               if dir.x>0 then return 0 end
-               return 1
-       end
-       if dir.z>0 then return 2 end
-       return 3
-end
-
-function drill_dig_it2 (pos,player)
-       drill_dig_it0 (pos,player)
-       pos.z=pos.z+1
-       drill_dig_it0 (pos,player)
-       pos.z=pos.z-2
-       drill_dig_it0 (pos,player)
-       pos.z=pos.z+1
-       pos.y=pos.y+1
-       drill_dig_it0 (pos,player)
-       pos.z=pos.z+1
-       drill_dig_it0 (pos,player)
-       pos.z=pos.z-2
-       drill_dig_it0 (pos,player)
-       pos.z=pos.z+1
-       pos.y=pos.y-2
-       drill_dig_it0 (pos,player)
-       pos.z=pos.z+1
-       drill_dig_it0 (pos,player)
-       pos.z=pos.z-2
-       drill_dig_it0 (pos,player)
-end
-function drill_dig_it3 (pos,player)
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x+1
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x-2
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x+1
-       pos.y=pos.y+1
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x+1
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x-2
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x+1
-       pos.y=pos.y-2
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x+1
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x-2
-       drill_dig_it0 (pos,player)
-end
-
-function drill_dig_it4 (pos,player)
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x+1
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x-2
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x+1
-       pos.z=pos.z+1
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x+1
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x-2
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x+1
-       pos.z=pos.z-2
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x+1
-       drill_dig_it0 (pos,player)
-       pos.x=pos.x-2
-       drill_dig_it0 (pos,player)
-end
-
-technic.register_MV_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",
-       stack_max = 1,
-       on_use = function(itemstack, user, pointed_thing)
-               if pointed_thing.type=="node" then 
-               local item=itemstack:to_table()
-               local meta=get_item_meta(item["metadata"])
-               if meta==nil then return end --tool not charghed
-               if meta["charge"]==nil then return end
-               local charge=meta["charge"]
-               if charge-mining_drill_power_usage>0 then
-                       charge_to_take=drill_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,1,1)
-                       charge =charge-mining_drill_power_usage;
-                       meta["charge"]=charge
-                       item["metadata"]=set_item_meta(meta)
-                       technic.set_RE_wear(item,charge,mining_drill_max_charge)
-                       itemstack:replace(item)
-                       end
-               return itemstack
-               end
-       end,
-})
-
-minetest.register_tool("technic:mining_drill_mk2", {
-       description = "Mining Drill Mk2",
-       inventory_image = "technic_mining_drill_mk2.png",
-       on_use = function(itemstack, user, pointed_thing)
-       mining_drill_mk2_handler(itemstack,user,pointed_thing)
-       return itemstack
-       end,
-})
-technic.register_HV_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)
-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",
-       wield_image = "technic_mining_drill_mk2.png",
-       groups = {not_in_creative_inventory=1},
-       on_use = function(itemstack, user, pointed_thing)
-       mining_drill_mk2_handler(itemstack,user,pointed_thing)
-       return itemstack
-       end,
-})
-end
-
-minetest.register_tool("technic:mining_drill_mk3", {
-       description = "Mining Drill Mk3",
-       inventory_image = "technic_mining_drill_mk3.png",
-       on_use = function(itemstack, user, pointed_thing)
-       mining_drill_mk3_handler(itemstack,user,pointed_thing)
-       return itemstack
-       end,
-})
-technic.register_HV_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)
-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",
-       wield_image = "technic_mining_drill_mk3.png",
-       groups = {not_in_creative_inventory=1},
-       on_use = function(itemstack, user, pointed_thing)
-       mining_drill_mk3_handler(itemstack,user,pointed_thing)
-       return itemstack
-       end,
-})
-end
-
-function mining_drill_mk2_handler (itemstack,user,pointed_thing)
-       local keys=user:get_player_control()
-       local player_name=user:get_player_name()
-       local item=itemstack:to_table()
-       local meta=get_item_meta(item["metadata"])
-       if meta==nil or keys["sneak"]==true then return mining_drill_mk2_setmode(user,itemstack) end
-       if meta["mode"]==nil then return mining_drill_mk2_setmode(user,itemstack) end
-       if pointed_thing.type~="node" then return end
-       if meta["charge"]==nil then return end
-       charge=meta["charge"]
-       if charge-mining_drill_power_usage>0 then
-               local charge_to_take=drill_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,2,meta["mode"])
-               charge=charge-charge_to_take;
-               if charge<0 then charge=0 end
-               meta["charge"]=charge
-               item["metadata"]=set_item_meta(meta)
-               technic.set_RE_wear(item,charge,mining_drill_mk2_max_charge)
-               itemstack:replace(item)
-       end
-       return itemstack
-end
-
-function mining_drill_mk3_handler (itemstack,user,pointed_thing)
-       local keys=user:get_player_control()
-       local player_name=user:get_player_name()
-       local item=itemstack:to_table()
-       local meta=get_item_meta(item["metadata"])
-       if meta==nil or keys["sneak"]==true then return mining_drill_mk3_setmode(user,itemstack) end
-       if meta["mode"]==nil then return mining_drill_mk3_setmode(user,itemstack) end
-       if pointed_thing.type~="node" then return end
-       if meta["charge"]==nil then return end
-       local charge=meta["charge"]
-       if charge-mining_drill_power_usage>0 then
-               local charge_to_take=drill_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,3,meta["mode"])
-               charge=charge-charge_to_take;
-               if charge<0 then charge=0 end
-               meta["charge"]=charge
-               item["metadata"]=set_item_meta(meta)
-               technic.set_RE_wear(item,charge,mining_drill_mk3_max_charge)
-               itemstack:replace(item)
-       end
-       return itemstack
-end
-
-mining_drill_mode_text={
-{"Single node."},
-{"3 nodes deep."},
-{"3 modes wide."},
-{"3 modes tall."},
-{"3x3 nodes."},
-}
-
-function mining_drill_mk2_setmode(user,itemstack)
-       local player_name=user:get_player_name()
-       local item=itemstack:to_table()
-       local meta=get_item_meta(item["metadata"])
-       if meta==nil then
-               meta={}
-               mode=0
-       end
-       if meta["mode"]==nil then
-               minetest.chat_send_player(player_name,"Hold shift and use to change Mining Drill Mk2 modes.")
-               meta["mode"]=0
-               mode=0
-       end
-       mode=(meta["mode"])
-       mode=mode+1
-       if mode>=5 then mode=1 end
-       minetest.chat_send_player(player_name, "Mining Drill Mk2 mode : "..mode.." - "..mining_drill_mode_text[mode][1] )
-       item["name"]="technic:mining_drill_mk2_"..mode
-       meta["mode"]=mode
-       item["metadata"]=set_item_meta(meta)
-       itemstack:replace(item)
-       return itemstack
-end
-
-function mining_drill_mk3_setmode(user,itemstack)
-       local player_name=user:get_player_name()
-       local item=itemstack:to_table()
-       local meta=get_item_meta(item["metadata"])
-       if meta==nil then
-               meta={}
-               mode=0
-       end
-       if meta["mode"]==nil then
-               minetest.chat_send_player(player_name,"Hold shift and use to change Mining Drill Mk3 modes.")
-               meta["mode"]=0
-               mode=0
-       end
-       mode=(meta["mode"])
-       mode=mode+1
-       if mode>=6 then mode=1 end
-       minetest.chat_send_player(player_name, "Mining Drill Mk3 mode : "..mode.." - "..mining_drill_mode_text[mode][1] )
-       item["name"]="technic:mining_drill_mk3_"..mode
-       meta["mode"]=mode
-       item["metadata"]=set_item_meta(meta)
-       itemstack:replace(item)
-       return itemstack
-end
diff --git a/technic/mining_laser_mk1.lua b/technic/mining_laser_mk1.lua
deleted file mode 100644 (file)
index 8b89131..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-local laser_mk1_max_charge=40000
-technic.register_LV_power_tool ("technic:laser_mk1",laser_mk1_max_charge)
-
-local laser_shoot = function(itemstack, player, pointed_thing)
-                               local laser_straight_mode=0
-                               local playerpos=player:getpos()
-                               local dir=player:get_look_dir()
-                               if pointed_thing.type=="node" then  
-                                       pos=minetest.get_pointed_thing_position(pointed_thing, above)
-                                       local node = minetest.env:get_node(pos)
-                                       if node.name~="ignore" then
-                                       minetest.node_dig(pos,node,player)
-                                       end
-                                       laser_straight_mode=1
-                                       end     
-                               
-                               direction_y=math.abs(math.floor(dir.y*100))
-                               if direction_y>50 then entity_name="technic:laser_beam_entityV"
-                                       else entity_name="technic:laser_beam_entity" end
-                               
-                               if laser_straight_mode==1  then
-                                       pos1=minetest.get_pointed_thing_position(pointed_thing, under)
-                                       pos1.x=math.floor(pos1.x) 
-                                       pos1.y=math.floor(pos1.y)
-                                       pos1.z=math.floor(pos1.z)
-                                       obj=minetest.env:add_entity(pos1,entity_name)
-                               else
-                               obj=minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.6,z=playerpos.z},entity_name)
-                               end
-                               if obj:get_luaentity().player == nil then
-                                       obj:get_luaentity().player = player
-                               end
-                               if laser_straight_mode==1 and direction_y<50 then
-                                       obj:setvelocity({x=dir.x*8, y=0, z=dir.z*8})
-                               else if laser_straight_mode==1 and direction_y>50 then
-                                       obj:setvelocity({x=0, y=dir.y*8, z=dir.z*8})
-                                       end
-                               end
-                               if laser_straight_mode==0 then
-                                       obj:setvelocity({x=dir.x*8, y=dir.y*8, z=dir.z*8})
-                                       end
-                               obj:setacceleration({x=0, y=0, z=0})
-                               obj:setyaw(player:get_look_yaw()+math.pi)
-                               if obj:get_luaentity().player == nil then
-                                       obj:get_luaentity().player = player
-                               end
-                               --obj:get_luaentity().node = player:get_inventory():get_stack("main", 1):get_name()
-                               minetest.sound_play("technic_laser", {pos = playerpos, gain = 1.0, max_hear_distance = 10,})
-                               return true
-end
-
-
-minetest.register_tool("technic:laser_mk1", {
-       description = "Mining Laser MK1",
-       inventory_image = "technic_mining_laser_mk1.png",
-       stack_max = 1,
-       on_use = function(itemstack, user, pointed_thing)
-               item=itemstack:to_table()
-               local meta=get_item_meta(item["metadata"])
-               if meta==nil then return end --tool not charghed
-               if meta["charge"]==nil then return end
-               charge=meta["charge"]
-               if charge-400>0 then
-                laser_shoot(item, user, pointed_thing)
-                charge = charge-400;
-               technic.set_RE_wear(item,charge,laser_mk1_max_charge)
-               meta["charge"]=charge
-               item["metadata"]=set_item_meta(meta)
-               itemstack:replace(item)
-               end
-               return itemstack
-       end,
-})
-
-minetest.register_craft({
-       output = 'technic:laser_mk1',
-       recipe = {
-               {'default:diamond', 'default:steel_ingot', 'technic:battery'},
-               {'', 'default:steel_ingot', 'technic:battery'},
-               {'', '', 'default:copper_ingot'},
-       }
-})
-
-
-
-minetest.register_node("technic:laser_beam_box", {
-       drawtype = "nodebox",
-       node_box = {
-               type = "fixed",
-               fixed = {
-                       { -0.5 , -0.1, -0.1 ,  0.1 ,  0.1 , 0.1  },
-                       { -0.1 , -0.1 , -0.1 , 0.5, 0.1 , 0.1  },
-               }
-       },
-       tiles = {"technic_laser_beam.png"},
-       groups = {not_in_creative_inventory=1},
-})
-
-minetest.register_node("technic:laser_beam_boxV", {
-       drawtype = "nodebox",
-       node_box = {
-               type = "fixed",
-               fixed = {
-                       { -0.1 , -0.1 , -0.1 , 0.1 , 0.5, 0.1  },
-                       { -0.1 , -0.5, -0.1 ,  0.1 ,  0.1 , 0.1  },
-
-               }
-       },
-       tiles = {"technic_laser_beam.png"},
-       groups = {not_in_creative_inventory=1},
-})
-
-LASER_BEAM_ENTITY={
-       physical = false,
-       timer=0,
-       visual = "wielditem",
-       visual_size = {x=0.2, y=0.2},
-       textures = {"technic:laser_beam_box"},
-       lastpos={},
-       max_range=10,
-       count=0,
---     digger=nil,
-       collisionbox = {0,0,0,0,0,0},
-}
-
-LASER_BEAM_ENTITY.on_step = function(self, dtime)
-       self.timer=self.timer+dtime
-       local pos = self.object:getpos()
-       if self.player~=nil then if self.lastpos.x~=nil then lazer_it (pos, self.player) end end                
-       if self.lastpos.x ~=nil and self.lastpos.y ~=nil and self.lastpos.y ~=nil then 
-                       temp1={x=math.floor(self.lastpos.x),y=math.floor(self.lastpos.y),z=math.floor(self.lastpos.z)}
-                       temp2={x=math.floor(pos.x),y=math.floor(pos.y),z=math.floor(pos.z)}
-                       if temp1.x==temp2.x and temp1.y==temp2.y and temp1.z==temp2.z then return end
-                       end
-       self.lastpos={x=pos.x, y=pos.y, z=pos.z}        
-       self.count=self.count+1
-       if self.count==self.max_range then self.object:remove() end
-end
-
-LASER_BEAM_ENTITYV={
-       physical = false,
-       timer=0,
-       visual = "wielditem",
-       visual_size = {x=0.2, y=0.2},
-       textures = {"technic:laser_beam_boxV"},
-       lastpos={},
-       max_range=15,
-       count=0,
-       collisionbox = {0,0,0,0,0,0},
-}
-
-LASER_BEAM_ENTITYV.on_step = function(self, dtime)
-       self.timer=self.timer+dtime
-       local pos = self.object:getpos()
-       if self.player~=nil then if self.lastpos.x~=nil then lazer_it (pos, self.player) end end                
-       if self.lastpos.x ~=nil and self.lastpos.y ~=nil and self.lastpos.y ~=nil then 
-                       temp1={x=math.floor(self.lastpos.x),y=math.floor(self.lastpos.y),z=math.floor(self.lastpos.z)}
-                       temp2={x=math.floor(pos.x),y=math.floor(pos.y),z=math.floor(pos.z)}
-                       if temp1.x==temp2.x and temp1.y==temp2.y and temp1.z==temp2.z then return end
-                       end
-       self.lastpos={x=pos.x, y=pos.y, z=pos.z}        
-       self.count=self.count+1
-       if self.count==self.max_range then self.object:remove() end
-end
-
-
-minetest.register_entity("technic:laser_beam_entity", LASER_BEAM_ENTITY)
-minetest.register_entity("technic:laser_beam_entityV", LASER_BEAM_ENTITYV)
-
-function lazer_it (pos, player)        
-       local pos1={}
---     pos1.x=math.floor(pos.x)
---     pos1.y=math.floor(pos.y)
---     pos1.z=math.floor(pos.z)
-       local node = minetest.env:get_node(pos)
-       if node.name == "air" or node.name == "ignore" or node.name == "default:lava_source" or node.name == "default:lava_flowing" then return end
-       if node.name == "default:water_source" or node.name == "default:water_flowing" then minetest.env:remove_node(pos) return end
-       if player then minetest.node_dig(pos,node,player) end
-end
diff --git a/technic/music_player.lua b/technic/music_player.lua
deleted file mode 100644 (file)
index a3f52aa..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
--- LV Music player.
--- The playe can play music. But it is high ampage!
-minetest.register_alias("music_player", "technic:music_player")
-minetest.register_craft({
-       output = 'technic:music_player',
-       recipe = {
-               {'default:wood', 'default:wood', 'default:wood'},
-               {'default:diamond', 'default:diamond', 'default:diamond'},
-               {'default:stone', 'default:copper_ingot', 'default:stone'},
-       }
-})
-
-minetest.register_craftitem("technic:music_player", {
-       description = "Music Player",
-       stack_max = 99,
-})
-
-local music_player_formspec =
-   "invsize[8,9;]"..
-   "label[0,0;Music Player]"..
-   "button[4,1;1,1;track1;1]"..
-   "button[5,1;1,1;track2;2]"..
-   "button[6,1;1,1;track3;3]"..
-   "button[4,2;1,1;track4;4]"..
-   "button[5,2;1,1;track5;5]"..
-   "button[6,2;1,1;track6;6]"..
-   "button[4,3;1,1;track7;7]"..
-   "button[5,3;1,1;track8;8]"..
-   "button[6,3;1,1;track9;9]"..
-   "button[4,4;1,2;play;Play]"..
-   "button[6,4;1,2;stop;Stop]"..
-   "label[4,0;Current track --]"
-
-minetest.register_node(
-   "technic:music_player",
-   {
-      description = "Music Player",
-      tiles = {"technic_music_player_top.png", "technic_machine_bottom.png", "technic_music_player_side.png",
-              "technic_music_player_side.png", "technic_music_player_side.png", "technic_music_player_side.png"},
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-      sounds = default.node_sound_wood_defaults(),
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       meta:set_string("infotext", "Music Player")
-                       meta:set_float("technic_power_machine", 1)
-                       meta:set_int("active",     0) -- Is the device on?
-                       meta:set_int("music_player_current_track", 1)
-                       meta:set_string("formspec", music_player_formspec)
-                    end,
-      on_receive_fields = function(pos, formanme, fields, sender)
-                            local meta                 = minetest.env:get_meta(pos)
-                            music_handle               = meta:get_int("music_handle")
-                            music_player_current_track = meta:get_int("music_player_current_track")
-                            if fields.track1 then music_player_current_track = 1 end
-                            if fields.track2 then music_player_current_track = 2 end
-                            if fields.track3 then music_player_current_track = 3 end
-                            if fields.track4 then music_player_current_track = 4 end
-                            if fields.track5 then music_player_current_track = 5 end
-                            if fields.track6 then music_player_current_track = 6 end
-                            if fields.track7 then music_player_current_track = 7 end
-                            if fields.track8 then music_player_current_track = 8 end
-                            if fields.track9 then music_player_current_track = 9 end
-                            meta:set_int("music_player_current_track",music_player_current_track)
-                            if fields.play and meta:get_int("active") == 0 then
-                               if music_handle then minetest.sound_stop(music_handle) end
-                               music_handle = minetest.sound_play("technic_track"..music_player_current_track, {pos = pos, gain = 1.0,loop = true, max_hear_distance = 72,})
-                               meta:set_int("active",1)
-                            end
-                            if fields.stop then
-                               meta:set_int("active",0)
-                               if music_handle then minetest.sound_stop(music_handle) end
-                            end
-                            meta:set_int("music_handle",music_handle)
-                         end,
-   })
-
-minetest.register_abm(
-   { nodenames = {"technic:music_player"},
-     interval = 1,
-     chance   = 1,
-     action = function(pos, node, active_object_count, active_object_count_wider)
-                local meta         = minetest.env:get_meta(pos)
-                local eu_input     = meta:get_int("LV_EU_input")
-                local state        = meta:get_int("state")
-                local next_state   = state
-
-                -- Machine information
-                local machine_name         = "Music Player"
-                local machine_node         = "technic:music_player"
-                local machine_state_demand = { 10, 150 }
-                        
-                local music_handle         = meta:get_int("music_handle")
-
-                -- Setup meta data if it does not exist. state is used as an indicator of this
-                if state == 0 then
-                   meta:set_int("state", 1)
-                   meta:set_int("LV_EU_demand", machine_state_demand[1])
-                   meta:set_int("LV_EU_input", 0)
-                   return
-                end
-                        
-                -- Power off automatically if no longer connected to a switching station
-                technic.switching_station_timeout_count(pos, "LV")
-                        
-                -- State machine
-                if eu_input == 0 then
-                   -- unpowered - go idle
-                   -- hacky_swap_node(pos, machine_node) -- if someday two nodes for this
-                   meta:set_string("infotext", machine_name.." Unpowered")
-                   next_state = 1
-                elseif eu_input == machine_state_demand[state] then
-                   -- Powered - do the state specific actions
-                   if state == 1 then
-                      -- hacky_swap_node(pos, machine_node) -- if someday two nodes for this
-                      meta:set_string("infotext", machine_name.." Idle")
-
-                      if meta:get_int("active") == 1 then
-                         next_state = 2
-                      end
-
-                   elseif state == 2 then
-                      -- hacky_swap_node(pos, machine_node.."_active") -- if someday two nodes for this
-                      meta:set_string("infotext", machine_name.." Active")
-
-                      music_player_current_track=meta:get_int("music_player_current_track")
-                      meta:set_string("formspec",
-                                      "invsize[8,9;]"..
-                                         "label[0,0;Music Player]"..
-                                         "button[4,1;1,1;track1;1]"..
-                                         "button[5,1;1,1;track2;2]"..
-                                         "button[6,1;1,1;track3;3]"..
-                                         "button[4,2;1,1;track4;4]"..
-                                         "button[5,2;1,1;track5;5]"..
-                                         "button[6,2;1,1;track6;6]"..
-                                         "button[4,3;1,1;track7;7]"..
-                                         "button[5,3;1,1;track8;8]"..
-                                         "button[6,3;1,1;track9;9]"..
-                                         "button[4,4;1,2;play;Play]"..
-                                         "button[6,4;1,2;stop;Stop]"..
-                                         "label[4,0;Current track "..tostring(music_player_current_track).."]"
-                                   )
-                      if meta:get_int("active") == 0 then
-                         if music_handle then minetest.sound_stop(music_handle) end
-                         next_state = 1
-                      end
-                   end
-                end
-                -- Change state?
-                if next_state ~= state then
-                   meta:set_int("LV_EU_demand", machine_state_demand[next_state])
-                   meta:set_int("state", next_state)
-                end
-             end
-   })
-
-technic.register_LV_machine ("technic:music_player","RE")
diff --git a/technic/node_breaker.lua b/technic/node_breaker.lua
deleted file mode 100644 (file)
index 06de700..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-minetest.register_craft({
-       output = 'technic:nodebreaker_off 1',
-       recipe = {
-               {'default:wood', 'default:pick_mese','default:wood'},
-               {'default:stone', 'mesecons:piston','default:stone'},
-               {'default:stone', 'mesecons:mesecon','default:stone'},
-
-       }
-})
-
-node_breaker_on = function(pos, node)
-       if node.name == "technic:nodebreaker_off" then
-               hacky_swap_node(pos,"technic:nodebreaker_on")
-               break_node (pos,node.param2)
-               nodeupdate(pos)
-       end
-end
-
-node_breaker_off = function(pos, node)
-       if node.name == "technic:nodebreaker_on" then
-               hacky_swap_node(pos,"technic:nodebreaker_off")
-               nodeupdate(pos)
-       end
-end
-
-minetest.register_node("technic:nodebreaker_off", {
-       description = "Node Breaker",
-       tile_images = {"technic_nodebreaker_top_off.png","technic_nodebreaker_bottom_off.png","technic_nodebreaker_side2_off.png","technic_nodebreaker_side1_off.png",
-                       "technic_nodebreaker_back.png","technic_nodebreaker_front_off.png"},
-       is_ground_content = true,
-       paramtype2 = "facedir",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1},
-       mesecons= {effector={action_on=node_breaker_on, action_off=node_breaker_off}},
-       sounds = default.node_sound_stone_defaults(),
-       on_construct = function(pos)
-       local meta = minetest.env:get_meta(pos)
-       end,
-       
-})
-
-minetest.register_node("technic:nodebreaker_on", {
-       description = "Node Breaker",
-       tile_images = {"technic_nodebreaker_top_on.png","technic_nodebreaker_bottom_on.png","technic_nodebreaker_side2_on.png","technic_nodebreaker_side1_on.png",
-                       "technic_nodebreaker_back.png","technic_nodebreaker_front_on.png"},
-       mesecons= {effector={action_on=node_breaker_on, action_off=node_breaker_off}},
-       is_ground_content = true,
-       paramtype2 = "facedir",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1,not_in_creative_inventory=1},
-       sounds = default.node_sound_stone_defaults(),
-})
-
-
-function break_node (pos,n_param)              
-       local pos1={}
-       local pos2={}
-       pos1.x=pos.x
-       pos1.y=pos.y
-       pos1.z=pos.z
-       pos2.x=pos.x
-       pos2.y=pos.y
-       pos2.z=pos.z
-
-       --param2 3=x+ 1=x- 2=z+ 0=z-
-       local x_velocity=0
-       local z_velocity=0
-
-       if n_param==3 then pos2.x=pos2.x+1 pos1.x=pos1.x-1 x_velocity=-1 end
-       if n_param==2 then pos2.z=pos2.z+1 pos1.z=pos1.z-1 z_velocity=-1 end
-       if n_param==1 then pos2.x=pos2.x-1 pos1.x=pos1.x+1 x_velocity=1 end
-       if n_param==0 then pos2.z=pos2.z-1 pos1.x=pos1.z+1 z_velocity=1 end
-
-       local node=minetest.env:get_node(pos2)
-       if node.name == "air" then return nil end
-       if node.name == "default:lava_source" then return nil end
-       if node.name == "default:lava_flowing" then return nil end
-       if node.name == "default:water_source" then minetest.env:remove_node(pos2) return nil end
-       if node.name == "default:water_flowing" then minetest.env:remove_node(pos2) return nil end
-       if node.name == "ignore" then minetest.env:remove_node(pos2) return nil end
-       local drops = minetest.get_node_drops(node.name, "default:pick_mese")
-               local _, dropped_item
-               for _, dropped_item in ipairs(drops) do
-                       local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},dropped_item)
-                       item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
-                       item1:setvelocity({x=x_velocity, y=0, z=z_velocity})
-                       item1:setacceleration({x=0, y=0, z=0})
-               end
-       minetest.env:remove_node(pos2)
-end
-
diff --git a/technic/nuclear_reactor_hv.lua b/technic/nuclear_reactor_hv.lua
deleted file mode 100644 (file)
index a5204c7..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
--- The enriched uranium rod driven EU generator.
--- A very large and advanced machine providing vast amounts of power.
--- Very efficient but also expensive to run as it needs uranium. (10000EU 86400 ticks (24h))
--- Provides HV EUs that can be down converted as needed.
---
--- The nuclear reactor core needs water and a protective shield to work.
--- This is checked now and then and if the machine is tampered with... BOOM!
-local burn_ticks   =     1                      -- [minutes]. How many minutes does the power plant burn per serving?
-local power_supply = 10000                      -- [HV] EUs
-local fuel_type    = "technic:enriched_uranium" -- This reactor burns this stuff
-
--- FIXME: recipe must make more sense like a rod recepticle, steam chamber, HV generator?
-minetest.register_craft({
-       output = 'technic:hv_nuclear_reactor_core',
-       recipe = {
-               {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
-               {'technic:stainless_steel_ingot', '', 'technic:stainless_steel_ingot'},
-               {'technic:stainless_steel_ingot', 'technic:hv_cable', 'technic:stainless_steel_ingot'},
-       }
-})
-
-minetest.register_craftitem("technic:hv_nuclear_reactor_core", {
-       description = "Uranium Rod Driven HV Reactor",
-       stack_max = 1,
-}) 
-
-local generator_formspec =
-       "invsize[8,9;]"..
---     "image[0,0;5,5;technic_generator_menu.png]"..
-       "label[0,0;Nuclear Reactor Rod Compartment]"..
-       "list[current_name;src;2,1;3,2;]"..
-       "list[current_player;main;0,5;8,4;]"
-
--- "Boxy sphere"
-local nodebox = {{ -0.353, -0.353, -0.353, 0.353, 0.353, 0.353 }, -- Box
-                { -0.495, -0.064, -0.064, 0.495, 0.064, 0.064 }, -- Circle +-x
-                { -0.483, -0.128, -0.128, 0.483, 0.128, 0.128 },
-                { -0.462, -0.191, -0.191, 0.462, 0.191, 0.191 },
-                { -0.433, -0.249, -0.249, 0.433, 0.249, 0.249 },
-                { -0.397, -0.303, -0.303, 0.397, 0.303, 0.303 },
-                { -0.305, -0.396, -0.305, 0.305, 0.396, 0.305 }, -- Circle +-y
-                { -0.250, -0.432, -0.250, 0.250, 0.432, 0.250 },
-                { -0.191, -0.461, -0.191, 0.191, 0.461, 0.191 },
-                { -0.130, -0.482, -0.130, 0.130, 0.482, 0.130 },
-                { -0.066, -0.495, -0.066, 0.066, 0.495, 0.066 },
-                { -0.064, -0.064, -0.495, 0.064, 0.064, 0.495 }, -- Circle +-z
-                { -0.128, -0.128, -0.483, 0.128, 0.128, 0.483 },
-                { -0.191, -0.191, -0.462, 0.191, 0.191, 0.462 },
-                { -0.249, -0.249, -0.433, 0.249, 0.249, 0.433 },
-                { -0.303, -0.303, -0.397, 0.303, 0.303, 0.397 },
-                }
-
-minetest.register_node(
-   "technic:hv_nuclear_reactor_core",
-   {
-      description = "Nuclear Reactor",
-      tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
-              "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"},
---      paramtype2 = "facedir",
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_wood_defaults(),
-      drawtype="nodebox",
-      paramtype = "light",
-      node_box = {
-        type = "fixed",
-        fixed = nodebox
-      },
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       meta:set_string("infotext", "Nuclear Reactor Core")
-                       meta:set_float("technic_hv_power_machine", 1)
-                       meta:set_int("HV_EU_supply", 0)
-                       meta:set_int("HV_EU_from_fuel", 1) -- Signal to the switching station that this device burns some sort of fuel and needs special handling
-                       meta:set_int("burn_time", 0)
-                       meta:set_string("formspec", generator_formspec)
-                       local inv = meta:get_inventory()
-                       inv:set_size("src", 6)
-               end,    
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  else
-                     return true
-                  end
-               end,
-   })
-
-minetest.register_node(
-   "technic:hv_nuclear_reactor_core_active",
-   {
-      description = "Coal Driven Generator",
-      tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
-              "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"},
---      paramtype2 = "facedir",
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_wood_defaults(),
-      drop="technic:generator",
-      drawtype="nodebox",
-      light_source = 15,
-      paramtype = "light",
-      node_box = {
-        type = "fixed",
-        fixed = nodebox
-      },
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  else
-                     return true
-                  end
-               end,
-   })
-
-local check_reactor_structure = function(pos)
-                                  -- The reactor consists of an 11x11x11 cube structure
-                                  -- A cross section through the middle:
-                                  --  CCCCC CCCCC
-                                  --  CCCCC CCCCC
-                                  --  CCSSS SSSCC
-                                  --  CCSCC CCSCC
-                                  --  CCSCWWWCSCC
-                                  --  CCSCW#WCSCC
-                                  --  CCSCW|WCSCC
-                                  --  CCSCC|CCSCC
-                                  --  CCSSS|SSSCC
-                                  --  CCCCC|CCCCC
-                                  --  C = Concrete, S = Stainless Steel, W = water node (not floating), #=reactor core, |=HV cable
-                                  --  The man-hole and the HV cable is only in the middle.
-                                  local water_nodes = minetest.find_nodes_in_area({x=pos.x-1, y=pos.y-1, z=pos.z-1},
-                                                                            {x=pos.x+1, y=pos.y+1, z=pos.z+1}, "default:water_source")
-                                  --print("Water      (  25):"..#water_nodes)
-                                  if #water_nodes ~= 25 then
-                                     --print("Water supply defect")
-                                     return 0
-                                  end
-                                  local inner_shield_nodes = minetest.find_nodes_in_area({x=pos.x-2, y=pos.y-2, z=pos.z-2},
-                                                                                         {x=pos.x+2, y=pos.y+2, z=pos.z+2}, "technic:concrete")
-
-                                  --print("Concrete 1 (  96):"..#inner_shield_nodes)
-                                  if #inner_shield_nodes ~= 96 then
-                                     --print("Inner shield defect")
-                                     return 0
-                                  end
-                                  local steel_shield_nodes = minetest.find_nodes_in_area({x=pos.x-3, y=pos.y-3, z=pos.z-3},
-                                                                                         {x=pos.x+3, y=pos.y+3, z=pos.z+3}, "default:steelblock")
-
-                                  --print("Steel      ( 216):"..#steel_shield_nodes)
-                                  if #steel_shield_nodes ~= 216 then
-                                     --print("Steel shield defect")
-                                     return 0
-                                  end
-                                  local outer_shield_nodes = minetest.find_nodes_in_area({x=pos.x-5, y=pos.y-5, z=pos.z-5},
-                                                                                         {x=pos.x+5, y=pos.y+5, z=pos.z+5}, "technic:concrete")
-                                  --print("Concrete 2 (1080):"..#outer_shield_nodes)
-                                  if #outer_shield_nodes ~= (984+#inner_shield_nodes) then
-                                     --print("Outer shield defect")
-                                     return 0
-                                  end
-                                  return 1
-                               end
-
-local explode_reactor = function(pos)
-                          print("BOOM A reactor exploded!")
-                       end
-
-minetest.register_abm(
-   {
-      nodenames = {"technic:hv_nuclear_reactor_core","technic:hv_nuclear_reactor_core_active"},
-      interval = 1,
-      chance   = 1,
-      action = function(pos, node, active_object_count, active_object_count_wider)
-                 local meta = minetest.env:get_meta(pos)
-                 local burn_time= meta:get_int("burn_time")
-
-                 -- If more to burn and the energy produced was used: produce some more
-                 if burn_time>0 then
-                    if meta:get_int("HV_EU_supply") == 0 then
-                       -- We did not use the power
-                       meta:set_int("HV_EU_supply", power_sypply)
-                    else
-                       burn_time = burn_time - 1
-                       meta:set_int("burn_time",burn_time)
-                       meta:set_string("infotext", "Nuclear Reactor Core ("..math.floor(burn_time/(burn_ticks*60)*100).."%)")
-                    end
-                 end
-
-                 -- Burn another piece of coal
-                 if burn_time==0 then
-                    local inv = meta:get_inventory()
-                    local correct_fuel_count = 0
-                    if inv:is_empty("src") == false  then 
-                       local srclist= inv:get_list("src")
-                       for _, srcstack in pairs(srclist) do
-                          if srcstack then
-                             local src_item=srcstack:to_table()
-                             if src_item and src_item["name"] == fuel_type then
-                                correct_fuel_count = correct_fuel_count + 1
-                             end
-                          end
-                       end
-                       -- Check that the reactor is complete as well as the correct number of correct fuel
-                       if correct_fuel_count == 6 then
-                          if check_reactor_structure(pos) == 1 then
-                             burn_time=burn_ticks*60
-                             meta:set_int("burn_time",burn_time)
-                             hacky_swap_node (pos,"technic:hv_nuclear_reactor_core_active") 
-                             meta:set_int("HV_EU_supply", power_supply)
-                             for idx, srcstack in pairs(srclist) do
-                                srcstack:take_item()
-                                inv:set_stack("src", idx, srcstack)
-                             end
-                          else
-                             -- BOOM!!! (the reactor was compromised and it should explode after some time) TNT mod inspired??
-                             explode_reactor(pos)
-                          end
-                       else
-                          meta:set_int("HV_EU_supply", 0)
-                       end
-                    end
-                 end
-
-                 -- Nothing left to burn
-                 if burn_time==0 then
-                    meta:set_string("infotext", "Nuclear Reactor Core (idle)")
-                    hacky_swap_node (pos,"technic:hv_nuclear_reactor_core")
-                 end
-              end
-   })
-
-technic.register_HV_machine ("technic:hv_nuclear_reactor_core","PR")
-technic.register_HV_machine ("technic:hv_nuclear_reactor_core_active","PR")
diff --git a/technic/power_radiator.lua b/technic/power_radiator.lua
deleted file mode 100644 (file)
index 86a770e..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
--- The power radiator fuctions like an inductive charger
--- only better in the game setting.
--- The purpose is to allow small appliances to receive power
--- without the overhead of the wiring needed for larger machines.
---
--- The power radiator will consume power corresponding to the
--- sum(power rating of the attached appliances)/0.6
--- Using inductive power transfer is very inefficient so this is
--- set to the factor 0.6.
---
--- Punching the radiator will toggle the power state of all attached appliances.
---
-local power_radius = 6
-
-------------------------------------------------------------------
--- API for inductive powered nodes:
--- Use the functions below to set the corresponding callbacks
--- Also two nodes are needed: The inactive and the active one. The active must be called <name>_active .
-------------------------------------------------------------------
--- Register a new appliance using this function
-technic.inductive_nodes = {}
-technic.register_inductive_machine = function(name)
-                                       table.insert(technic.inductive_nodes, name)
-                                       table.insert(technic.inductive_nodes, name.."_active")
-                                    end
-
--- Appliances:
---  has_supply: pos of supply node if the appliance has a power radiator near with sufficient power for the demand else ""
---  EU_demand: The power demand of the device.
---  EU_charge: Actual use. set to EU_demand if active==1
---  active: set to 1 if the device is on
-technic.inductive_on_construct = function(pos, eu_demand, infotext)
-                                   local meta = minetest.env:get_meta(pos)
-                                   meta:set_string("infotext", infotext)
-                                   meta:set_int("technic_inductive_power_machine", 1)
-                                   meta:set_int("EU_demand",eu_demand)     -- The power demand of this appliance
-                                   meta:set_int("EU_charge",0)       -- The actual power draw of this appliance
-                                   meta:set_string("has_supply","") -- Register whether we are powered or not. For use with several radiators.
-                                   meta:set_int("active", 0)    -- If the appliance can be turned on and off by using it use this.
-                                end
-
-technic.inductive_on_punch_off = function(pos, eu_charge, swapnode)
-                   local meta = minetest.env:get_meta(pos)
-                   if meta:get_string("has_supply") ~= "" then
-                      hacky_swap_node(pos, swapnode)
-                      meta:set_int("active", 1)
-                      meta:set_int("EU_charge",eu_charge)
-                      --print("-----------")
-                      --print("Turn on:")
-                      --print("EUcha:"..meta:get_int("EU_charge"))
-                      --print("has_supply:"..meta:get_string("has_supply"))
-                      --print("<----------->")
-                   end
-                end
-
-technic.inductive_on_punch_on = function(pos, eu_charge, swapnode)
-                   local meta = minetest.env:get_meta(pos)
-                   hacky_swap_node(pos, swapnode)
-                   meta:set_int("active", 0)
-                   meta:set_int("EU_charge",eu_charge)
-                   --print("-----------")
-                   --print("Turn off:")
-                   --print("EUcha:"..meta:get_int("EU_charge"))
-                   --print("has_supply:"..meta:get_string("has_supply"))
-                   --print("<---------->")
-                end
-
-local shutdown_inductive_appliances = function(pos)
-                                        -- The supply radius
-                                        local rad = power_radius
-                                        -- If the radiator is removed. turn off all appliances in region
-                                        -- If another radiator is near it will turn on the appliances again
-                                        local positions = minetest.env:find_nodes_in_area({x=pos.x-rad,y=pos.y-rad,z=pos.z-rad},{x=pos.x+rad,y=pos.y+rad,z=pos.z+rad}, technic.inductive_nodes)
-                                        for _,pos1 in pairs(positions) do
-                                           local meta1 = minetest.env:get_meta(pos1)
-                                           -- If the appliance is belonging to this node
-                                           if meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
-                                              local nodename = minetest.env:get_node(pos1).name
-                                              -- Swap the node and make sure it is off and unpowered
-                                              if string.sub(nodename, -7) == "_active" then
-                                                 hacky_swap_node(pos1, string.sub(nodename, 1, -8))
-                                                 meta1:set_int("active", 0)
-                                                 meta1:set_int("EU_charge", 0)
-                                              end
-                                              meta1:set_string("has_supply", "")
-                                          end
-                                       end
-                                    end
-
-local toggle_on_off_inductive_appliances = function(pos, node, puncher)
-                                             if pos == nil then return end
-                                             -- The supply radius
-                                             local rad = power_radius
-                                             local positions = minetest.env:find_nodes_in_area({x=pos.x-rad,y=pos.y-rad,z=pos.z-rad},{x=pos.x+rad,y=pos.y+rad,z=pos.z+rad}, technic.inductive_nodes)
-                                             for _,pos1 in pairs(positions) do
-                                                local meta1 = minetest.env:get_meta(pos1)
-                                                if meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
-                                                   minetest.env:punch_node(pos1)
-                                                end
-                                             end
-                                          end
-
-minetest.register_node(
-   "technic:power_radiator", {
-      description = "Power Radiator",
-      tiles  = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
-               "technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-      sounds = default.node_sound_wood_defaults(),
-      drawtype = "nodebox",
-      paramtype = "light",
-      is_ground_content = true,
-      node_box = {
-        type = "fixed",
-        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
-      },
-      selection_box = {
-        type = "fixed",
-        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
-      },
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       meta:set_int("technic_mv_power_machine", 1)  -- MV machine
-                       meta:set_int("MV_EU_demand",1)               -- Demand on the primary side when idle
-                       meta:set_int("connected_EU_demand",0)        -- Potential demand of connected appliances
-                       meta:set_string("infotext", "Power Radiator")
---                     meta:set_int("active", 0)
-                    end,
-      on_dig = function(pos, node, digger)
-                 shutdown_inductive_appliances(pos)
-                 return minetest.node_dig(pos, node, digger)
-              end,
-      on_punch = function(pos, node, puncher)
-                   toggle_on_off_inductive_appliances(pos, node, puncher)
-                end
-   })
-
-minetest.register_craft(
-   {
-      output = 'technic:power_radiator 1',
-      recipe = {
-        {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
-        {'technic:copper_coil',           'technic:mv_transformer',        'technic:copper_coil'},
-        {'technic:rubber',                'technic:mv_cable',              'technic:rubber'},
-      }
-   })
-
-minetest.register_abm(
-   {nodenames = {"technic:power_radiator"},
-    interval   = 1,
-    chance     = 1,
-    action = function(pos, node, active_object_count, active_object_count_wider)
-               local meta             = minetest.env:get_meta(pos)
-               local eu_input  = meta:get_int("MV_EU_input")
-               local eu_demand = meta:get_int("MV_EU_demand")
-
-               -- Power off automatically if no longer connected to a switching station
-               technic.switching_station_timeout_count(pos, "MV")
-
-               if eu_input == 0 then
-                  -- No power
-                  meta:set_string("infotext", "Power Radiator is unpowered");
---                   meta:set_int("active",1) -- used for setting textures someday maybe
-                  shutdown_inductive_appliances(pos)
-                  meta:set_int("connected_EU_demand", 0)
-                  meta:set_int("MV_EU_demand",1)
-               elseif eu_input == eu_demand then
-                  -- Powered and ready
-
-                  -- The maximum EU sourcing a single radiator can provide.
-                  local max_charge          = 3000 -- == the max EU demand of the radiator
-                  local connected_EU_demand = meta:get_int("connected_EU_demand")
-
-                  -- Efficiency factor
-                  local eff_factor = 0.6
-                  -- The supply radius
-                  local rad = power_radius
-                  
-                  local meta1            = nil
-                  local pos1             = {}
-                  local used_charge      = 0
-                  
-                  -- Index all nodes within supply range
-                  local positions = minetest.env:find_nodes_in_area({x=pos.x-rad,y=pos.y-rad,z=pos.z-rad},{x=pos.x+rad,y=pos.y+rad,z=pos.z+rad}, technic.inductive_nodes)
-                  for _,pos1 in pairs(positions) do
-                     local meta1 = minetest.env:get_meta(pos1)
-                     -- If not supplied see if this node can handle it.
-                     if meta1:get_string("has_supply") == "" then
-                        -- if demand surpasses the capacity of this node, don't bother adding it.
-                        local app_eu_demand = math.floor(meta1:get_int("EU_demand")/eff_factor)
-                        if connected_EU_demand + app_eu_demand <= max_charge then
-                           --print("I can supply this:"..connected_EU_demand.."|"..app_eu_demand.."<="..max_charge.."|act:"..meta1:get_int("EU_charge"))
-                           -- We can power the appliance. Register, and spend power if it is on.
-                           connected_EU_demand = connected_EU_demand + app_eu_demand
-
-                           meta1:set_string("has_supply", pos.x..pos.y..pos.z)
-                           --Always 0: used_charge = math.floor(used_charge+meta1:get_int("EU_charge")/eff_factor)
-                        end
-                     elseif meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
-                        -- The appliance has power from this node. Spend power if it is on.
-                        used_charge = used_charge+math.floor(meta1:get_int("EU_charge")/eff_factor)
-                        --print("My Lamp ("..pos.x..","..pos.y..","..pos.z..") Used:"..used_charge.."Max:"..max_charge)
-                     end
-                     meta:set_string("infotext", "Power Radiator is powered ("..math.floor(used_charge/max_charge*100).."% of maximum power)");
-                     if used_charge == 0 then
-                        meta:set_int("MV_EU_demand", 1) -- Still idle
-                     else
-                        meta:set_int("MV_EU_demand", used_charge)
-                     end
---                   meta:set_int("active",1) -- used for setting textures someday maybe
-                  end
-                  -- Save state
-                  meta:set_int("connected_EU_demand",connected_EU_demand)
-               else
-                  -- This is the case where input ~= demand. Overloaded or underpowered!
---                --If demand surpasses actual supply turn off everything - we are out of power
---                if used_charge>eu_input then
---                   meta:set_string("infotext", "Power Radiator is overloaded ("..math.floor(used_charge/eu_input*100).."% of available power)");
-----                 meta:set_int("active",1) -- used for setting textures someday maybe
---                   shutdown_inductive_appliances(pos)
---                   connected_EU_demand = 0
-               end
-            end,
- })
-
-technic.register_MV_machine ("technic:power_radiator","RE")
diff --git a/technic/project_table.lua b/technic/project_table.lua
deleted file mode 100644 (file)
index 355295c..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-minetest.register_craft({
-       output = 'technic:project_table 1',
-       recipe = {
-               {'default:wood','default:wood','default:wood'},
-               {'default:wood','default:chest','default:wood'},
-               {'default:stone','default:stone','default:stone'},
-       }
-})
-
-
-minetest.register_craftitem("technic:project_table", {
-       description = "Project Table",
-       stack_max = 99,
-})
-
-minetest.register_node("technic:project_table", {
-       description = "Project Table",
-       tiles = {"technic_iron_chest_top.png", "technic_iron_chest_top.png", "technic_iron_chest_side.png",
-               "technic_iron_chest_side.png", "technic_iron_chest_side.png", "technic_iron_chest_front.png"},
-       paramtype2 = "facedir",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       legacy_facedir_simple = true,
-       sounds = default.node_sound_wood_defaults(),
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_string("formspec",
-                               "invsize[9,9;]"..
-                               "list[current_name;main;0,2;8,2;]"..
-                               "list[current_player;main;0,5;8,4;]")
-               meta:set_string("infotext", "Iron Chest")
-               local inv = meta:get_inventory()
-               inv:set_size("main", 8*4)
-       end,
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               return inv:is_empty("main")
-       end,
-})
\ No newline at end of file
diff --git a/technic/silver_chest.lua b/technic/silver_chest.lua
deleted file mode 100644 (file)
index 81dc47f..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-minetest.register_craft({
-       output = 'technic:silver_chest 1',
-       recipe = {
-               {'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
-               {'moreores:silver_ingot','technic:copper_chest','moreores:silver_ingot'},
-               {'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
-       }
-})
-
-minetest.register_craft({
-       output = 'technic:silver_locked_chest 1',
-       recipe = {
-               {'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
-               {'moreores:silver_ingot','technic:copper_locked_chest','moreores:silver_ingot'},
-               {'moreores:silver_ingot','moreores:silver_ingot','moreores:silver_ingot'},
-       }
-})
-
-minetest.register_craft({
-       output = 'technic:silver_locked_chest 1',
-       recipe = {
-               {'default:steel_ingot'},
-               {'technic:silver_chest'},
-       }
-})
-
-minetest.register_craftitem("technic:silver_chest", {
-       description = "Silver Chest",
-       stack_max = 99,
-})
-minetest.register_craftitem("technic:silver_locked_chest", {
-       description = "Silver Locked Chest",
-       stack_max = 99,
-})
-
-minetest.register_node("technic:silver_chest", {
-       description = "Silver Chest",
-       tiles = {"technic_silver_chest_top.png", "technic_silver_chest_top.png", "technic_silver_chest_side.png",
-               "technic_silver_chest_side.png", "technic_silver_chest_side.png", "technic_silver_chest_front.png"},
-       paramtype2 = "facedir",
-       groups = chest_groups1,
-       tube = tubes_properties,
-       legacy_facedir_simple = true,
-       sounds = default.node_sound_wood_defaults(),
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_string("formspec",
-                               "invsize[11,9;]"..
-                               "list[current_name;main;0,0;11,4;]"..
-                               "list[current_player;main;0,5;8,4;]")
-               meta:set_string("infotext", "Silver Chest")
-               local inv = meta:get_inventory()
-               inv:set_size("main", 11*4)
-       end,
-       can_dig = chest_can_dig,
-
-       on_punch = function (pos, node, puncher)
-               local meta = minetest.env:get_meta(pos);
-                meta:set_string("formspec", "hack:sign_text_input")
-       end,
-       
-       on_receive_fields = function(pos, formname, fields, sender)
-        local meta = minetest.env:get_meta(pos);
-               fields.text = fields.text or ""
-               meta:set_string("text", fields.text)
-               meta:set_string("infotext", '"'..fields.text..'"')
-
-               meta:set_string("formspec",
-                               "invsize[11,9;]"..
-                               "list[current_name;main;0,0;11,4;]"..
-                               "list[current_player;main;0,5;8,4;]")
-       end,
-
-       on_metadata_inventory_move = def_on_metadata_inventory_move,
-       on_metadata_inventory_put = def_on_metadata_inventory_put,
-       on_metadata_inventory_take = def_on_metadata_inventory_take 
-})
-
-minetest.register_node("technic:silver_locked_chest", {
-       description = "Silver Locked Chest",
-       tiles = {"technic_silver_chest_top.png", "technic_silver_chest_top.png", "technic_silver_chest_side.png",
-               "technic_silver_chest_side.png", "technic_silver_chest_side.png", "technic_silver_chest_locked.png"},
-       paramtype2 = "facedir",
-       groups = chest_groups2,
-       tube = tubes_properties,
-       legacy_facedir_simple = true,
-       sounds = default.node_sound_wood_defaults(),
-       after_place_node = function(pos, placer)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_string("owner", placer:get_player_name() or "")
-               meta:set_string("infotext", "Silver Locked Chest (owned by "..
-                       meta:get_string("owner")..")")
-       end,
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_string("formspec",
-                               "invsize[11,9;]"..
-                               "list[current_name;main;0,0;11,4;]"..
-                               "list[current_player;main;0,5;8,4;]")
-               meta:set_string("infotext", "Silver Locked Chest")
-               meta:set_string("owner", "")
-               local inv = meta:get_inventory()
-               inv:set_size("main", 11*4)
-       end,
-       can_dig = chest_can_dig,
-
-       on_punch = function (pos, node, puncher)
-               local meta = minetest.env:get_meta(pos);
-                meta:set_string("formspec", "hack:sign_text_input")
-       end,
-       
-       on_receive_fields = function(pos, formname, fields, sender)
-        local meta = minetest.env:get_meta(pos);
-               fields.text = fields.text or ""
-               meta:set_string("text", fields.text)
-               meta:set_string("infotext", '"'..fields.text..'"')
-
-               meta:set_string("formspec",
-                               "invsize[11,9;]"..
-                               "list[current_name;main;0,0;11,4;]"..
-                               "list[current_player;main;0,5;8,4;]")
-       end,
-
-
-       allow_metadata_inventory_move = def_allow_metadata_inventory_move,
-       allow_metadata_inventory_put = def_allow_metadata_inventory_put,
-       allow_metadata_inventory_take = def_allow_metadata_inventory_take,
-       on_metadata_inventory_move = def_on_metadata_inventory_move,
-       on_metadata_inventory_put = def_on_metadata_inventory_put,
-       on_metadata_inventory_take = def_on_metadata_inventory_take 
-})
diff --git a/technic/solar_array_hv.lua b/technic/solar_array_hv.lua
deleted file mode 100644 (file)
index 73f6ee2..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
--- The high voltage solar array is an assembly of medium voltage arrays.
--- The assembly can deliver high voltage levels and is a 20% less efficient
--- compared to 5 individual medium voltage arrays due to losses in the transformer.
--- However high voltage is supplied.
--- Solar arrays are not able to store large amounts of energy.
-minetest.register_node("technic:solar_array_hv", {
-       tiles = {"technic_hv_solar_array_top.png", "technic_hv_solar_array_bottom.png", "technic_hv_solar_array_side.png",
-                "technic_hv_solar_array_side.png", "technic_hv_solar_array_side.png", "technic_hv_solar_array_side.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       sounds = default.node_sound_wood_defaults(),
-       description="HV Solar Array",
-       active = false,
-       drawtype = "nodebox",
-       paramtype = "light",
-       is_ground_content = true,       
-       node_box = {
-                       type = "fixed",
-                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
-               },
-               selection_box = {
-                       type = "fixed",
-                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
-               },
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_float("technic_hv_power_machine", 1)
-               meta:set_int("HV_EU_supply", 0)
-               meta:set_string("infotext", "HV Solar Array")
-       end,
-})
-
-minetest.register_craft(
-   {output = 'technic:solar_array_hv 1',
-    recipe = {
-       {'technic:solar_array_mv', 'technic:solar_array_mv','technic:solar_array_mv'},
-       {'technic:solar_array_mv', 'technic:hv_transformer','technic:solar_array_mv'},
-       {'default:steel_ingot',    'technic:hv_cable',      'default:steel_ingot'},
-    }
- })
-
-minetest.register_abm(
-   {nodenames = {"technic:solar_array_hv"},
-    interval   = 1,
-    chance     = 1,
-    action = function(pos, node, active_object_count, active_object_count_wider)
-               -- The action here is to make the solar array produce power
-               -- Power is dependent on the light level and the height above ground
-               -- 130m and above is optimal as it would be above cloud level.
-                -- Height gives 1/4 of the effect, light 3/4. Max. effect is 2880EU for the array.
-                -- There are many ways to cheat by using other light sources like lamps.
-                -- As there is no way to determine if light is sunlight that is just a shame.
-                -- To take care of some of it solar panels do not work outside daylight hours or if
-                -- built below -10m
-               local pos1={}
-               pos1.y=pos.y+1
-               pos1.x=pos.x
-               pos1.z=pos.z
-               local light = minetest.env:get_node_light(pos1, nil)
-               local time_of_day = minetest.env:get_timeofday()
-               local meta = minetest.env:get_meta(pos)
-               if light == nil then light = 0 end
-               -- turn on array only during day time and if sufficient light
-                -- I know this is counter intuitive when cheating by using other light sources.
-               if light >= 12 and time_of_day>=0.24 and time_of_day<=0.76 and pos.y > -10 then
-                  local charge_to_give          = math.floor(light*(light*9.6+pos1.y/130*48))
-                  if charge_to_give<0   then charge_to_give=0 end
-                  if charge_to_give>160 then charge_to_give=160 end
-                  meta:set_string("infotext", "Solar Array is active ("..charge_to_give.."EU)")
-                  meta:set_int("HV_EU_supply", charge_to_give)
-               else
-                  meta:set_string("infotext", "Solar Array is inactive");
-                  meta:set_int("HV_EU_supply", 0)
-               end
-            end,
- }) 
-
-technic.register_HV_machine ("technic:solar_array_hv","PR")
-
diff --git a/technic/solar_array_lv.lua b/technic/solar_array_lv.lua
deleted file mode 100644 (file)
index e758eb8..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
--- The solar array is an assembly of panels into a powerful array
--- The assembly can deliver more energy than the individual panel because
--- of the transformer unit which converts the panel output variations into
--- a stable supply.
--- Solar arrays are not able to store large amounts of energy.
--- The LV arrays are used to make medium voltage arrays.
-minetest.register_node("technic:solar_array_lv", {
-       tiles = {"technic_lv_solar_array_top.png", "technic_lv_solar_array_bottom.png", "technic_lv_solar_array_side.png",
-               "technic_lv_solar_array_side.png", "technic_lv_solar_array_side.png", "technic_lv_solar_array_side.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       sounds = default.node_sound_wood_defaults(),
-       description="LV Solar Array",
-       drawtype = "nodebox",
-       paramtype = "light",
-       is_ground_content = true,       
-       node_box = {
-                       type = "fixed",
-                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
-               },
-               selection_box = {
-                       type = "fixed",
-                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
-               },
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_int("technic_power_machine", 1)
-               meta:set_int("LV_EU_supply", 0)
-               meta:set_string("infotext", "LV Solar Array")
-       end,
-})
-
-minetest.register_craft(
-   {output = 'technic:solar_array_lv 1',
-    recipe = {
-       {'technic:solar_panel', 'technic:solar_panel',    'technic:solar_panel'},
-       {'technic:solar_panel', 'technic:lv_transformer', 'technic:solar_panel'},
-       {'default:steel_ingot', 'technic:lv_cable',       'default:steel_ingot'},
-    }
- })
-
-minetest.register_abm(
-   {nodenames = {"technic:solar_array_lv"},
-    interval   = 1,
-    chance     = 1,
-    action = function(pos, node, active_object_count, active_object_count_wider)
-               -- The action here is to make the solar array produce power
-               -- Power is dependent on the light level and the height above ground
-               -- 130m and above is optimal as it would be above cloud level.
-               -- Height gives 1/4 of the effect, light 3/4. Max. effect is 160EU for the array.
-               -- There are many ways to cheat by using other light sources like lamps.
-               -- As there is no way to determine if light is sunlight that is just a shame.
-               -- To take care of some of it solar arrays do not work outside daylight hours or if
-               -- built below -10m
-               local pos1={}
-               pos1.y=pos.y+1
-               pos1.x=pos.x
-               pos1.z=pos.z
-               local light = minetest.env:get_node_light(pos1, nil)
-               local time_of_day = minetest.env:get_timeofday()
-               local meta = minetest.env:get_meta(pos)
-               if light == nil then light = 0 end
-               -- turn on array only during day time and if sufficient light
-               -- I know this is counter intuitive when cheating by using other light sources.
-               if light >= 12 and time_of_day>=0.24 and time_of_day<=0.76 and pos.y > -10 then
-                  local charge_to_give = math.floor(light*(light*0.5333+pos1.y/130*2.6667))
-                  if charge_to_give<0   then charge_to_give=0 end
-                  if charge_to_give>160 then charge_to_give=160 end
-                  meta:set_string("infotext", "Solar Array is active ("..charge_to_give.."EU)")
-                  meta:set_int("LV_EU_supply", charge_to_give)
-               else
-                  meta:set_string("infotext", "Solar Array is inactive");
-                  meta:set_int("LV_EU_supply", 0)
-               end
-            end,
- })
-
-technic.register_LV_machine ("technic:solar_array_lv","PR")
-
diff --git a/technic/solar_array_mv.lua b/technic/solar_array_mv.lua
deleted file mode 100644 (file)
index f389a9f..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
--- The medium voltage solar array is an assembly of low voltage arrays.
--- The assembly can deliver medium voltage levels and is a 10% less efficient
--- compared to 5 individual low voltage arrays due to losses in the transformer.
--- However medium voltage is supplied.
--- Solar arrays are not able to store large amounts of energy.
--- The MV arrays are used to make high voltage arrays.
-minetest.register_node("technic:solar_array_mv", {
-       tiles = {"technic_mv_solar_array_top.png", "technic_mv_solar_array_bottom.png", "technic_mv_solar_array_side.png",
-                "technic_mv_solar_array_side.png", "technic_mv_solar_array_side.png", "technic_mv_solar_array_side.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       sounds = default.node_sound_wood_defaults(),
-       description="MV Solar Array",
-       active = false,
-       drawtype = "nodebox",
-       paramtype = "light",
-       is_ground_content = true,       
-       node_box = {
-                       type = "fixed",
-                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
-               },
-               selection_box = {
-                       type = "fixed",
-                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
-               },
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_float("technic_mv_power_machine", 1)
-               meta:set_int("MV_EU_supply", 0)
-               meta:set_string("infotext", "MV Solar Array")
-       end,
-})
-
-minetest.register_craft(
-   {
-      output = 'technic:solar_array_mv 1',
-      recipe = {
-        {'technic:solar_array_lv', 'technic:solar_array_lv','technic:solar_array_lv'},
-        {'technic:solar_array_lv', 'technic:mv_transformer','technic:solar_array_lv'},
-        {'default:steel_ingot',    'technic:mv_cable',      'default:steel_ingot'},
-      }
-})
-
-minetest.register_abm(
-   {nodenames = {"technic:solar_array_mv"},
-    interval   = 1,
-    chance     = 1,
-    action = function(pos, node, active_object_count, active_object_count_wider)
-               -- The action here is to make the solar array produce power
-               -- Power is dependent on the light level and the height above ground
-               -- 130m and above is optimal as it would be above cloud level.
-               -- Height gives 1/4 of the effect, light 3/4. Max. effect is 720EU for the array.
-               -- There are many ways to cheat by using other light sources like lamps.
-               -- As there is no way to determine if light is sunlight that is just a shame.
-               -- To take care of some of it solar panels do not work outside daylight hours or if
-               -- built below -10m
-               local pos1={}
-               pos1.y=pos.y+1
-               pos1.x=pos.x
-               pos1.z=pos.z
-
-               local light = minetest.env:get_node_light(pos1, nil)
-               local time_of_day = minetest.env:get_timeofday()
-               local meta = minetest.env:get_meta(pos)
-               if light == nil then light = 0 end
-               -- turn on array only during day time and if sufficient light
-               -- I know this is counter intuitive when cheating by using other light sources.
-               if light >= 12 and time_of_day>=0.24 and time_of_day<=0.76 and pos.y > -10 then
-                  local charge_to_give = math.floor(light*(light*2.4+pos1.y/130*12))
-                  if charge_to_give<0   then charge_to_give=0 end
-                  if charge_to_give>160 then charge_to_give=160 end
-                  meta:set_string("infotext", "Solar Array is active ("..charge_to_give.."EU)")
-                  --                   meta:set_float("active",1)
-                  meta:set_int("MV_EU_supply", charge_to_give)
-               else
-                  meta:set_string("infotext", "Solar Array is inactive");
-                  meta:set_int("MV_EU_supply", 0)
-               end
-            end,
- }) 
-
-technic.register_MV_machine ("technic:solar_array_mv","PR")
-
diff --git a/technic/solar_panel.lua b/technic/solar_panel.lua
deleted file mode 100644 (file)
index ff3e34a..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
--- Solar panels are the building blocks of LV solar arrays
--- They can however also be used separately but with reduced efficiency due to the missing transformer.
--- Individual panels are 20% less efficient than when the panels are combined into full arrays.
-minetest.register_node("technic:solar_panel", {
-       tiles = {"technic_solar_panel_top.png", "technic_solar_panel_bottom.png", "technic_solar_panel_side.png",
-               "technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       sounds = default.node_sound_wood_defaults(),
-       description="Solar Panel",
-       active = false,
-       drawtype = "nodebox",
-       paramtype = "light",
-       is_ground_content = true,       
-       node_box = {
-                       type = "fixed",
-                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
-               },
-               selection_box = {
-                       type = "fixed",
-                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
-               },
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_int("technic_power_machine", 1)
-               meta:set_int("LV_EU_supply", 0)
-               meta:set_string("infotext", "LV Solar Panel")
-       end,
-})
-
-minetest.register_craft({
-       output = 'technic:solar_panel 1',
-       recipe = {
-               {'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer','technic:doped_silicon_wafer'},
-               {'technic:doped_silicon_wafer', 'technic:lv_cable',           'technic:doped_silicon_wafer'},
-               {'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer','technic:doped_silicon_wafer'},
-
-       }
-})
-
-minetest.register_abm(
-       {nodenames = {"technic:solar_panel"},
-       interval   = 1,
-       chance     = 1,
-       action = function(pos, node, active_object_count, active_object_count_wider)
-               -- The action here is to make the solar panel prodice power
-               -- Power is dependent on the light level and the height above ground
-               -- 130m and above is optimal as it would be above cloud level.
-                -- Height gives 1/4 of the effect, light 3/4. Max. effect is 26EU.
-                -- There are many ways to cheat by using other light sources like lamps.
-                -- As there is no way to determine if light is sunlight that is just a shame.
-                -- To take care of some of it solar panels do not work outside daylight hours or if
-                -- built below -10m
-               local pos1={}
-               pos1.y=pos.y+1
-               pos1.x=pos.x
-               pos1.z=pos.z
-
-               local light = minetest.env:get_node_light(pos1, nil)
-               local time_of_day = minetest.env:get_timeofday()
-               local meta = minetest.env:get_meta(pos)
-               if light == nil then light = 0 end
-               -- turn on panel only during day time and if sufficient light
-                -- I know this is counter intuitive when cheating by using other light sources underground.
-               if light >= 12 and time_of_day>=0.24 and time_of_day<=0.76 and pos.y > -10 then
-                       local charge_to_give=math.floor(light*(light*0.0867+pos1.y/130*0.4333))
-                       if charge_to_give<0 then charge_to_give=0 end
-                       if charge_to_give>26 then charge_to_give=26 end
-                       meta:set_string("infotext", "Solar Panel is active ("..charge_to_give.."EU)")
-                       meta:set_int("LV_EU_supply", charge_to_give)
-               else
-                       meta:set_string("infotext", "Solar Panel is inactive");
-                       meta:set_int("LV_EU_supply", 0)
-               end
-       end,
-}) 
-
-technic.register_LV_machine ("technic:solar_panel","PR")
-
diff --git a/technic/sonic_screwdriver.lua b/technic/sonic_screwdriver.lua
deleted file mode 100644 (file)
index 00922f7..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-local sonic_screwdriver_max_charge=15000
-technic.register_HV_power_tool ("technic:sonic_screwdriver",sonic_screwdriver_max_charge)
-
-minetest.register_tool("technic:sonic_screwdriver", {
-                       description = "Sonic Screwdriver",
-                       inventory_image = "technic_sonic_screwdriver.png",
-                       on_use = function(itemstack, user, pointed_thing)
-                                       -- Must be pointing to facedir applicable node
-                                       if pointed_thing.type~="node" then return end
-                                       local pos=minetest.get_pointed_thing_position(pointed_thing,above)
-                                       local node=minetest.env:get_node(pos)
-                                       local node_name=node.name
-                                               if minetest.registered_nodes[node_name].paramtype2 == "facedir" or minetest.registered_nodes[node_name].paramtype2 == "wallmounted" then
-                                       if node.param2==nil  then return end
-                                       item=itemstack:to_table()
-                                       local meta1=get_item_meta(item["metadata"])
-                                       if meta1==nil then return end --tool not charghed
-                                       if meta1["charge"]==nil then return end
-                                       charge=meta1["charge"]
-                                       if charge-100>0 then
-                                               minetest.sound_play("technic_sonic_screwdriver", {pos = pos, gain = 0.3, max_hear_distance = 10,})
-                                               local n = node.param2
-                                               if minetest.registered_nodes[node_name].paramtype2 == "facedir" then
-                                                  n = n+1
-                                               if n == 4 then n = 0 end
-                                               else
-                                                       n = n+1
-                                                       if n == 6 then n = 0 end
-                                               end
-                                               -- hacky_swap_node, unforunatly.
-                                               local meta = minetest.env:get_meta(pos)
-                                               local meta0 = meta:to_table()
-                                               node.param2 = n
-                                               minetest.env:set_node(pos,node)
-                                               meta = minetest.env:get_meta(pos)
-                                               meta:from_table(meta0)
-
-                                               charge=charge-100;  
-                                               meta1["charge"]=charge
-                                               item["metadata"]=set_item_meta(meta1)
-                                               technic.set_RE_wear(item,charge,sonic_screwdriver_max_charge)
-                                               itemstack:replace(item)
-                                               end
-                                               return itemstack
-                                               else
-                                               return itemstack
-                                               end
-                                               end,
-                
-       })
-minetest.register_craft({
-       output = "technic:sonic_screwdriver",
-       recipe = {
-               {"default:diamond"},
-               {"technic:battery"},
-               {"technic:stainless_steel_ingot"}
-               }
-})
diff --git a/technic/supply_converter.lua b/technic/supply_converter.lua
deleted file mode 100644 (file)
index bee99d2..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
--- The supply converter is a generic device which can convert from
--- LV to MV and back, and HV to MV and back.
--- The machine will not convert from HV directly to LV.
--- The machine is configured by the wiring below and above it.
--- It is prepared for an upgrade slot if this is to be implemented later.
---
--- The conversion factor is a constant and the conversion is a lossy operation.
---
--- It works like this:
---   The top side is setup as the "RE" side, the bottom as the "PR" side.
---   Once the RE side is powered it will deliver power to the other side.
---   Unused power is wasted just like any other producer!
---   
-minetest.register_node(
-   "technic:supply_converter", {
-      description = "Supply Converter",
-      tiles  = {"technic_supply_converter_top.png", "technic_supply_converter_bottom.png", "technic_supply_converter_side.png",
-               "technic_supply_converter_side.png", "technic_supply_converter_side.png", "technic_supply_converter_side.png"},
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-      sounds = default.node_sound_wood_defaults(),
-      drawtype = "nodebox",
-      paramtype = "light",
-      is_ground_content = true,
-      node_box = {
-        type = "fixed",
-        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
-      },
-      selection_box = {
-        type = "fixed",
-        fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
-      },
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       meta:set_float("technic_hv_power_machine", 1)
-                       meta:set_float("technic_mv_power_machine", 1)
-                       meta:set_float("technic_power_machine", 1)
-                       meta:set_string("infotext", "Supply Converter")
-                         meta:set_float("active", false)
-                      end,
-   })
-
-minetest.register_craft({
-       output = 'technic:supply_converter 1',
-       recipe = {
-               {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot','technic:stainless_steel_ingot'},
-               {'technic:mv_transformer',        'technic:mv_cable',             'technic:lv_transformer'},
-               {'technic:mv_cable',              'technic:rubber',               'technic:lv_cable'},
-       }
-})
-
-minetest.register_abm(
-   { nodenames = {"technic:supply_converter"},
-     interval   = 1,
-     chance     = 1,
-     action = function(pos, node, active_object_count, active_object_count_wider)
-                -- Conversion factors (a picture of V*A - loss) Asymmetric.
-                local lv_mv_factor  = 5 -- division (higher is less efficient)
-                local mv_lv_factor  = 4 -- multiplication (higher is more efficient)
-                local mv_hv_factor  = 5 -- division
-                local hv_mv_factor  = 4 -- multiplication
-                local max_lv_demand = 2000 -- The increment size power supply tier. Determines how many are needed
-                local max_mv_demand = 2000 -- -""-
-                local max_hv_demand = 2000 -- -""-
-
-                -- Machine information
-                local machine_name  = "Supply Converter"
-                local meta          = minetest.env:get_meta(pos)
-                local upgrade       = "" -- Replace with expansion slot later??
-                
-                -- High voltage on top, low at bottom regardless of converter direction
-                local pos_up        = {x=pos.x, y=pos.y+1, z=pos.z}
-                local pos_down      = {x=pos.x, y=pos.y-1, z=pos.z}
-                local meta_up       = minetest.env:get_meta(pos_up)
-                local meta_down     = minetest.env:get_meta(pos_down)
-                local convert_MV_LV = 0
-                local convert_LV_MV = 0
-                local convert_MV_HV = 0
-                local convert_HV_MV = 0
-                -- check cabling
-                if meta_up:get_float("mv_cablelike") == 1 and meta_down:get_float("cablelike") == 1 then
-                   convert_MV_LV = 1
-                   upgrade = "MV-LV step down"
-                end
-                if meta_up:get_float("cablelike") == 1 and meta_down:get_float("mv_cablelike") == 1 then
-                   convert_LV_MV = 1
-                   upgrade = "LV-MV step up"
-                end
-                if meta_up:get_float("mv_cablelike") == 1 and meta_down:get_float("hv_cablelike") == 1 then
-                   convert_MV_HV = 1
-                   upgrade = "MV-HV step up"
-                end
-                if meta_up:get_float("hv_cablelike") == 1 and meta_down:get_float("mv_cablelike") == 1 then
-                   convert_HV_MV = 1
-                   upgrade = "HV-MV step down"
-                end
-                --print("Cabling:"..convert_MV_LV.."|"..convert_LV_MV.."|"..convert_HV_MV.."|"..convert_MV_HV)
-
-                if convert_MV_LV == 0 and convert_LV_MV == 0 and convert_HV_MV == 0 and convert_MV_HV == 0 then
-                   meta:set_string("infotext", machine_name.." has bad cabling")
-                   meta:set_int("LV_EU_demand", 0)
-                   meta:set_int("LV_EU_supply", 0)
-                   meta:set_int("LV_EU_input",  0)
-                   meta:set_int("MV_EU_demand", 0)
-                   meta:set_int("MV_EU_supply", 0)
-                   meta:set_int("MV_EU_input",  0)
-                   meta:set_int("HV_EU_demand", 0)
-                   meta:set_int("HV_EU_supply", 0)
-                   meta:set_int("HV_EU_input",  0)
-                   return
-                end
-
-                -- The node is programmed with an upgrade slot
-                -- containing a MV-LV step down, LV-MV step up, HV-MV step down or MV-HV step up unit
-
-                if upgrade == "" then
-                   meta:set_string("infotext", machine_name.." has an empty converter slot");
-                   technic.unregister_LV_machine("technic:supply_converter")
-                   technic.unregister_MV_machine("technic:supply_converter")
-                   technic.unregister_HV_machine("technic:supply_converter")
-                   meta:set_int("LV_EU_demand", 0)
-                   meta:set_int("LV_EU_supply", 0)
-                   meta:set_int("LV_EU_input",  0)
-                   meta:set_int("MV_EU_demand", 0)
-                   meta:set_int("MV_EU_supply", 0)
-                   meta:set_int("MV_EU_input",  0)
-                   meta:set_int("HV_EU_demand", 0)
-                   meta:set_int("HV_EU_supply", 0)
-                   meta:set_int("HV_EU_input",  0)
-                   return
-                end
-
-                -- State machine
-                if upgrade == "MV-LV step down" and convert_MV_LV then
-                   -- Register machine type
-                   technic.register_LV_machine("technic:supply_converter","PR")
-                   technic.register_MV_machine("technic:supply_converter","RE")
-
-                   -- Power off automatically if no longer connected to a switching station
-                   technic.switching_station_timeout_count(pos, "MV")
-
-                   local eu_input  = meta:get_int("MV_EU_input")
-                   if eu_input == 0 then
-                      -- Unpowered - go idle
-                      --hacky_swap_node(pos, machine_node)
-                      meta:set_string("infotext", machine_name.." Unpowered")
-                      meta:set_int("LV_EU_supply", 0)
-                      meta:set_int("MV_EU_supply", 0)
-
-                      meta:set_int("LV_EU_demand", 0)
-                      meta:set_int("MV_EU_demand", max_mv_demand)
-                   else
-                      -- MV side has got power to spare
-                      meta:set_string("infotext", machine_name.." is active (MV:"..max_mv_demand.."->LV:"..eu_input*mv_lv_factor..")");
-                      meta:set_int("LV_EU_supply", eu_input*mv_lv_factor)
-                   end
-                   ---------------------------------------------------
-                elseif upgrade == "LV-MV step up"   and convert_LV_MV then
-                   -- Register machine type
-                   technic.register_LV_machine("technic:supply_converter","RE")
-                   technic.register_MV_machine("technic:supply_converter","PR")
-
-                   -- Power off automatically if no longer connected to a switching station
-                   technic.switching_station_timeout_count(pos, "LV")
-
-                   local eu_input  = meta:get_int("LV_EU_input")
-                   if eu_input == 0 then
-                      -- Unpowered - go idle
-                      --hacky_swap_node(pos, machine_node)
-                      meta:set_string("infotext", machine_name.." Unpowered")
-                      meta:set_int("LV_EU_supply", 0)
-                      meta:set_int("MV_EU_supply", 0)
-
-                      meta:set_int("LV_EU_demand", max_lv_demand)
-                      meta:set_int("MV_EU_demand", 0)
-                   else
-                      -- LV side has got power to spare
-                      meta:set_string("infotext", machine_name.." is active (LV:"..max_lv_demand.."->MV:"..eu_input/lv_mv_factor..")");
-                      meta:set_int("MV_EU_supply", eu_input/lv_mv_factor)
-                   end
-                   ---------------------------------------------------
-
-                elseif upgrade == "HV-MV step down" and convert_HV_MV then
-                   -- Register machine type
-                   technic.register_MV_machine("technic:supply_converter","PR")
-                   technic.register_HV_machine("technic:supply_converter","RE")
-
-                   -- Power off automatically if no longer connected to a switching station
-                   technic.switching_station_timeout_count(pos, "HV")
-
-                   local eu_input  = meta:get_int("HV_EU_input")
-                   if eu_input == 0 then
-                      -- Unpowered - go idle
-                      --hacky_swap_node(pos, machine_node)
-                      meta:set_string("infotext", machine_name.." Unpowered")
-                      meta:set_int("MV_EU_supply", 0)
-                      meta:set_int("HV_EU_supply", 0)
-
-                      meta:set_int("MV_EU_demand", 0)
-                      meta:set_int("HV_EU_demand", max_hv_demand)
-                   else
-                      -- HV side has got power to spare
-                      meta:set_string("infotext", machine_name.." is active (HV:"..max_hv_demand.."->MV:"..eu_input*hv_mv_factor..")");
-                      meta:set_int("MV_EU_supply", eu_input*hv_mv_factor)
-                   end
-                   ---------------------------------------------------
-                elseif upgrade == "MV-HV step up"   and convert_MV_HV then
-                   -- Register machine type
-                   technic.register_MV_machine("technic:supply_converter","RE")
-                   technic.register_HV_machine("technic:supply_converter","PR")
-
-                   -- Power off automatically if no longer connected to a switching station
-                   technic.switching_station_timeout_count(pos, "MV")
-
-                   local eu_input  = meta:get_int("MV_EU_input")
-                   if eu_input == 0 then
-                      -- Unpowered - go idle
-                      --hacky_swap_node(pos, machine_node)
-                      meta:set_string("infotext", machine_name.." Unpowered")
-                      meta:set_int("MV_EU_supply", 0)
-                      meta:set_int("HV_EU_supply", 0)
-
-                      meta:set_int("MV_EU_demand", max_mv_demand)
-                      meta:set_int("HV_EU_demand", 0)
-                   else
-                      -- MV side has got power to spare
-                      meta:set_string("infotext", machine_name.." is active (MV:"..max_mv_demand.."->HV:"..eu_input/mv_hv_factor..")");
-                      meta:set_int("HV_EU_supply", eu_input/mv_hv_factor)
-                   end
-                   ---------------------------------------------------
-                end
-       end,
-})
diff --git a/technic/switching_station.lua b/technic/switching_station.lua
deleted file mode 100644 (file)
index 36133fa..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
--- SWITCHING STATION
--- The switching station is the center of all power distribution on an electric network.
--- The station will collect all produced power from producers (PR) and batteries (BA)
--- and distribute it to receivers (RE) and depleted batteries (BA).
---
--- It works like this:
---  All PR,BA,RE nodes are indexed and tagged with the switching station.
--- The tagging is to allow more stations to be built without allowing a cheat
--- with duplicating power.
---  All the RE nodes are queried for their current EU demand. Those which are off
--- would require no or a small standby EU demand, while those which are on would
--- require more.
--- If the total demand is less than the available power they are all updated with the
--- demand number.
--- If any surplus exists from the PR nodes the batteries will be charged evenly with this.
--- If the total demand requires draw on the batteries they will be discharged evenly.
---
--- If the total demand is more than the available power all RE nodes will be shut down.
--- We have a brown-out situation.
---
--- Hence all the power distribution logic resides in this single node.
---
---  Nodes connected to the network will have one or more of these parameters as meta data:
---   <LV|MV|HV>_EU_supply : Exists for PR and BA node types. This is the EU value supplied by the node. Output
---   <LV|MV|HV>_EU_demand : Exists for RE and BA node types. This is the EU value the node requires to run. Output
---   <LV|MV|HV>_EU_input  : Exists for RE and BA node types. This is the actual EU value the network can give the node. Input
---
---  The reason the LV|MV|HV type is prepended toe meta data is because some machine could require several supplies to work.
---  This way the supplies are separated per network.
-technic.DBG = 1
-local dprint = technic.dprint
-
-minetest.register_craft(
-   {
-      output = 'technic:switching_station 1',
-      recipe = {
-        {'technic:lv_transformer', 'technic:mv_transformer', 'technic:hv_transformer'},
-        {'technic:lv_transformer', 'technic:mv_transformer', 'technic:hv_transformer'},
-        {'technic:lv_cable',       'technic:mv_cable',       'technic:hv_cable'},
-      }
-   })
-
-minetest.register_node(
-   "technic:switching_station",
-   {description = "Switching Station",
-    tiles  = {"technic_water_mill_top_active.png", "technic_water_mill_top_active.png", "technic_water_mill_top_active.png",
-             "technic_water_mill_top_active.png", "technic_water_mill_top_active.png", "technic_water_mill_top_active.png"},
-    groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-    sounds = default.node_sound_wood_defaults(),
-    drawtype = "nodebox",
-    paramtype = "light",
-    is_ground_content = true,
-    node_box = {
-        type = "fixed",
-       fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
-    },
-    selection_box = {
-       type = "fixed",
-       fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
-    },
-    on_construct = function(pos)
-                     local meta = minetest.env:get_meta(pos)
-                     meta:set_string("infotext", "Switching Station")
---                     minetest.chat_send_player(puncher:get_player_name(), "Switching station constructed. Punch the station to shut down the network.");
---                     meta:set_int("active", 1)
-                  end,
---      on_punch = function(pos, node, puncher)
---                 local meta   = minetest.env:get_meta(pos)
---                 local active = meta:get_int("active")
---                 if active == 1 then
---                    meta:set_int("active", 0)
---                    minetest.chat_send_player(puncher:get_player_name(), "Electrical network shut down. Punch again to turn it on.");
---                 else
---                    meta:set_int("active", 1)
---                    minetest.chat_send_player(puncher:get_player_name(), "Electrical network turned on. Punch again to shut it down.");
---                 end
---              end
- })
-
---------------------------------------------------
--- Functions to help the machines on the electrical network
---------------------------------------------------
--- This one provides a timeout for a node in case it was disconnected from the network
--- A node must be touched by the station continuously in order to function
-technic.switching_station_timeout_count = function(pos, machine_tier)
-                                            local meta = minetest.env:get_meta(pos)
-                                            timeout =  meta:get_int(machine_tier.."_EU_timeout")
-                                            --print("Counting timeout "..timeout)
-                                            if timeout == 0 then
-                                               --print("OFF")
-                                               meta:set_int(machine_tier.."_EU_input", 0)
-                                            else
-                                               --print("ON")
-                                               meta:set_int(machine_tier.."_EU_timeout", timeout-1)
-                                            end
-                                         end
-
---------------------------------------------------
--- Functions to traverse the electrical network
---------------------------------------------------
-
--- Add a wire node to the LV/MV/HV network
-local add_new_cable_node = function(nodes,pos)
-                             local i = 1
-                             repeat
-                                if nodes[i]==nil then break end
-                                if pos.x==nodes[i].x and pos.y==nodes[i].y and pos.z==nodes[i].z then return false end
-                                i=i+1
-                             until false
-                             nodes[i] = {x=pos.x, y=pos.y, z=pos.z, visited=1} -- copy position
-                             return true
-                          end
-
--- Generic function to add found connected nodes to the right classification array
-local check_node_subp = function(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos,machines,cablename)
-                          local meta = minetest.env:get_meta(pos)
-                          local name = minetest.env:get_node(pos).name
-                          if meta:get_float(cablename)==1 then
-                             add_new_cable_node(all_nodes,pos)
-                          elseif machines[name] then
-                             --dprint(name.." is a "..machines[name])
-                             if     machines[name] == "PR" then
-                                add_new_cable_node(PR_nodes,pos)
-                             elseif machines[name] == "RE" then
-                                add_new_cable_node(RE_nodes,pos)
-                             elseif machines[name] == "BA" then
-                                add_new_cable_node(BA_nodes,pos)
-                             end
-                             if cablename == "cablelike" then
-                                meta:set_int("LV_EU_timeout", 2) -- Touch node
-                             elseif cablename == "mv_cablelike" then
-                                meta:set_int("MV_EU_timeout", 2) -- Touch node
-                             elseif cablename == "hv_cablelike" then
-                                meta:set_int("HV_EU_timeout", 2) -- Touch node
-                             end
-                          end
-                       end
-
--- Traverse a network given a list of machines and a cable type name
-local traverse_network = function(PR_nodes,RE_nodes,BA_nodes,all_nodes, i, machines, cablename)
-                           local pos = {x=all_nodes[i].x, y=all_nodes[i].y, z=all_nodes[i].z} -- copy position
-                           pos.x=pos.x+1
-                           check_node_subp(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos, machines, cablename)
-                           pos.x=pos.x-2
-                           check_node_subp(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos, machines, cablename)
-                           pos.x=pos.x+1
-                           
-                           pos.y=pos.y+1
-                           check_node_subp(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos, machines, cablename)
-                           pos.y=pos.y-2
-                           check_node_subp(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos, machines, cablename)
-                           pos.y=pos.y+1
-                           
-                           pos.z=pos.z+1
-                           check_node_subp(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos, machines, cablename)
-                           pos.z=pos.z-2
-                           check_node_subp(PR_nodes,RE_nodes,BA_nodes,all_nodes,pos, machines, cablename)
-                           pos.z=pos.z+1
-                     end
-
-----------------------------------------------
--- The action code for the switching station
-----------------------------------------------
-minetest.register_abm(
-       {nodenames = {"technic:switching_station"},
-       interval   = 1,
-       chance     = 1,
-       action = function(pos, node, active_object_count, active_object_count_wider)
-                   local meta             = minetest.env:get_meta(pos)
-                   local meta1            = nil
-                   local pos1             = {}
-                   local PR_EU            = 0 -- EUs from PR nodes
-                   local BA_PR_EU         = 0 -- EUs from BA nodes (discharching)
-                   local BA_RE_EU         = 0 -- EUs to BA nodes (charging)
-                   local RE_EU            = 0 -- EUs to RE nodes
-
-                   local network   = ""
-                   local all_nodes = {}
-                   local PR_nodes  = {}
-                   local BA_nodes  = {} 
-                   local RE_nodes  = {}
-
---                 -- Possible to turn off the entire network
---                 if meta:get_int("active") == 0 then
---                    for _,pos1 in pairs(RE_nodes) do
---                       meta1  = minetest.env:get_meta(pos1)
---                       meta1:set_int("EU_input", 0)
---                    end
---                    for _,pos1 in pairs(BA_nodes) do
---                       meta1  = minetest.env:get_meta(pos1)
---                       meta1:set_int("EU_input", 0)
---                    end
---                    return
---                 end
-
-                   -- Which kind of network are we on:
-                   pos1 = {x=pos.x, y=pos.y-1, z=pos.z}
-                   all_nodes[1] = pos1
-
-                   meta1  = minetest.env:get_meta(pos1)
-                   if meta1:get_float("cablelike") ==1 then
-                      -- LV type
-                      --dprint("LV type")
-                      network = "LV"
-                      local table_index = 1
-                      repeat
-                         traverse_network(PR_nodes,RE_nodes,BA_nodes,all_nodes,table_index, technic.LV_machines, "cablelike")
-                         table_index = table_index + 1
-                         if all_nodes[table_index] == nil then break end
-                      until false
-                   elseif meta1:get_float("mv_cablelike") ==1 then
-                      -- MV type
-                      --dprint("MV type")
-                      network = "MV"
-                      local table_index = 1
-                      repeat
-                         traverse_network(PR_nodes,RE_nodes,BA_nodes,all_nodes,table_index, technic.MV_machines, "mv_cablelike")
-                         table_index = table_index + 1
-                         if all_nodes[table_index] == nil then break end
-                      until false
-                   elseif meta1:get_float("hv_cablelike") ==1 then
-                      -- HV type
-                      --dprint("HV type")
-                      network = "HV"
-                      local table_index = 1
-                      repeat
-                         traverse_network(PR_nodes,RE_nodes,BA_nodes,all_nodes,table_index, technic.HV_machines, "hv_cablelike")
-                         table_index = table_index + 1
-                         if all_nodes[table_index] == nil then break end
-                      until false
-                   else
-                      -- No type :-)
-                      --dprint("Not connected to a network")
-                      meta:set_string("infotext", "Switching Station - no network")
-                      return
-                   end
-                   --dprint("nodes="..table.getn(all_nodes).." PR="..table.getn(PR_nodes).." BA="..table.getn(BA_nodes).." RE="..table.getn(RE_nodes))
-
-                   -- Strings for the meta data
-                   local eu_demand_str    = network.."_EU_demand"
-                   local eu_input_str     = network.."_EU_input"
-                   local eu_supply_str    = network.."_EU_supply"
-                   local eu_from_fuel_str = network.."_EU_from_fuel"
-
-                   -- Get all the power from the PR nodes
-                   local PR_eu_supply = 0 -- Total power
-                   for _,pos1 in pairs(PR_nodes) do
-                      meta1  = minetest.env:get_meta(pos1)
-                      PR_eu_supply = PR_eu_supply + meta1:get_int(eu_supply_str)
-                   end
-                   --dprint("Total PR supply:"..PR_eu_supply)
-
-                   -- Get all the demand from the RE nodes
-                   local RE_eu_demand = 0
-                   for _,pos1 in pairs(RE_nodes) do
-                      meta1  = minetest.env:get_meta(pos1)
-                      RE_eu_demand = RE_eu_demand + meta1:get_int(eu_demand_str)
-                   end
-                   --dprint("Total RE demand:"..RE_eu_demand)
-
-                   -- Get all the power from the BA nodes
-                   local BA_eu_supply = 0
-                   for _,pos1 in pairs(BA_nodes) do
-                      meta1  = minetest.env:get_meta(pos1)
-                      BA_eu_supply = BA_eu_supply + meta1:get_int(eu_supply_str)
-                   end
-                   --dprint("Total BA supply:"..BA_eu_supply)
-
-                   -- Get all the demand from the BA nodes
-                   local BA_eu_demand = 0
-                   for _,pos1 in pairs(BA_nodes) do
-                      meta1  = minetest.env:get_meta(pos1)
-                      BA_eu_demand = BA_eu_demand + meta1:get_int(eu_demand_str)
-                   end
-                   --dprint("Total BA demand:"..BA_eu_demand)
-
-                   meta:set_string("infotext", "Switching Station. PR("..(PR_eu_supply+BA_eu_supply)..") RE("..(RE_eu_demand+BA_eu_demand)..")")
-
-                   -- If the PR supply is enough for the RE demand supply them all
-                   if PR_eu_supply >= RE_eu_demand then
-                      --dprint("PR_eu_supply"..PR_eu_supply.." >= RE_eu_demand"..RE_eu_demand)
-                      for _,pos1 in pairs(RE_nodes) do
-                         meta1  = minetest.env:get_meta(pos1)
-                         local eu_demand = meta1:get_int(eu_demand_str)
-                         meta1:set_int(eu_input_str, eu_demand)
-                      end
-                      -- We have a surplus, so distribute the rest equally to the BA nodes
-                      -- Let's calculate the factor of the demand
-                      PR_eu_supply = PR_eu_supply - RE_eu_demand
-                      local charge_factor = 0 -- Assume all batteries fully charged
-                      if BA_eu_demand > 0 then
-                         charge_factor = PR_eu_supply / BA_eu_demand
-                      end
-                      for n,pos1 in pairs(BA_nodes) do
-                         meta1  = minetest.env:get_meta(pos1)
-                         local eu_demand = meta1:get_int(eu_demand_str)
-                         meta1:set_int(eu_input_str, math.floor(eu_demand*charge_factor))
-                         --dprint("Charging battery:"..math.floor(eu_demand*charge_factor))
-                      end
-                      -- If still a surplus we can start giving back to the fuel burning generators
-                      -- Only full EU packages are given back. The rest is wasted.
-                      if BA_eu_demand == 0 then
-                         for _,pos1 in pairs(PR_nodes) do
-                            meta1  = minetest.env:get_meta(pos1)
-                            if meta1:get_int(eu_from_fuel_str) == 1 then
-                               local eu_supply = meta1:get_int(eu_supply_str)
-                               if PR_eu_supply < eu_supply then
-                                  break
-                               else
-                                  -- Set the supply to 0 if we did not require it.
-                                  meta1:set_int(eu_supply_str, 0)
-                                  PR_eu_supply = PR_eu_supply - eu_supply
-                               end
-                            end
-                         end
-                      end
-                      return
-                   end
-
-                   -- If the PR supply is not enough for the RE demand we will discharge the batteries too
-                   if PR_eu_supply+BA_eu_supply >= RE_eu_demand then
-                      --dprint("PR_eu_supply "..PR_eu_supply.."+BA_eu_supply "..BA_eu_supply.." >= RE_eu_demand"..RE_eu_demand)
-                      for _,pos1 in pairs(RE_nodes) do
-                         meta1  = minetest.env:get_meta(pos1)
-                         local eu_demand = meta1:get_int(eu_demand_str)
-                         meta1:set_int(eu_input_str, eu_demand)
-                      end
-                      -- We have a deficit, so distribute to the BA nodes
-                      -- Let's calculate the factor of the supply
-                      local charge_factor = 0 -- Assume all batteries depleted
-                      if BA_eu_supply > 0 then
-                         charge_factor = (PR_eu_supply - RE_eu_demand) / BA_eu_supply
-                      end
-                      for n,pos1 in pairs(BA_nodes) do
-                         meta1  = minetest.env:get_meta(pos1)
-                         local eu_supply = meta1:get_int(eu_supply_str)
-                         meta1:set_int(eu_input_str, math.floor(eu_supply*charge_factor))
-                         --dprint("Discharging battery:"..math.floor(eu_supply*charge_factor))
-                      end
-                      return
-                   end
-
-                   -- If the PR+BA supply is not enough for the RE demand: Shut everything down!
-                   -- Note: another behaviour could also be imagined: provide the average power for all and let the node decide what happens.
-                   -- This is much simpler though: Not enough power for all==no power for all
-                   --print("NO POWER")
-                   for _,pos1 in pairs(RE_nodes) do
-                      meta1  = minetest.env:get_meta(pos1)
-                      meta1:set_int(eu_input_str, 0)
-                   end
-       end,
-})
diff --git a/technic/tetris.lua b/technic/tetris.lua
deleted file mode 100644 (file)
index 3b14c47..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-minetest.register_node("technic:tetris_machine_node1", {
-       tiles = {"tetris_machine_top.png", "technic_mv_battery_box_bottom.png", "tetris_machine_front1.png",
-               "tetris_machine_side1B.png", "tetris_machine_side1P.png", "tetris_machine_side1L.png"},
-       tile_images = {"technic_tetris_machine.png",},
-       is_ground_content = true,
-       groups = {cracky=1},
-       sounds = default.node_sound_stone_defaults(),
-})
-
-minetest.register_node("technic:tetris_machine_node2", {
-       tiles = {"tetris_machine_top.png", "technic_mv_battery_box_bottom.png", "tetris_machine_front2.png",
-               "tetris_machine_side2B.png", "tetris_machine_side2P.png", "tetris_machine_side2L.png"},
-       tile_images = {"technic_tetris_machine.png",},
-       is_ground_content = true,
-       groups = {cracky=1},
-       sounds = default.node_sound_stone_defaults(),
-})
diff --git a/technic/tool_workshop.lua b/technic/tool_workshop.lua
deleted file mode 100644 (file)
index 52cd044..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
--- LV Tool workshop
--- This machine repairs tools.
-minetest.register_alias("tool_workshop", "technic:tool_workshop")
-minetest.register_craft({
-       output = 'technic:tool_workshop',
-       recipe = {
-               {'default:wood', 'default:wood', 'default:wood'},
-               {'default:wood', 'default:diamond', 'default:wood'},
-               {'default:stone', 'default:copper_ingot', 'default:stone'},
-       }
-})
-
-minetest.register_craftitem("technic:tool_workshop", {
-       description = "Tool Workshop",
-       stack_max = 99,
-}) 
-
-local workshop_formspec =
-   "invsize[8,9;]"..
-   "list[current_name;src;3,1;1,1;]"..
-   "label[0,0;Tool Workshop]"..
-   "list[current_player;main;0,5;8,4;]"
-
-minetest.register_node(
-   "technic:tool_workshop",
-   {
-      description = "Tool Workshop",
-      tiles = {"technic_workshop_top.png", "technic_machine_bottom.png", "technic_workshop_side.png",
-              "technic_workshop_side.png", "technic_workshop_side.png", "technic_workshop_side.png"},
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-      sounds = default.node_sound_wood_defaults(),
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       meta:set_string("infotext", "Tool Workshop")
-                       meta:set_float("technic_power_machine", 1)
-                       meta:set_string("formspec", workshop_formspec)
-                       local inv = meta:get_inventory()
-                       inv:set_size("src", 1)
-                    end,       
-      can_dig = function(pos,player)
-                  local meta = minetest.env:get_meta(pos);
-                  local inv = meta:get_inventory()
-                  if not inv:is_empty("src") then
-                     minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
-                     return false
-                  end
-                  return true
-               end,
-   })
-
-minetest.register_abm(
-   { nodenames = {"technic:tool_workshop"},
-     interval = 1,
-     chance   = 1,
-     action = function(pos, node, active_object_count, active_object_count_wider)
-                local meta         = minetest.env:get_meta(pos)
-                local eu_input     = meta:get_int("LV_EU_input")
-                local state        = meta:get_int("state")
-                local next_state   = state
-
-                -- Machine information
-                local machine_name         = "Tool Workshop"
-                local machine_node         = "technic:tool_workshop"
-                local machine_state_demand = { 50, 150 }
-                        
-                -- Setup meta data if it does not exist. state is used as an indicator of this
-                if state == 0 then
-                   meta:set_int("state", 1)
-                   meta:set_int("LV_EU_demand", machine_state_demand[1])
-                   meta:set_int("LV_EU_input", 0)
-                   return
-                end
-                        
-                -- Power off automatically if no longer connected to a switching station
-                technic.switching_station_timeout_count(pos, "LV")
-                        
-                -- State machine
-                if eu_input == 0 then
-                   -- Unpowered - go idle
-                   --hacky_swap_node(pos, machine_node)
-                   meta:set_string("infotext", machine_name.." Unpowered")
-                   next_state = 1
-                elseif eu_input == machine_state_demand[state] then
-                   -- Powered - do the state specific actions
-                   local inv = meta:get_inventory()
-                           
-                   if state == 1 then
-                      --hacky_swap_node(pos, machine_node)
-                      meta:set_string("infotext", machine_name.." Idle")
-                      if not inv:is_empty("src") then
-                         next_state = 2
-                      end
-                   elseif state == 2 then
-                      --hacky_swap_node(pos, machine_node.."_active")
-                      meta:set_string("infotext", machine_name.." Active")
-
-                      if inv:is_empty("src") then
-                         next_state = 1
-                      else
-                         srcstack = inv:get_stack("src", 1)
-                         src_item=srcstack:to_table()
-                         -- Cannot charge cans
-                         if (src_item["name"]=="technic:water_can" or src_item["name"]=="technic:lava_can") then
-                            return
-                         end
-                         local wear=tonumber(src_item["wear"])
-                         wear = math.max(1, wear-2000) -- Improve the tool this much every tick
-                         src_item["wear"]=tostring(wear)
-                         inv:set_stack("src", 1, src_item)
-                      end
-                   end
-                end
-                -- Change state?
-                if next_state ~= state then
-                   meta:set_int("LV_EU_demand", machine_state_demand[next_state])
-                   meta:set_int("state", next_state)
-                end
-             end
-   }) 
-
-technic.register_LV_machine ("technic:tool_workshop","RE")
-
diff --git a/technic/tools/cans.lua b/technic/tools/cans.lua
new file mode 100644 (file)
index 0000000..6a98ce9
--- /dev/null
@@ -0,0 +1,120 @@
+local water_can_max_load = 16
+local lava_can_max_load = 8
+
+minetest.register_craft({
+       output = 'technic:water_can 1',
+       recipe = {
+               {'technic:zinc_ingot', 'technic:rubber','technic:zinc_ingot'},
+               {'default:steel_ingot', '', 'default:steel_ingot'},
+               {'technic:zinc_ingot', 'default:steel_ingot', 'technic:zinc_ingot'},
+       }
+})
+
+minetest.register_craft({
+       output = 'technic:lava_can 1',
+       recipe = {
+               {'technic:zinc_ingot', 'technic:stainless_steel_ingot','technic:zinc_ingot'},
+               {'technic:stainless_steel_ingot', '', 'technic:stainless_steel_ingot'},
+               {'technic:zinc_ingot', 'technic:stainless_steel_ingot', 'technic:zinc_ingot'},
+       }
+})
+
+
+minetest.register_tool("technic:water_can", {
+       description = "Water Can",
+       inventory_image = "technic_water_can.png",
+       stack_max = 1,
+       liquids_pointable = true,
+       on_use = function(itemstack, user, pointed_thing)
+               
+               if pointed_thing.type ~= "node" then
+                                       return end
+               n = minetest.env:get_node(pointed_thing.under)
+               
+               item=itemstack:to_table()
+               local load=nil
+               if item["metadata"]=="" then load=0 
+               else load=tonumber(item["metadata"]) 
+               end
+               
+               if n.name == "default:water_source" then
+                       if load+1<17 then
+                       minetest.env:add_node(pointed_thing.under, {name="air"})
+                        load=load+1;   
+                       item["metadata"]=tostring(load)
+                       technic.set_RE_wear(item,load,water_can_max_load)
+                       itemstack:replace(item)
+                       end
+                       return itemstack
+               end
+               item=itemstack:to_table()
+               if load==0 then return end
+                       
+               if n.name == "default:water_flowing" then
+                       minetest.env:add_node(pointed_thing.under, {name="default:water_source"})
+                       load=load-1;    
+                       item["metadata"]=tostring(load)
+                       technic.set_RE_wear(item,load,water_can_max_load)
+                       itemstack:replace(item)
+                       return itemstack
+                       end
+
+               n = minetest.env:get_node(pointed_thing.above)
+               if n.name == "air" then
+                       minetest.env:add_node(pointed_thing.above, {name="default:water_source"})
+                       load=load-1;    
+                       item["metadata"]=tostring(load)
+                       technic.set_RE_wear(item,load,water_can_max_load)
+                       itemstack:replace(item)
+                       return itemstack
+                       end             
+       end,
+})
+
+minetest.register_tool("technic:lava_can", {
+       description = "Lava Can",
+       inventory_image = "technic_lava_can.png",
+       stack_max = 1,
+       liquids_pointable = true,
+       on_use = function(itemstack, user, pointed_thing)
+               if pointed_thing.type ~= "node" then return end
+               n = minetest.env:get_node(pointed_thing.under)
+               item=itemstack:to_table()
+               local load=nil
+               if item["metadata"]=="" then load=0 
+               else load=tonumber(item["metadata"]) 
+               end
+               
+               if n.name == "default:lava_source" then
+                       if load+1<17 then
+                       minetest.env:add_node(pointed_thing.under, {name="air"})
+                        load=load+1;
+                       item["metadata"]=tostring(load)
+                       technic.set_RE_wear(item,load,lava_can_max_load)
+                       itemstack:replace(item)
+                       end
+                       return itemstack
+               end
+               item=itemstack:to_table()
+               if load==0 then return end
+                       
+               if n.name == "default:lava_flowing" then
+                       minetest.env:add_node(pointed_thing.under, {name="default:lava_source"})
+                       load=load-1;    
+                       item["metadata"]=tostring(load)
+                       technic.set_RE_wear(item,load,lava_can_max_load)
+                       itemstack:replace(item)
+                       return itemstack
+                       end
+
+               n = minetest.env:get_node(pointed_thing.above)
+               if n.name == "air" then
+                       minetest.env:add_node(pointed_thing.above, {name="default:lava_source"})
+                       load=load-1;    
+                       item["metadata"]=tostring(load)
+                       technic.set_RE_wear(item,load,lava_can_max_load)
+                       itemstack:replace(item)
+                       return itemstack
+                       end     
+       end,
+})
diff --git a/technic/tools/chainsaw.lua b/technic/tools/chainsaw.lua
new file mode 100644 (file)
index 0000000..ae0c30c
--- /dev/null
@@ -0,0 +1,269 @@
+-- Configuration
+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)
+
+minetest.register_tool("technic:chainsaw", {
+        description = "Chainsaw",
+        inventory_image = "technic_chainsaw.png",
+        stack_max = 1,
+        on_use = function(itemstack, user, pointed_thing)
+                if pointed_thing.type=="node" then
+                        item=itemstack:to_table()
+                        local meta=get_item_meta(item["metadata"])
+                        if meta==nil then return end --tool not charged
+                        if meta["charge"]==nil then return end
+                        -- Send current charge to digging function so that the chainsaw will stop after digging a number of nodes.
+                        local charge=meta["charge"]
+                        if charge < chainsaw_charge_per_node then return end -- only cut if charged
+
+                        charge=chainsaw_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,charge)
+                        technic.set_RE_wear(item,charge,chainsaw_max_charge)
+                        meta["charge"]=charge
+                        item["metadata"]=set_item_meta(meta)
+                        itemstack:replace(item)
+                        return itemstack
+                end
+        end,
+})
+
+minetest.register_craft({
+        output = 'technic:chainsaw',
+        recipe = {
+                {'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:battery'},
+                {'technic:stainless_steel_ingot', 'technic:motor',                 'technic:battery'},
+                {'',                               '',                             'default:copper_ingot'},
+        }
+})
+
+-- The default stuff
+local timber_nodenames={["default:jungletree"] = true,
+                        ["default:papyrus"]    = true,
+                        ["default:cactus"]     = true,
+                        ["default:tree"]       = true,
+                        ["default:apple"]      = true
+}
+
+if chainsaw_leaves == true then
+        timber_nodenames["default:leaves"] = true
+end
+
+-- Support moretrees if it is there
+if( minetest.get_modpath("moretrees") ~= nil ) then
+        timber_nodenames["moretrees:apple_tree_trunk"]                 = true
+        timber_nodenames["moretrees:apple_tree_trunk_sideways"]        = true
+        timber_nodenames["moretrees:beech_trunk"]                      = true
+        timber_nodenames["moretrees:beech_trunk_sideways"]             = true
+        timber_nodenames["moretrees:birch_trunk"]                      = true
+        timber_nodenames["moretrees:birch_trunk_sideways"]             = true
+        timber_nodenames["moretrees:fir_trunk"]                        = true
+        timber_nodenames["moretrees:fir_trunk_sideways"]               = true
+        timber_nodenames["moretrees:oak_trunk"]                        = true
+        timber_nodenames["moretrees:oak_trunk_sideways"]               = true
+        timber_nodenames["moretrees:palm_trunk"]                       = true
+        timber_nodenames["moretrees:palm_trunk_sideways"]              = true
+        timber_nodenames["moretrees:pine_trunk"]                       = true
+        timber_nodenames["moretrees:pine_trunk_sideways"]              = true
+        timber_nodenames["moretrees:rubber_tree_trunk"]                = true
+        timber_nodenames["moretrees:rubber_tree_trunk_sideways"]       = true
+        timber_nodenames["moretrees:rubber_tree_trunk_empty"]          = true
+        timber_nodenames["moretrees:rubber_tree_trunk_sideways_empty"] = true
+        timber_nodenames["moretrees:sequoia_trunk"]                    = true
+        timber_nodenames["moretrees:sequoia_trunk_sideways"]           = true
+        timber_nodenames["moretrees:spruce_trunk"]                     = true
+        timber_nodenames["moretrees:spruce_trunk_sideways"]            = true
+        timber_nodenames["moretrees:willow_trunk"]                     = true
+        timber_nodenames["moretrees:willow_trunk_sideways"]            = true
+        timber_nodenames["moretrees:jungletree_trunk"]                 = true
+        timber_nodenames["moretrees:jungletree_trunk_sideways"]        = true
+
+        if chainsaw_leaves == true then
+                timber_nodenames["moretrees:apple_tree_leaves"]        = true
+                timber_nodenames["moretrees:oak_leaves"]               = true
+                timber_nodenames["moretrees:sequoia_leaves"]           = true
+                timber_nodenames["moretrees:birch_leaves"]             = true
+                timber_nodenames["moretrees:birch_leaves"]             = true
+                timber_nodenames["moretrees:palm_leaves"]              = true
+                timber_nodenames["moretrees:spruce_leaves"]            = true
+                timber_nodenames["moretrees:spruce_leaves"]            = true
+                timber_nodenames["moretrees:pine_leaves"]              = true
+                timber_nodenames["moretrees:willow_leaves"]            = true
+                timber_nodenames["moretrees:rubber_tree_leaves"]       = true
+                timber_nodenames["moretrees:jungletree_leaves_green"]  = true
+                timber_nodenames["moretrees:jungletree_leaves_yellow"] = true
+                timber_nodenames["moretrees:jungletree_leaves_red"]    = true
+        end
+end
+
+-- Support growing_trees if it is there
+if( minetest.get_modpath("growing_trees") ~= nil ) then
+        timber_nodenames["growing_trees:trunk"]         = true
+        timber_nodenames["growing_trees:medium_trunk"]  = true
+        timber_nodenames["growing_trees:big_trunk"]     = true
+        timber_nodenames["growing_trees:trunk_top"]     = true
+        timber_nodenames["growing_trees:trunk_sprout"]  = true
+        timber_nodenames["growing_trees:branch_sprout"] = true
+        timber_nodenames["growing_trees:branch"]        = true
+        timber_nodenames["growing_trees:branch_xmzm"]   = true
+        timber_nodenames["growing_trees:branch_xpzm"]   = true
+        timber_nodenames["growing_trees:branch_xmzp"]   = true
+        timber_nodenames["growing_trees:branch_xpzp"]   = true
+        timber_nodenames["growing_trees:branch_zz"]     = true
+        timber_nodenames["growing_trees:branch_xx"]     = true
+
+        if chainsaw_leaves == true then
+                timber_nodenames["growing_trees:leaves"] = true
+        end
+end
+
+-- Support growing_cactus if it is there
+if( minetest.get_modpath("growing_cactus") ~= nil ) then
+        timber_nodenames["growing_cactus:sprout"]                       = true
+        timber_nodenames["growing_cactus:branch_sprout_vertical"]       = true
+        timber_nodenames["growing_cactus:branch_sprout_vertical_fixed"] = true
+        timber_nodenames["growing_cactus:branch_sprout_xp"]             = true
+        timber_nodenames["growing_cactus:branch_sprout_xm"]             = true
+        timber_nodenames["growing_cactus:branch_sprout_zp"]             = true
+        timber_nodenames["growing_cactus:branch_sprout_zm"]             = true
+        timber_nodenames["growing_cactus:trunk"]                        = true
+        timber_nodenames["growing_cactus:branch_trunk"]                 = true
+        timber_nodenames["growing_cactus:branch"]                       = true
+        timber_nodenames["growing_cactus:branch_xp"]                    = true
+        timber_nodenames["growing_cactus:branch_xm"]                    = true
+        timber_nodenames["growing_cactus:branch_zp"]                    = true
+        timber_nodenames["growing_cactus:branch_zm"]                    = true
+        timber_nodenames["growing_cactus:branch_zz"]                    = true
+        timber_nodenames["growing_cactus:branch_xx"]                    = true
+end
+
+-- Support farming_plus if it is there
+if( minetest.get_modpath("farming_plus") ~= nil ) then
+   if chainsaw_leaves == true then
+      timber_nodenames["farming_plus:cocoa_leaves"] = true
+   end
+end
+
+-- Table for saving what was sawed down
+local produced
+
+-- Saw down trees entry point
+chainsaw_dig_it = function(pos, player,current_charge)
+        local remaining_charge=current_charge
+
+        -- Save the currently installed dropping mechanism so we can restore it.
+       local original_handle_node_drops = minetest.handle_node_drops
+
+        -- A bit of trickery here: use a different node drop callback
+        -- and restore the original afterwards.
+        minetest.handle_node_drops = chainsaw_handle_node_drops
+
+        -- clear result and start sawing things down
+        produced = {}
+        remaining_charge = recursive_dig(pos, remaining_charge, player)
+        minetest.sound_play("chainsaw", {pos = pos, gain = 1.0, max_hear_distance = 10,})
+
+        -- Restore the original noder drop handler
+        minetest.handle_node_drops = original_handle_node_drops
+
+        -- Now drop items for the player
+        local number, produced_item, p
+        for produced_item,number in pairs(produced) do
+                --print("ADDING ITEM: " .. produced_item .. " " .. number)
+                -- Drop stacks of 99 or less
+                p = {
+                        x = pos.x + math.random()*4,
+                        y = pos.y,
+                        z = pos.z + math.random()*4
+                }
+                while number > 99 do
+                        minetest.env:add_item(p, produced_item .. " 99")
+                        p = {
+                                x = pos.x + math.random()*4,
+                                y = pos.y,
+                                z = pos.z + math.random()*4
+                        }
+                        number = number - 99
+                end
+                minetest.env:add_item(p, produced_item .. " " .. number)
+        end
+        return remaining_charge
+end
+
+-- Override the default handling routine to be able to count up the
+-- items sawed down so that we can drop them i an nice single stack
+chainsaw_handle_node_drops = function(pos, drops, digger)
+        -- Add dropped items to list of collected nodes
+        local _, dropped_item
+        for _, dropped_item in ipairs(drops) do
+                if produced[dropped_item] == nil then
+                        produced[dropped_item] = 1
+                else
+                        produced[dropped_item] = produced[dropped_item] + 1
+                end
+        end
+end
+
+-- This function does all the hard work. Recursively we dig the node at hand
+-- if it is in the table and then search the surroundings for more stuff to dig.
+recursive_dig = function(pos, remaining_charge, player)
+        local node=minetest.env:get_node(pos)
+        local i=1
+        -- Lookup node name in timber table:
+        if timber_nodenames[node.name] ~= nil then
+                -- Return if we are out of power
+                if remaining_charge < chainsaw_charge_per_node then
+                        return 0
+                end
+                local np
+                -- wood found - cut it.
+                minetest.env:dig_node(pos)
+
+                remaining_charge=remaining_charge-chainsaw_charge_per_node
+                -- check surroundings and run recursively if any charge left
+                np={x=pos.x+1, y=pos.y, z=pos.z}
+                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
+                        remaining_charge = recursive_dig(np, remaining_charge)
+                end
+                np={x=pos.x+1, y=pos.y, z=pos.z+1}
+                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
+                        remaining_charge = recursive_dig(np, remaining_charge)
+                end
+                np={x=pos.x+1, y=pos.y, z=pos.z-1}
+                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
+                        remaining_charge = recursive_dig(np, remaining_charge)
+                end
+
+                np={x=pos.x-1, y=pos.y, z=pos.z}
+                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
+                        remaining_charge = recursive_dig(np, remaining_charge)
+                end
+                np={x=pos.x-1, y=pos.y, z=pos.z+1}
+                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
+                        remaining_charge = recursive_dig(np, remaining_charge)
+                end
+                np={x=pos.x-1, y=pos.y, z=pos.z-1}
+                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
+                        remaining_charge = recursive_dig(np, remaining_charge)
+                end
+
+                np={x=pos.x, y=pos.y+1, z=pos.z}
+                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
+                        remaining_charge = recursive_dig(np, remaining_charge)
+                end
+
+                np={x=pos.x, y=pos.y, z=pos.z+1}
+                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
+                        remaining_charge = recursive_dig(np, remaining_charge)
+                end
+                np={x=pos.x, y=pos.y, z=pos.z-1}
+                if timber_nodenames[minetest.env:get_node(np).name] ~= nil then
+                        remaining_charge = recursive_dig(np, remaining_charge)
+                end
+                return remaining_charge
+        end
+        -- Nothing sawed down
+        return remaining_charge
+end
+
diff --git a/technic/tools/flashlight.lua b/technic/tools/flashlight.lua
new file mode 100644 (file)
index 0000000..5f3ea96
--- /dev/null
@@ -0,0 +1,174 @@
+-- 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)
+      
+minetest.register_tool("technic:flashlight", {
+       description = "Flashlight",
+       inventory_image = "technic_flashlight.png",
+       stack_max = 1,
+       on_use = function(itemstack, user, pointed_thing)
+       end,
+       })
+minetest.register_craft({
+output = "technic:flashlight",
+recipe = {
+       {"technic:rubber","glass","technic:rubber"},
+       {"technic:stainless_steel_ingot","technic:battery","technic:stainless_steel_ingot"},
+       {"","technic:battery",""}
+       }
+})
+
+local players = {}
+local player_positions = {}
+local last_wielded = {}
+
+function round(num) 
+       return math.floor(num + 0.5) 
+end
+
+minetest.register_on_joinplayer(function(player)
+       local player_name = player:get_player_name()
+       table.insert(players, player_name)
+       local pos = player:getpos()
+       local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
+       player_positions[player_name] = {}
+       player_positions[player_name]["x"] = rounded_pos.x;
+       player_positions[player_name]["y"] = rounded_pos.y;
+       player_positions[player_name]["z"] = rounded_pos.z;
+end)
+
+minetest.register_on_leaveplayer(function(player)
+       local player_name = player:get_player_name()
+       for i,v in ipairs(players) do
+               if v == player_name then 
+                       table.remove(players, i)
+                       last_wielded[player_name] = nil
+                       -- Neuberechnung des Lichts erzwingen
+                       local pos = player:getpos()
+                       local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
+                       minetest.env:add_node(rounded_pos,{type="node",name="technic:light_off"})
+                       minetest.env:add_node(rounded_pos,{type="node",name="air"})
+                       player_positions[player_name]["x"] = nil
+                       player_positions[player_name]["y"] = nil
+                       player_positions[player_name]["z"] = nil
+                       player_positions[player_name]["m"] = nil
+                       player_positions[player_name] = nil
+               end
+       end
+end)
+
+minetest.register_globalstep(function(dtime)
+       for i,player_name in ipairs(players) do
+               local player = minetest.env:get_player_by_name(player_name)
+               if player then
+               flashlight_weared=check_for_flashlight(player)
+               local pos = player:getpos()
+               local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
+               local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]}
+               
+               if last_wielded[player_name] and not flashlight_weared then --remove light, flashlight weared out or was removed from hotbar
+                       local node=minetest.env:get_node_or_nil(old_pos)
+                       if node then
+                       if node.name=="technic:light" then 
+                               minetest.env:add_node(old_pos,{type="node",name="technic:light_off"})
+                               minetest.env:add_node(old_pos,{type="node",name="air"})         
+                         last_wielded[player_name]=false
+                         end
+                       end
+                       end
+
+               player_moved=not(old_pos.x==rounded_pos.x and old_pos.y==rounded_pos.y and old_pos.z==rounded_pos.z)
+               if player_moved and last_wielded[player_name] and flashlight_weared  then
+                       
+                       local node=minetest.env:get_node_or_nil(rounded_pos)
+                       if node then
+                       if node.name=="air" then 
+                               minetest.env:add_node(rounded_pos,{type="node",name="technic:light"})
+                         end
+                       end
+                       local node=minetest.env:get_node_or_nil(old_pos)
+                       if node then
+                         if node.name=="technic:light" then 
+                               minetest.env:add_node(old_pos,{type="node",name="technic:light_off"})
+                               minetest.env:add_node(old_pos,{type="node",name="air"})         
+                         end
+                       end
+                       player_positions[player_name]["x"] = rounded_pos.x
+                       player_positions[player_name]["y"] = rounded_pos.y
+                       player_positions[player_name]["z"] = rounded_pos.z
+                       
+               else if not last_wielded[player_name] and flashlight_weared then
+                       local node=minetest.env:get_node_or_nil(rounded_pos)
+                       if node then
+                       if node.name=="air" then 
+                               minetest.env:add_node(rounded_pos,{type="node",name="technic:light"})
+                         end
+                       end
+                       player_positions[player_name]["x"] = rounded_pos.x
+                       player_positions[player_name]["y"] = rounded_pos.y
+                       player_positions[player_name]["z"] = rounded_pos.z
+                       last_wielded[player_name]=true
+                       end                     
+                       
+       end
+       end
+       end
+end)
+
+minetest.register_node("technic:light", {
+       drawtype = "glasslike",
+       tile_images = {"technic_light.png"},
+       paramtype = "light",
+       walkable = false,
+       buildable_to = true,
+       is_ground_content = true,
+       light_propagates = true,
+       sunlight_propagates = true,
+       light_source = 15,
+       selection_box = {
+        type = "fixed",
+        fixed = {0, 0, 0, 0, 0, 0},
+    },
+})
+minetest.register_node("technic:light_off", {
+       drawtype = "glasslike",
+       tile_images = {"technic_light.png"},
+       paramtype = "light",
+       walkable = false,
+       buildable_to = true,
+       is_ground_content = true,
+       light_propagates = true,
+       sunlight_propagates = true,
+       selection_box = {
+        type = "fixed",
+        fixed = {0, 0, 0, 0, 0, 0},
+    },
+})
+
+function check_for_flashlight (player)
+if player==nil then return false end
+local inv = player:get_inventory()
+local hotbar=inv:get_list("main")
+               for i=1,8,1 do
+                       
+                       if hotbar[i]:get_name() == "technic:flashlight" then
+                       local item=hotbar[i]:to_table()
+                       local meta=get_item_meta(item["metadata"])
+                       if meta==nil then return false end --flashlight not charghed
+                       if meta["charge"]==nil then return false end
+                       charge=meta["charge"]
+                       if charge-2>0 then
+                        charge =charge-2;      
+                       technic.set_RE_wear(item,charge,flashlight_max_charge)
+                       meta["charge"]=charge
+                       item["metadata"]=set_item_meta(meta)
+                       hotbar[i]:replace(item)
+                       inv:set_stack("main",i,hotbar[i])
+                       return true
+                       end
+                       end
+               end
+return false
+end    
diff --git a/technic/tools/flashlight_old.lua b/technic/tools/flashlight_old.lua
new file mode 100644 (file)
index 0000000..8a2c338
--- /dev/null
@@ -0,0 +1,176 @@
+-- original code comes from walkin_light mod by Echo http://minetest.net/forum/viewtopic.php?id=2621
+
+flashlight_max_charge=30000
+      
+       minetest.register_tool("technic:flashlight", {
+            description = "Flashlight",
+            inventory_image = "technic_flashlight.png",
+       stack_max = 1,
+            on_use = function(itemstack, user, pointed_thing)
+       end,            
+    })
+     
+    minetest.register_craft({
+            output = "technic:flashlight",
+            recipe = {
+                   {"glass","glass","glass"},
+                    {"technic:stainless_steel_ingot","technic:battery","technic:stainless_steel_ingot"},
+                    {"","technic:battery",""}
+            }
+    })
+local players = {}
+local player_positions = {}
+local last_wielded = {}
+
+function round(num) 
+       return math.floor(num + 0.5) 
+end
+
+minetest.register_on_joinplayer(function(player)
+       local player_name = player:get_player_name()
+       table.insert(players, player_name)
+       last_wielded[player_name] = flashlight_weared(player)
+       local pos = player:getpos()
+       local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
+       local wielded_item = player:get_wielded_item():get_name()
+       if flashlight_weared(player)==true then
+               -- Neuberechnung des Lichts erzwingen
+               minetest.env:add_node(rounded_pos,{type="node",name="technic:light_off"})
+               minetest.env:add_node(rounded_pos,{type="node",name="air"})
+       end
+       player_positions[player_name] = {}
+       player_positions[player_name]["x"] = rounded_pos.x;
+       player_positions[player_name]["y"] = rounded_pos.y;
+       player_positions[player_name]["z"] = rounded_pos.z;
+end)
+
+minetest.register_on_leaveplayer(function(player)
+       local player_name = player:get_player_name()
+       for i,v in ipairs(players) do
+               if v == player_name then 
+                       table.remove(players, i)
+                       last_wielded[player_name] = nil
+                       -- Neuberechnung des Lichts erzwingen
+                       local pos = player:getpos()
+                       local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
+                       minetest.env:add_node(rounded_pos,{type="node",name="technic:light_off"})
+                       minetest.env:add_node(rounded_pos,{type="node",name="air"})
+                       player_positions[player_name]["x"] = nil
+                       player_positions[player_name]["y"] = nil
+                       player_positions[player_name]["z"] = nil
+                       player_positions[player_name]["m"] = nil
+                       player_positions[player_name] = nil
+               end
+       end
+end)
+
+minetest.register_globalstep(function(dtime)
+       for i,player_name in ipairs(players) do
+               local player = minetest.env:get_player_by_name(player_name)
+               if flashlight_weared(player)==true then
+                       -- Fackel ist in der Hand
+                       local pos = player:getpos()
+                       local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
+                       if (last_wielded[player_name] ~= true) or (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then
+                               -- Fackel gerade in die Hand genommen oder zu neuem Node bewegt
+                               local is_air  = minetest.env:get_node_or_nil(rounded_pos)
+                               if is_air == nil or (is_air ~= nil and (is_air.name == "air" or is_air.name == "technic:light")) then
+                                       -- wenn an aktueller Position "air" ist, Fackellicht setzen
+                                       minetest.env:add_node(rounded_pos,{type="node",name="technic:light"})
+                               end
+                               if (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then
+                                       -- wenn Position geänder, dann altes Licht löschen
+                                       local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]}
+                                       -- Neuberechnung des Lichts erzwingen
+                                       local is_light = minetest.env:get_node_or_nil(old_pos)
+                                       if is_light ~= nil and is_light.name == "technic:light" then
+                                               minetest.env:add_node(old_pos,{type="node",name="technic:light_off"})
+                                               minetest.env:add_node(old_pos,{type="node",name="air"})
+                                       end
+                               end
+                               -- gemerkte Position ist nun die gerundete neue Position
+                               player_positions[player_name]["x"] = rounded_pos.x
+                               player_positions[player_name]["y"] = rounded_pos.y
+                               player_positions[player_name]["z"] = rounded_pos.z
+                       end
+
+                       last_wielded[player_name] = true;
+               elseif last_wielded[player_name] == true  then
+                       -- Fackel nicht in der Hand, aber beim letzten Durchgang war die Fackel noch in der Hand
+                       local pos = player:getpos()
+                       local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
+                       repeat
+                               local is_light  = minetest.env:get_node_or_nil(rounded_pos)
+                               if is_light ~= nil and is_light.name == "technic:light" then
+                                       -- minetest.env:remove_node(rounded_pos)
+                                       -- Erzwinge Neuberechnung des Lichts
+                                       minetest.env:add_node(rounded_pos,{type="node",name="technic:light_off"})
+                                       minetest.env:add_node(rounded_pos,{type="node",name="air"})
+                               end
+                       until minetest.env:get_node_or_nil(rounded_pos) ~= "technic:light"
+                       local old_pos = {x=player_positions[player_name]["x"], y=player_positions[player_name]["y"], z=player_positions[player_name]["z"]}
+                       repeat
+                               is_light  = minetest.env:get_node_or_nil(old_pos)
+                               if is_light ~= nil and is_light.name == "technic:light" then
+                                       -- minetest.env:remove_node(old_pos)
+                                       -- Erzwinge Neuberechnung des Lichts
+                                       minetest.env:add_node(old_pos,{type="node",name="technic:light_off"})
+                                       minetest.env:add_node(old_pos,{type="node",name="air"})
+                               end
+                       until minetest.env:get_node_or_nil(old_pos) ~= "technic:light"
+                       last_wielded[player_name] = true
+               end
+       end
+end)
+
+minetest.register_node("technic:light", {
+       drawtype = "glasslike",
+       tile_images = {"technic_light.png"},
+       paramtype = "light",
+       walkable = false,
+       is_ground_content = true,
+       light_propagates = true,
+       sunlight_propagates = true,
+       light_source = 15,
+       selection_box = {
+        type = "fixed",
+        fixed = {0, 0, 0, 0, 0, 0},
+    },
+})
+minetest.register_node("technic:light_off", {
+       drawtype = "glasslike",
+       tile_images = {"technic_light.png"},
+       paramtype = "light",
+       walkable = false,
+       is_ground_content = true,
+       light_propagates = true,
+       sunlight_propagates = true,
+       selection_box = {
+        type = "fixed",
+        fixed = {0, 0, 0, 0, 0, 0},
+    },
+})
+
+function flashlight_weared (player)
+flashlight_on=false
+local inv = player:get_inventory()
+local hotbar=inv:get_list("main")
+               for i=1,8,1 do
+                       
+                       if hotbar[i]:get_name() == "technic:flashlight" then
+                       item=hotbar[i]:to_table()
+                       if item["metadata"]=="" or item["metadata"]=="0" then return flashlight_on end --flashlight not charghed
+                       charge=tonumber(item["metadata"]) 
+                       if charge-2>0 then
+                        flashlight_on=true     
+                        charge =charge-2;      
+                       set_RE_wear(item,charge,flashlight_max_charge)
+                       item["metadata"]=tostring(charge)
+                       hotbar[i]:replace(item)
+                       inv:set_stack("main",i,hotbar[i])
+                       return true
+                       end
+                       end
+               end
+return flashlight_on
+end    
\ No newline at end of file
diff --git a/technic/tools/init.lua b/technic/tools/init.lua
new file mode 100644 (file)
index 0000000..daa7727
--- /dev/null
@@ -0,0 +1,16 @@
+local path = technic.modpath.."/tools"
+
+if technic.config:getBool("enable_mining_drill") then
+       dofile(path.."/mining_drill.lua")
+end
+if technic.config:getBool("enable_mining_laser") then
+       dofile(path.."/mining_laser_mk1.lua")
+end
+if technic.config:getBool("enable_flashlight") then
+       dofile(path.."/flashlight.lua")
+end
+dofile(path.."/cans.lua")
+dofile(path.."/chainsaw.lua")
+dofile(path.."/tree_tap.lua")
+dofile(path.."/sonic_screwdriver.lua")
+
diff --git a/technic/tools/mining_drill.lua b/technic/tools/mining_drill.lua
new file mode 100644 (file)
index 0000000..6df9e97
--- /dev/null
@@ -0,0 +1,384 @@
+local mining_drill_max_charge=60000
+local mining_drill_mk2_max_charge=240000
+local mining_drill_mk3_max_charge=960000
+local mining_drill_power_usage=200
+local mining_drill_mk2_power_usage=600
+local mining_drill_mk3_power_usage=1800
+
+minetest.register_craft({
+       output = 'technic:mining_drill',
+       recipe = {
+               {'technic:stainless_steel_ingot',       'technic:diamond_drill_head',   'technic:stainless_steel_ingot'},
+               {'technic:stainless_steel_ingot',       'technic:motor',                                'technic:stainless_steel_ingot'},
+               {'',                                                            'technic:red_energy_crystal',   'moreores:copper_ingot'},
+       }
+})
+minetest.register_craft({
+       output = 'technic:mining_drill_mk2',
+       recipe = {
+               {'technic:diamond_drill_head',          'technic:diamond_drill_head',   'technic:diamond_drill_head'},
+               {'technic:stainless_steel_ingot',       'technic:mining_drill',                 'technic:stainless_steel_ingot'},
+               {'',                                                            'technic:green_energy_crystal', ''},
+       }
+})
+minetest.register_craft({
+       output = 'technic:mining_drill_mk3',
+       recipe = {
+               {'technic:diamond_drill_head',          'technic:diamond_drill_head',   'technic:diamond_drill_head'},
+               {'technic:stainless_steel_ingot',       'technic:mining_drill_mk2',     'technic:stainless_steel_ingot'},
+               {'',                                                            'technic:blue_energy_crystal',  ''},
+       }
+})
+
+function drill_dig_it (pos, player,drill_type,mode)
+       
+       local charge
+
+       if mode==1 then
+               drill_dig_it0 (pos,player)
+       end
+       
+       if mode==2 then -- 3 deep
+               dir=drill_dig_it1(player)
+               if dir==0 then -- x+
+                       drill_dig_it0 (pos,player)
+                       pos.x=pos.x+1
+                       drill_dig_it0 (pos,player)
+                       pos.x=pos.x+1
+                       drill_dig_it0 (pos,player)
+               end
+               if dir==1 then  -- x-
+                       drill_dig_it0 (pos,player)
+                       pos.x=pos.x-1
+                       drill_dig_it0 (pos,player)
+                       pos.x=pos.x-1
+                       drill_dig_it0 (pos,player)
+               end
+               if dir==2 then  -- z+
+                       drill_dig_it0 (pos,player)
+                       pos.z=pos.z+1
+                       drill_dig_it0 (pos,player)
+                       pos.z=pos.z+1
+                       drill_dig_it0 (pos,player)
+               end
+               if dir==3 then  -- z-
+                       drill_dig_it0 (pos,player)
+                       pos.z=pos.z+1
+                       drill_dig_it0 (pos,player)
+                       pos.z=pos.z+1
+                       drill_dig_it0 (pos,player)
+               end
+       end
+       
+       if mode==3 then -- 3 wide
+               dir=drill_dig_it1(player)
+               if dir==0 or dir==1 then -- x
+                       drill_dig_it0 (pos,player)
+                       pos.z=pos.z+1
+                       drill_dig_it0 (pos,player)
+                       pos.z=pos.z-2
+                       drill_dig_it0 (pos,player)
+               end
+               if dir==2 or dir==3 then  -- z
+                       drill_dig_it0 (pos,player)
+                       pos.x=pos.x+1
+                       drill_dig_it0 (pos,player)
+                       pos.x=pos.x-2
+                       drill_dig_it0 (pos,player)
+               end
+       end
+       
+       if mode==4 then -- 3 tall, selected in the middle
+               drill_dig_it0 (pos,player)
+               pos.y=pos.y+1
+               drill_dig_it0 (pos,player)
+               pos.y=pos.y-2
+               drill_dig_it0 (pos,player)
+       end
+
+       if mode==5 then -- 3 x 3
+               local dir=player:get_look_dir()
+               if math.abs(dir.y)<0.5 then
+                       dir=drill_dig_it1(player)
+                               if dir==0 or dir==1 then -- x
+                                       drill_dig_it2(pos,player)
+                               end
+                               if dir==2 or dir==3 then  -- z
+                                       drill_dig_it3(pos,player)
+                               end
+               else
+               drill_dig_it4(pos,player)
+               end
+       end
+       
+       if drill_type==1 then charge=mining_drill_power_usage end
+       if drill_type==2 then 
+               if  mode==1 then charge=mining_drill_mk2_power_usage end
+               if (mode==2 or mode==3 or mode==4) then charge=mining_drill_mk2_power_usage*3 end
+       end
+       if drill_type==3 then 
+               if  mode==1 then charge=mining_drill_power_usage end
+               if (mode==2 or mode==3 or mode==4) then charge=mining_drill_mk2_power_usage*6 end
+               if mode==5 then charge=mining_drill_mk2_power_usage*9 end
+       end
+       minetest.sound_play("mining_drill", {pos = pos, gain = 1.0, max_hear_distance = 10,})
+       return charge
+end
+
+function drill_dig_it0 (pos,player)
+       local node=minetest.env:get_node(pos)
+       if node.name == "air" or node.name == "ignore" then return end
+       if node.name == "default:lava_source" then return end
+       if node.name == "default:lava_flowing" then return end
+       if node.name == "default:water_source" then minetest.env:remove_node(pos) return end
+       if node.name == "default:water_flowing" then minetest.env:remove_node(pos) return end
+       minetest.node_dig(pos,node,player)
+end
+
+function drill_dig_it1 (player)
+       local dir=player:get_look_dir()
+       if math.abs(dir.x)>math.abs(dir.z) then 
+               if dir.x>0 then return 0 end
+               return 1
+       end
+       if dir.z>0 then return 2 end
+       return 3
+end
+
+function drill_dig_it2 (pos,player)
+       drill_dig_it0 (pos,player)
+       pos.z=pos.z+1
+       drill_dig_it0 (pos,player)
+       pos.z=pos.z-2
+       drill_dig_it0 (pos,player)
+       pos.z=pos.z+1
+       pos.y=pos.y+1
+       drill_dig_it0 (pos,player)
+       pos.z=pos.z+1
+       drill_dig_it0 (pos,player)
+       pos.z=pos.z-2
+       drill_dig_it0 (pos,player)
+       pos.z=pos.z+1
+       pos.y=pos.y-2
+       drill_dig_it0 (pos,player)
+       pos.z=pos.z+1
+       drill_dig_it0 (pos,player)
+       pos.z=pos.z-2
+       drill_dig_it0 (pos,player)
+end
+function drill_dig_it3 (pos,player)
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x+1
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x-2
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x+1
+       pos.y=pos.y+1
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x+1
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x-2
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x+1
+       pos.y=pos.y-2
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x+1
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x-2
+       drill_dig_it0 (pos,player)
+end
+
+function drill_dig_it4 (pos,player)
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x+1
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x-2
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x+1
+       pos.z=pos.z+1
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x+1
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x-2
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x+1
+       pos.z=pos.z-2
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x+1
+       drill_dig_it0 (pos,player)
+       pos.x=pos.x-2
+       drill_dig_it0 (pos,player)
+end
+
+technic.register_MV_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",
+       stack_max = 1,
+       on_use = function(itemstack, user, pointed_thing)
+               if pointed_thing.type=="node" then 
+               local item=itemstack:to_table()
+               local meta=get_item_meta(item["metadata"])
+               if meta==nil then return end --tool not charghed
+               if meta["charge"]==nil then return end
+               local charge=meta["charge"]
+               if charge-mining_drill_power_usage>0 then
+                       charge_to_take=drill_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,1,1)
+                       charge =charge-mining_drill_power_usage;
+                       meta["charge"]=charge
+                       item["metadata"]=set_item_meta(meta)
+                       technic.set_RE_wear(item,charge,mining_drill_max_charge)
+                       itemstack:replace(item)
+                       end
+               return itemstack
+               end
+       end,
+})
+
+minetest.register_tool("technic:mining_drill_mk2", {
+       description = "Mining Drill Mk2",
+       inventory_image = "technic_mining_drill_mk2.png",
+       on_use = function(itemstack, user, pointed_thing)
+       mining_drill_mk2_handler(itemstack,user,pointed_thing)
+       return itemstack
+       end,
+})
+technic.register_HV_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)
+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",
+       wield_image = "technic_mining_drill_mk2.png",
+       groups = {not_in_creative_inventory=1},
+       on_use = function(itemstack, user, pointed_thing)
+       mining_drill_mk2_handler(itemstack,user,pointed_thing)
+       return itemstack
+       end,
+})
+end
+
+minetest.register_tool("technic:mining_drill_mk3", {
+       description = "Mining Drill Mk3",
+       inventory_image = "technic_mining_drill_mk3.png",
+       on_use = function(itemstack, user, pointed_thing)
+       mining_drill_mk3_handler(itemstack,user,pointed_thing)
+       return itemstack
+       end,
+})
+technic.register_HV_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)
+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",
+       wield_image = "technic_mining_drill_mk3.png",
+       groups = {not_in_creative_inventory=1},
+       on_use = function(itemstack, user, pointed_thing)
+       mining_drill_mk3_handler(itemstack,user,pointed_thing)
+       return itemstack
+       end,
+})
+end
+
+function mining_drill_mk2_handler (itemstack,user,pointed_thing)
+       local keys=user:get_player_control()
+       local player_name=user:get_player_name()
+       local item=itemstack:to_table()
+       local meta=get_item_meta(item["metadata"])
+       if meta==nil or keys["sneak"]==true then return mining_drill_mk2_setmode(user,itemstack) end
+       if meta["mode"]==nil then return mining_drill_mk2_setmode(user,itemstack) end
+       if pointed_thing.type~="node" then return end
+       if meta["charge"]==nil then return end
+       charge=meta["charge"]
+       if charge-mining_drill_power_usage>0 then
+               local charge_to_take=drill_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,2,meta["mode"])
+               charge=charge-charge_to_take;
+               if charge<0 then charge=0 end
+               meta["charge"]=charge
+               item["metadata"]=set_item_meta(meta)
+               technic.set_RE_wear(item,charge,mining_drill_mk2_max_charge)
+               itemstack:replace(item)
+       end
+       return itemstack
+end
+
+function mining_drill_mk3_handler (itemstack,user,pointed_thing)
+       local keys=user:get_player_control()
+       local player_name=user:get_player_name()
+       local item=itemstack:to_table()
+       local meta=get_item_meta(item["metadata"])
+       if meta==nil or keys["sneak"]==true then return mining_drill_mk3_setmode(user,itemstack) end
+       if meta["mode"]==nil then return mining_drill_mk3_setmode(user,itemstack) end
+       if pointed_thing.type~="node" then return end
+       if meta["charge"]==nil then return end
+       local charge=meta["charge"]
+       if charge-mining_drill_power_usage>0 then
+               local charge_to_take=drill_dig_it(minetest.get_pointed_thing_position(pointed_thing, above),user,3,meta["mode"])
+               charge=charge-charge_to_take;
+               if charge<0 then charge=0 end
+               meta["charge"]=charge
+               item["metadata"]=set_item_meta(meta)
+               technic.set_RE_wear(item,charge,mining_drill_mk3_max_charge)
+               itemstack:replace(item)
+       end
+       return itemstack
+end
+
+mining_drill_mode_text={
+{"Single node."},
+{"3 nodes deep."},
+{"3 modes wide."},
+{"3 modes tall."},
+{"3x3 nodes."},
+}
+
+function mining_drill_mk2_setmode(user,itemstack)
+       local player_name=user:get_player_name()
+       local item=itemstack:to_table()
+       local meta=get_item_meta(item["metadata"])
+       if meta==nil then
+               meta={}
+               mode=0
+       end
+       if meta["mode"]==nil then
+               minetest.chat_send_player(player_name,"Hold shift and use to change Mining Drill Mk2 modes.")
+               meta["mode"]=0
+               mode=0
+       end
+       mode=(meta["mode"])
+       mode=mode+1
+       if mode>=5 then mode=1 end
+       minetest.chat_send_player(player_name, "Mining Drill Mk2 mode : "..mode.." - "..mining_drill_mode_text[mode][1] )
+       item["name"]="technic:mining_drill_mk2_"..mode
+       meta["mode"]=mode
+       item["metadata"]=set_item_meta(meta)
+       itemstack:replace(item)
+       return itemstack
+end
+
+function mining_drill_mk3_setmode(user,itemstack)
+       local player_name=user:get_player_name()
+       local item=itemstack:to_table()
+       local meta=get_item_meta(item["metadata"])
+       if meta==nil then
+               meta={}
+               mode=0
+       end
+       if meta["mode"]==nil then
+               minetest.chat_send_player(player_name,"Hold shift and use to change Mining Drill Mk3 modes.")
+               meta["mode"]=0
+               mode=0
+       end
+       mode=(meta["mode"])
+       mode=mode+1
+       if mode>=6 then mode=1 end
+       minetest.chat_send_player(player_name, "Mining Drill Mk3 mode : "..mode.." - "..mining_drill_mode_text[mode][1] )
+       item["name"]="technic:mining_drill_mk3_"..mode
+       meta["mode"]=mode
+       item["metadata"]=set_item_meta(meta)
+       itemstack:replace(item)
+       return itemstack
+end
diff --git a/technic/tools/mining_laser.lua b/technic/tools/mining_laser.lua
new file mode 100644 (file)
index 0000000..8b89131
--- /dev/null
@@ -0,0 +1,179 @@
+local laser_mk1_max_charge=40000
+technic.register_LV_power_tool ("technic:laser_mk1",laser_mk1_max_charge)
+
+local laser_shoot = function(itemstack, player, pointed_thing)
+                               local laser_straight_mode=0
+                               local playerpos=player:getpos()
+                               local dir=player:get_look_dir()
+                               if pointed_thing.type=="node" then  
+                                       pos=minetest.get_pointed_thing_position(pointed_thing, above)
+                                       local node = minetest.env:get_node(pos)
+                                       if node.name~="ignore" then
+                                       minetest.node_dig(pos,node,player)
+                                       end
+                                       laser_straight_mode=1
+                                       end     
+                               
+                               direction_y=math.abs(math.floor(dir.y*100))
+                               if direction_y>50 then entity_name="technic:laser_beam_entityV"
+                                       else entity_name="technic:laser_beam_entity" end
+                               
+                               if laser_straight_mode==1  then
+                                       pos1=minetest.get_pointed_thing_position(pointed_thing, under)
+                                       pos1.x=math.floor(pos1.x) 
+                                       pos1.y=math.floor(pos1.y)
+                                       pos1.z=math.floor(pos1.z)
+                                       obj=minetest.env:add_entity(pos1,entity_name)
+                               else
+                               obj=minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.6,z=playerpos.z},entity_name)
+                               end
+                               if obj:get_luaentity().player == nil then
+                                       obj:get_luaentity().player = player
+                               end
+                               if laser_straight_mode==1 and direction_y<50 then
+                                       obj:setvelocity({x=dir.x*8, y=0, z=dir.z*8})
+                               else if laser_straight_mode==1 and direction_y>50 then
+                                       obj:setvelocity({x=0, y=dir.y*8, z=dir.z*8})
+                                       end
+                               end
+                               if laser_straight_mode==0 then
+                                       obj:setvelocity({x=dir.x*8, y=dir.y*8, z=dir.z*8})
+                                       end
+                               obj:setacceleration({x=0, y=0, z=0})
+                               obj:setyaw(player:get_look_yaw()+math.pi)
+                               if obj:get_luaentity().player == nil then
+                                       obj:get_luaentity().player = player
+                               end
+                               --obj:get_luaentity().node = player:get_inventory():get_stack("main", 1):get_name()
+                               minetest.sound_play("technic_laser", {pos = playerpos, gain = 1.0, max_hear_distance = 10,})
+                               return true
+end
+
+
+minetest.register_tool("technic:laser_mk1", {
+       description = "Mining Laser MK1",
+       inventory_image = "technic_mining_laser_mk1.png",
+       stack_max = 1,
+       on_use = function(itemstack, user, pointed_thing)
+               item=itemstack:to_table()
+               local meta=get_item_meta(item["metadata"])
+               if meta==nil then return end --tool not charghed
+               if meta["charge"]==nil then return end
+               charge=meta["charge"]
+               if charge-400>0 then
+                laser_shoot(item, user, pointed_thing)
+                charge = charge-400;
+               technic.set_RE_wear(item,charge,laser_mk1_max_charge)
+               meta["charge"]=charge
+               item["metadata"]=set_item_meta(meta)
+               itemstack:replace(item)
+               end
+               return itemstack
+       end,
+})
+
+minetest.register_craft({
+       output = 'technic:laser_mk1',
+       recipe = {
+               {'default:diamond', 'default:steel_ingot', 'technic:battery'},
+               {'', 'default:steel_ingot', 'technic:battery'},
+               {'', '', 'default:copper_ingot'},
+       }
+})
+
+
+
+minetest.register_node("technic:laser_beam_box", {
+       drawtype = "nodebox",
+       node_box = {
+               type = "fixed",
+               fixed = {
+                       { -0.5 , -0.1, -0.1 ,  0.1 ,  0.1 , 0.1  },
+                       { -0.1 , -0.1 , -0.1 , 0.5, 0.1 , 0.1  },
+               }
+       },
+       tiles = {"technic_laser_beam.png"},
+       groups = {not_in_creative_inventory=1},
+})
+
+minetest.register_node("technic:laser_beam_boxV", {
+       drawtype = "nodebox",
+       node_box = {
+               type = "fixed",
+               fixed = {
+                       { -0.1 , -0.1 , -0.1 , 0.1 , 0.5, 0.1  },
+                       { -0.1 , -0.5, -0.1 ,  0.1 ,  0.1 , 0.1  },
+
+               }
+       },
+       tiles = {"technic_laser_beam.png"},
+       groups = {not_in_creative_inventory=1},
+})
+
+LASER_BEAM_ENTITY={
+       physical = false,
+       timer=0,
+       visual = "wielditem",
+       visual_size = {x=0.2, y=0.2},
+       textures = {"technic:laser_beam_box"},
+       lastpos={},
+       max_range=10,
+       count=0,
+--     digger=nil,
+       collisionbox = {0,0,0,0,0,0},
+}
+
+LASER_BEAM_ENTITY.on_step = function(self, dtime)
+       self.timer=self.timer+dtime
+       local pos = self.object:getpos()
+       if self.player~=nil then if self.lastpos.x~=nil then lazer_it (pos, self.player) end end                
+       if self.lastpos.x ~=nil and self.lastpos.y ~=nil and self.lastpos.y ~=nil then 
+                       temp1={x=math.floor(self.lastpos.x),y=math.floor(self.lastpos.y),z=math.floor(self.lastpos.z)}
+                       temp2={x=math.floor(pos.x),y=math.floor(pos.y),z=math.floor(pos.z)}
+                       if temp1.x==temp2.x and temp1.y==temp2.y and temp1.z==temp2.z then return end
+                       end
+       self.lastpos={x=pos.x, y=pos.y, z=pos.z}        
+       self.count=self.count+1
+       if self.count==self.max_range then self.object:remove() end
+end
+
+LASER_BEAM_ENTITYV={
+       physical = false,
+       timer=0,
+       visual = "wielditem",
+       visual_size = {x=0.2, y=0.2},
+       textures = {"technic:laser_beam_boxV"},
+       lastpos={},
+       max_range=15,
+       count=0,
+       collisionbox = {0,0,0,0,0,0},
+}
+
+LASER_BEAM_ENTITYV.on_step = function(self, dtime)
+       self.timer=self.timer+dtime
+       local pos = self.object:getpos()
+       if self.player~=nil then if self.lastpos.x~=nil then lazer_it (pos, self.player) end end                
+       if self.lastpos.x ~=nil and self.lastpos.y ~=nil and self.lastpos.y ~=nil then 
+                       temp1={x=math.floor(self.lastpos.x),y=math.floor(self.lastpos.y),z=math.floor(self.lastpos.z)}
+                       temp2={x=math.floor(pos.x),y=math.floor(pos.y),z=math.floor(pos.z)}
+                       if temp1.x==temp2.x and temp1.y==temp2.y and temp1.z==temp2.z then return end
+                       end
+       self.lastpos={x=pos.x, y=pos.y, z=pos.z}        
+       self.count=self.count+1
+       if self.count==self.max_range then self.object:remove() end
+end
+
+
+minetest.register_entity("technic:laser_beam_entity", LASER_BEAM_ENTITY)
+minetest.register_entity("technic:laser_beam_entityV", LASER_BEAM_ENTITYV)
+
+function lazer_it (pos, player)        
+       local pos1={}
+--     pos1.x=math.floor(pos.x)
+--     pos1.y=math.floor(pos.y)
+--     pos1.z=math.floor(pos.z)
+       local node = minetest.env:get_node(pos)
+       if node.name == "air" or node.name == "ignore" or node.name == "default:lava_source" or node.name == "default:lava_flowing" then return end
+       if node.name == "default:water_source" or node.name == "default:water_flowing" then minetest.env:remove_node(pos) return end
+       if player then minetest.node_dig(pos,node,player) end
+end
diff --git a/technic/tools/sonic_screwdriver.lua b/technic/tools/sonic_screwdriver.lua
new file mode 100644 (file)
index 0000000..00922f7
--- /dev/null
@@ -0,0 +1,59 @@
+local sonic_screwdriver_max_charge=15000
+technic.register_HV_power_tool ("technic:sonic_screwdriver",sonic_screwdriver_max_charge)
+
+minetest.register_tool("technic:sonic_screwdriver", {
+                       description = "Sonic Screwdriver",
+                       inventory_image = "technic_sonic_screwdriver.png",
+                       on_use = function(itemstack, user, pointed_thing)
+                                       -- Must be pointing to facedir applicable node
+                                       if pointed_thing.type~="node" then return end
+                                       local pos=minetest.get_pointed_thing_position(pointed_thing,above)
+                                       local node=minetest.env:get_node(pos)
+                                       local node_name=node.name
+                                               if minetest.registered_nodes[node_name].paramtype2 == "facedir" or minetest.registered_nodes[node_name].paramtype2 == "wallmounted" then
+                                       if node.param2==nil  then return end
+                                       item=itemstack:to_table()
+                                       local meta1=get_item_meta(item["metadata"])
+                                       if meta1==nil then return end --tool not charghed
+                                       if meta1["charge"]==nil then return end
+                                       charge=meta1["charge"]
+                                       if charge-100>0 then
+                                               minetest.sound_play("technic_sonic_screwdriver", {pos = pos, gain = 0.3, max_hear_distance = 10,})
+                                               local n = node.param2
+                                               if minetest.registered_nodes[node_name].paramtype2 == "facedir" then
+                                                  n = n+1
+                                               if n == 4 then n = 0 end
+                                               else
+                                                       n = n+1
+                                                       if n == 6 then n = 0 end
+                                               end
+                                               -- hacky_swap_node, unforunatly.
+                                               local meta = minetest.env:get_meta(pos)
+                                               local meta0 = meta:to_table()
+                                               node.param2 = n
+                                               minetest.env:set_node(pos,node)
+                                               meta = minetest.env:get_meta(pos)
+                                               meta:from_table(meta0)
+
+                                               charge=charge-100;  
+                                               meta1["charge"]=charge
+                                               item["metadata"]=set_item_meta(meta1)
+                                               technic.set_RE_wear(item,charge,sonic_screwdriver_max_charge)
+                                               itemstack:replace(item)
+                                               end
+                                               return itemstack
+                                               else
+                                               return itemstack
+                                               end
+                                               end,
+                
+       })
+minetest.register_craft({
+       output = "technic:sonic_screwdriver",
+       recipe = {
+               {"default:diamond"},
+               {"technic:battery"},
+               {"technic:stainless_steel_ingot"}
+               }
+})
diff --git a/technic/tools/tree_tap.lua b/technic/tools/tree_tap.lua
new file mode 100644 (file)
index 0000000..9d805d5
--- /dev/null
@@ -0,0 +1,60 @@
+    minetest.register_tool("technic:treetap", {
+            description = "Tree Tap",
+            inventory_image = "technic_tree_tap.png",
+            on_use = function(itemstack,user,pointed_thing)
+                    if pointed_thing.type~="node" then return end
+                    if user:get_inventory():room_for_item("main",ItemStack("technic:raw_latex")) then
+                            local pos=minetest.get_pointed_thing_position(pointed_thing,above)
+                            local node=minetest.env:get_node(pos)
+                            local node_name=node.name
+                            if node_name == "moretrees:rubber_tree_trunk" then
+                                    node.name = "moretrees:rubber_tree_trunk_empty"
+                                    user:get_inventory():add_item("main",ItemStack("technic:raw_latex"))
+                                    minetest.env:set_node(pos,node)
+                                    local item=itemstack:to_table()
+                                    local item_wear=tonumber((item["wear"]))
+                                    item_wear=item_wear+819
+                                    if item_wear>65535 then itemstack:clear() return itemstack end
+                                    item["wear"]=tostring(item_wear)
+                                    itemstack:replace(item)
+                                    return itemstack
+                                    else
+                                    return itemstack
+                                    end
+                           else return end
+                    end,
+    })
+     
+    minetest.register_craft({
+            output = "technic:treetap",
+            recipe = {
+                    {"pipeworks:tube", "default:wood", "default:stick"},
+                    {"", "default:stick", "default:stick"}
+            },
+    })
+     
+    minetest.register_craftitem("technic:raw_latex", {
+            description = "Raw Latex",
+            inventory_image = "technic_raw_latex.png",
+    })
+     
+    minetest.register_craft({
+            type = "cooking",
+            output = "technic:rubber",
+            recipe = "technic:raw_latex",
+    })
+     
+    minetest.register_craftitem("technic:rubber", {
+            description = "Rubber Fiber",
+            inventory_image = "technic_rubber.png",
+    })
+
+minetest.register_abm({
+       nodenames = {"moretrees:rubber_tree_trunk_empty"},
+       interval = 60,
+       chance = 15,
+       action = function(pos, node)
+               node.name = "moretrees:rubber_tree_trunk"
+               minetest.env:set_node(pos, node)
+       end
+})
diff --git a/technic/tree_tap.lua b/technic/tree_tap.lua
deleted file mode 100644 (file)
index 9d805d5..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-    minetest.register_tool("technic:treetap", {
-            description = "Tree Tap",
-            inventory_image = "technic_tree_tap.png",
-            on_use = function(itemstack,user,pointed_thing)
-                    if pointed_thing.type~="node" then return end
-                    if user:get_inventory():room_for_item("main",ItemStack("technic:raw_latex")) then
-                            local pos=minetest.get_pointed_thing_position(pointed_thing,above)
-                            local node=minetest.env:get_node(pos)
-                            local node_name=node.name
-                            if node_name == "moretrees:rubber_tree_trunk" then
-                                    node.name = "moretrees:rubber_tree_trunk_empty"
-                                    user:get_inventory():add_item("main",ItemStack("technic:raw_latex"))
-                                    minetest.env:set_node(pos,node)
-                                    local item=itemstack:to_table()
-                                    local item_wear=tonumber((item["wear"]))
-                                    item_wear=item_wear+819
-                                    if item_wear>65535 then itemstack:clear() return itemstack end
-                                    item["wear"]=tostring(item_wear)
-                                    itemstack:replace(item)
-                                    return itemstack
-                                    else
-                                    return itemstack
-                                    end
-                           else return end
-                    end,
-    })
-     
-    minetest.register_craft({
-            output = "technic:treetap",
-            recipe = {
-                    {"pipeworks:tube", "default:wood", "default:stick"},
-                    {"", "default:stick", "default:stick"}
-            },
-    })
-     
-    minetest.register_craftitem("technic:raw_latex", {
-            description = "Raw Latex",
-            inventory_image = "technic_raw_latex.png",
-    })
-     
-    minetest.register_craft({
-            type = "cooking",
-            output = "technic:rubber",
-            recipe = "technic:raw_latex",
-    })
-     
-    minetest.register_craftitem("technic:rubber", {
-            description = "Rubber Fiber",
-            inventory_image = "technic_rubber.png",
-    })
-
-minetest.register_abm({
-       nodenames = {"moretrees:rubber_tree_trunk_empty"},
-       interval = 60,
-       chance = 15,
-       action = function(pos, node)
-               node.name = "moretrees:rubber_tree_trunk"
-               minetest.env:set_node(pos, node)
-       end
-})
diff --git a/technic/water.lua b/technic/water.lua
deleted file mode 100644 (file)
index 044ee59..0000000
+++ /dev/null
@@ -1,588 +0,0 @@
-minetest.register_alias("battery", "technic:battery")
-minetest.register_alias("battery_box", "technic:battery_box")
-minetest.register_alias("electric_furnace", "technic:electric_furnace")
-
-
-minetest.register_craft({
-       output = 'technic:battery 1',
-       recipe = {
-               {'default:wood', 'default:copper_ingot', 'default:wood'},
-               {'default:wood', 'moreores:tin_ingot',   'default:wood'},
-               {'default:wood', 'default:copper_ingot', 'default:wood'},
-       }
-}) 
-
-minetest.register_craft({
-       output = 'technic:battery_box 1',
-       recipe = {
-               {'technic:battery',     'default:wood',         'technic:battery'},
-               {'technic:battery',     'default:copper_ingot', 'technic:battery'},
-               {'default:steel_ingot', 'default:steel_ingot',  'default:steel_ingot'},
-       }
-}) 
-
-minetest.register_craft({
-       output = 'technic:electric_furnace',
-       recipe = {
-               {'default:brick',       'default:brick',         'default:brick'},
-               {'default:brick',       '',                      'default:brick'},
-               {'default:steel_ingot', 'default:copper_ingot',  'default:steel_ingot'},
-       }
-})
-
-
---minetest.register_craftitem("technic:battery", {
---     description = "Recharcheable battery",
---     inventory_image = "technic_battery.png",
---     stack_max = 1,
---}) 
-
-minetest.register_tool("technic:battery",
-{description = "RE Battery",
-inventory_image = "technic_battery.png",
-energy_charge = 0,
-tool_capabilities = {max_drop_level=0, groupcaps={fleshy={times={}, uses=10000, maxlevel=0}}}}) 
-
-minetest.register_craftitem("technic:battery_box", {
-       description = "Battery box",
-       stack_max = 99,
-}) 
-
-
-
-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;Battery box]"..
-       "label[3,0;Charge]"..
-       "label[5,0;Discharge]"..
-       "label[1,3;Power level]"..
-       "list[current_player;main;0,5;8,4;]"
-
-minetest.register_node("technic:battery_box", {
-       description = "Battery box",
-       tiles = {"technic_battery_box_top.png", "technic_battery_box_bottom.png", "technic_battery_box_side.png",
-               "technic_battery_box_side.png", "technic_battery_box_side.png", "technic_battery_box_side.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       sounds = default.node_sound_wood_defaults(),
-       technic_power_machine=1,
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_string("infotext", "Battery box")
-               meta:set_float("technic_power_machine", 1)
-               meta:set_string("formspec", battery_box_formspec)
-               local inv = meta:get_inventory()
-               inv:set_size("src", 1)
-               inv:set_size("dst", 1)
-               battery_charge = 0
-               max_charge = 60000
-               end,    
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               if not inv:is_empty("dst") then
-                       return false
-               elseif not inv:is_empty("src") then
-                       return false
-               end
-               return true
-       end,
-})
-
-electric_furnace_formspec =
-       "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;2,2;]"..
-       "list[current_player;main;0,5;8,4;]"..
-       "label[0,0;Electric Furnace]"..
-       "label[1,3;Power level]"
-       
-minetest.register_node("technic:electric_furnace", {
-       description = "Electric furnace",
-       tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
-               "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front.png"},
-       paramtype2 = "facedir",
-       groups = {cracky=2},
-       legacy_facedir_simple = true,
-       sounds = default.node_sound_stone_defaults(),
-       technic_power_machine=1,
-       internal_EU_buffer=0;
-       interal_EU_buffer_size=2000;
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_float("technic_power_machine", 1)
-               meta:set_string("formspec", electric_furnace_formspec)
-               meta:set_string("infotext", "Electric furnace")
-               local inv = meta:get_inventory()
-               inv:set_size("src", 1)
-               inv:set_size("dst", 4)
-               local EU_used  = 0
-               local furnace_is_cookin = 0
-               local cooked = nil
-               meta:set_float("internal_EU_buffer",0)
-               meta:set_float("internal_EU_buffer_size",2000)
-
-       end,
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               if not inv:is_empty("dst") then
-                       return false
-               elseif not inv:is_empty("src") then
-                       return false
-               end
-               return true
-       end,
-})
-
-minetest.register_node("technic:electric_furnace_active", {
-       description = "Electric Furnace",
-       tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
-               "technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front_active.png"},
-       paramtype2 = "facedir",
-       light_source = 8,
-       drop = "technic:electric_furnace",
-       groups = {cracky=2, not_in_creative_inventory=1},
-       legacy_facedir_simple = true,
-       sounds = default.node_sound_stone_defaults(),
-       internal_EU_buffer=0;
-       interal_EU_buffer_size=2000;
-       technic_power_machine=1,
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_float("technic_power_machine", 1)
-               meta:set_string("formspec", electric_furnace_formspec)
-               meta:set_string("infotext", "Electric furnace");
-               local inv = meta:get_inventory()
-               inv:set_size("src", 1)
-               inv:set_size("dst", 4)
-               local EU_used  = 0
-               local furnace_is_cookin = 0
-               local cooked = nil
-       end,
-       can_dig = function(pos,player)
-               local meta = minetest.env:get_meta(pos);
-               local inv = meta:get_inventory()
-               if not inv:is_empty("dst") then
-                       return false
-               elseif not inv:is_empty("src") then
-                       return false
-               end
-               return true
-       end,
-})
-
-minetest.register_abm({
-       nodenames = {"technic:electric_furnace","technic:electric_furnace_active"},
-       interval = 1,
-       chance = 1,
-       
-       action = function(pos, node, active_object_count, active_object_count_wider)
-
-               local meta = minetest.env:get_meta(pos)
-               internal_EU_buffer=meta:get_float("internal_EU_buffer")
-               internal_EU_buffer_size=meta:get_float("internal_EU_buffer")
-               local load = math.floor(internal_EU_buffer/2000 * 100)
-               meta:set_string("formspec",
-                               "invsize[8,9;]"..
-                               "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
-                                               (load)..":technic_power_meter_fg.png]"..
-                               "list[current_name;src;3,1;1,1;]"..
-                               "list[current_name;dst;5,1;2,2;]"..
-                               "list[current_player;main;0,5;8,4;]"..
-                               "label[0,0;Electric Furnace]"..
-                               "label[1,3;Power level]")
-
-               local inv = meta:get_inventory()
-               
-               local furnace_is_cookin = meta:get_float("furnace_is_cookin")
-               
-               
-               local srclist = inv:get_list("src")
-               local cooked=nil 
-
-               if srclist then
-                cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
-               end
-               
-               
-               if (furnace_is_cookin == 1) then
-                       if internal_EU_buffer>=150 then
-                       internal_EU_buffer=internal_EU_buffer-150;
-                       meta:set_float("internal_EU_buffer",internal_EU_buffer)
-                       meta:set_float("src_time", meta:get_float("src_time") + 3)
-                       if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
-                               -- check if there's room for output in "dst" list
-                               if inv:room_for_item("dst",cooked.item) then
-                                       -- Put result in "dst" list
-                                       inv:add_item("dst", cooked.item)
-                                       -- take stuff from "src" list
-                                       srcstack = inv:get_stack("src", 1)
-                                       srcstack:take_item()
-                                       inv:set_stack("src", 1, srcstack)
-                               else
-                                       print("Furnace inventory full!")
-                               end
-                               meta:set_string("src_time", 0)
-                       end
-                       end             
-               end
-               
-               
-
-               
-               if srclist then
-                       cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
-                       if cooked.time>0 then 
-                       hacky_swap_node(pos,"technic:electric_furnace_active")
-                       meta:set_string("infotext","Furnace active")
-                       meta:set_string("furnace_is_cookin",1)
-               --      meta:set_string("formspec", electric_furnace_formspec)
-                       meta:set_string("src_time", 0)
-                       return
-                       end
-
-               end
-       
-                               hacky_swap_node(pos,"technic:electric_furnace")
-                               meta:set_string("infotext","Furnace inactive")
-                               meta:set_string("furnace_is_cookin",0)
-               --              meta:set_string("formspec", electric_furnace_formspec)
-                               meta:set_string("src_time", 0)
-               
-       
-end,           
-})
-
-
-
-
-function take_EU_from_net(pos, EU_to_take)
-       local meta = minetest.env:get_meta(pos)
-       local pos1=pos
-       pos1.z=pos1.z +1
-       local meta1 = minetest.env:get_meta(pos1)
-       charge=meta1:get_float("battery_charge")
-       charge=charge - EU_to_take
-       meta1:set_float("battery_charge",charge)
-end
-
-       LV_nodes_visited = {}
-
-function get_RE_item_load (load1,max_load)
-if load1==0 then load1=65535 end
-local temp = 65536-load1
-temp= temp/65535*max_load
-return math.floor(temp + 0.5)
-end
-
-function set_RE_item_load (load1,max_load)
-if load1 == 0 then return 65535 end
-local temp=load1/max_load*65535
-temp=65536-temp
-return math.floor(temp)
-end
-
-minetest.register_abm({
-       nodenames = {"technic:battery_box"},
-       interval = 1,
-       chance = 1,
-       action = function(pos, node, active_object_count, active_object_count_wider)
-       local meta = minetest.env:get_meta(pos)
-       charge= meta:get_float("battery_charge")
-       max_charge= 60000
-               
-               local inv = meta:get_inventory()
-               if inv:is_empty("src")==false  then 
-               srcstack = inv:get_stack("src", 1)
-               src_item=srcstack:to_table()
-               if src_item["name"]== "technic:battery" then
-               local load1=tonumber((src_item["wear"])) 
-               load1=get_RE_item_load(load1,10000)
-               load_step=1000
-               if load1<10000 and charge>0 then 
-                if charge-load_step<0 then load_step=charge end
-                if load1+load_step>10000 then load_step=10000-load1 end
-               load1=load1+load_step
-               charge=charge-load_step
-       
-               load1=set_RE_item_load(load1,10000)
-               src_item["wear"]=tostring(load1)
-               inv:set_stack("src", 1, src_item)
-               end             
-               end
-               end
-               meta:set_float("battery_charge",charge)
-               
-       
-               if inv:is_empty("src")==false  then 
-               srcstack = inv:get_stack("src", 1)
-               src_item=srcstack:to_table()
-               if src_item["name"]== "technic:laser_mk1" then
-               local load1=tonumber((src_item["wear"])) 
-               load1=get_RE_item_load(load1,40000)
-               load_step=1000
-               if load1<40000 and charge>0 then 
-                if charge-load_step<0 then load_step=charge end
-                if load1+load_step>40000 then load_step=40000-load1 end
-               load1=load1+load_step
-               charge=charge-load_step
-               load1=set_RE_item_load(load1,40000)
-               src_item["wear"]=tostring(load1)
-               inv:set_stack("src", 1, src_item)
-               end             
-               end
-               end
-               meta:set_float("battery_charge",charge)
-
-
-               if inv:is_empty("dst") == false then 
-               srcstack = inv:get_stack("dst", 1)
-               src_item=srcstack:to_table()
-               if src_item["name"]== "technic:battery" then
-               local load1=tonumber((src_item["wear"])) 
-               load1=get_RE_item_load(load1,10000)
-               load_step=1000
-               if load1>0 and charge<max_charge then 
-                        if charge+load_step>max_charge then load_step=max_charge-charge end
-                        if load1-load_step<0 then load_step=load1 end
-               load1=load1-load_step
-               charge=charge+load_step
-       
-               load1=set_RE_item_load(load1,10000)
-               src_item["wear"]=tostring(load1)
-               inv:set_stack("dst", 1, src_item)
-               end             
-               end
-               end
-               
-
-       meta:set_float("battery_charge",charge)
-       meta:set_string("infotext", "Battery box: "..charge.."/"..max_charge);
-
-       local load = math.floor(charge/60000 * 100)
-       meta:set_string("formspec",
-                               "invsize[8,9;]"..
-                               "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
-                                               (load)..":technic_power_meter_fg.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;Battery box]"..
-                               "label[3,0;Charge]"..
-                               "label[5,0;Discharge]"..
-                               "label[1,3;Power level]"..
-                               "list[current_player;main;0,5;8,4;]")
-               
-       local pos1={}
-
-       pos1.y=pos.y-1
-       pos1.x=pos.x
-       pos1.z=pos.z
-
-
-       meta1 = minetest.env:get_meta(pos1)
-       if meta1:get_float("cablelike")~=1 then return end
-
-               local LV_nodes = {}
-               local PR_nodes = {}
-               local RE_nodes = {}
-
-               LV_nodes[1]={}
-               LV_nodes[1].x=pos1.x
-               LV_nodes[1].y=pos1.y
-               LV_nodes[1].z=pos1.z
-               LV_nodes[1].visited=false
-
-
-table_index=1
-       repeat
-       check_LV_node (PR_nodes,RE_nodes,LV_nodes,table_index)
-       table_index=table_index+1
-       if LV_nodes[table_index]==nil then break end
-       until false
-
-
-local pos1={}
-i=1
-       repeat
-       if PR_nodes[i]==nil then break end
-               pos1.x=PR_nodes[i].x
-               pos1.y=PR_nodes[i].y
-               pos1.z=PR_nodes[i].z
-       local meta1 = minetest.env:get_meta(pos1)
-       local active=meta1:get_float("active")
-       if active==1 then charge=charge+80 end
-       i=i+1
-       until false
-
-if charge>max_charge then charge=max_charge end
-
-i=1
-       repeat
-       if RE_nodes[i]==nil then break end
-               pos1.x=RE_nodes[i].x         -- loading all conected machines buffers
-               pos1.y=RE_nodes[i].y
-               pos1.z=RE_nodes[i].z
-       local meta1 = minetest.env:get_meta(pos1)
-       local internal_EU_buffer=meta1:get_float("internal_EU_buffer")
-       local internal_EU_buffer_size=meta1:get_float("internal_EU_buffer_size")
-
-       local charge_to_give=200
-       if internal_EU_buffer+charge_to_give>internal_EU_buffer_size then
-               charge_to_give=internal_EU_buffer_size-internal_EU_buffer
-       end
-       if charge-charge_to_give<0 then charge_to_give=charge end
-
-       internal_EU_buffer=internal_EU_buffer+charge_to_give
-       meta1:set_float("internal_EU_buffer",internal_EU_buffer)
-       charge=charge-charge_to_give;
-       
-       i=i+1
-       until false
-       
-       meta:set_float("battery_charge",charge)
-       meta:set_string("infotext", "Battery box: "..charge.."/"..max_charge);
-
-
-end
-})
-
-function add_new_cable_node (LV_nodes,pos1)
-local i=1
-       repeat
-               if LV_nodes[i]==nil then break end
-               if pos1.x==LV_nodes[i].x and pos1.y==LV_nodes[i].y and pos1.z==LV_nodes[i].z then return false end
-               i=i+1
-       until false
-LV_nodes[i]={}
-LV_nodes[i].x=pos1.x
-LV_nodes[i].y=pos1.y
-LV_nodes[i].z=pos1.z
-LV_nodes[i].visited=false
-return true
-end
-
-function check_LV_node (PR_nodes,RE_nodes,LV_nodes,i)
-               local pos1={}
-               pos1.x=LV_nodes[i].x
-               pos1.y=LV_nodes[i].y
-               pos1.z=LV_nodes[i].z
-               LV_nodes[i].visited=true
-               new_node_added=false
-       
-               pos1.x=pos1.x+1
-               check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
-               pos1.x=pos1.x-2
-               check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
-               pos1.x=pos1.x+1
-               
-               pos1.y=pos1.y+1
-               check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
-               pos1.y=pos1.y-2
-               check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
-               pos1.y=pos1.y+1
-
-               pos1.z=pos1.z+1
-               check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
-               pos1.z=pos1.z-2
-               check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
-               pos1.z=pos1.z+1
-return new_node_added
-end
-
-function check_LV_node_subp (PR_nodes,RE_nodes,LV_nodes,pos1)
-meta = minetest.env:get_meta(pos1)
-if meta:get_float("cablelike")==1 then new_node_added=add_new_cable_node(LV_nodes,pos1) end
-if minetest.env:get_node(pos1).name == "technic:solar_panel" then      new_node_added=add_new_cable_node(PR_nodes,pos1) end            
-if minetest.env:get_node(pos1).name == "technic:electric_furnace" then         new_node_added=add_new_cable_node(RE_nodes,pos1) end            
-if minetest.env:get_node(pos1).name == "technic:electric_furnace_active" then  new_node_added=add_new_cable_node(RE_nodes,pos1) end            
-if minetest.env:get_node(pos1).name == "technic:tool_workshop" then    new_node_added=add_new_cable_node(RE_nodes,pos1) end            
-if minetest.env:get_node(pos1).name == "technic:music_player" then     new_node_added=add_new_cable_node(RE_nodes,pos1) end            
-if minetest.env:get_node(pos1).name == "technic:grinder" then  new_node_added=add_new_cable_node(RE_nodes,pos1) end            
-end
-               
-
-function get_connected_charge (charge,pos1)
-       local charge1=0
-       local meta={}
-       if minetest.env:get_node(pos1).name == "technic:battery_box" then
-       print ("found batbox")
-       meta = minetest.env:get_meta(pos1)
-       return meta:get_float("cable_OUT") 
-       end
-
-       if minetest.env:get_node(pos1).name == "technic:lv_cable" then
-       meta = minetest.env:get_meta(pos1)
-       charge1=meta:get_float("cable_OUT")
-               if charge1>charge then
-               charge=charge1
-               end
-       end
-return charge
-end
-
-minetest.register_node("technic:solar_panel", {
-       tiles = {"technic_solar_panel_top.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png",
-               "technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       sounds = default.node_sound_wood_defaults(),
-       description="Solar Panel",
-       active = false,
-       technic_power_machine=1,
-       drawtype = "nodebox",
-       paramtype = "light",
-       is_ground_content = true,       
-       node_box = {
-                       type = "fixed",
-                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
-               },
-               selection_box = {
-                       type = "fixed",
-                       fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
-               },
-       on_construct = function(pos)
-               local meta = minetest.env:get_meta(pos)
-               meta:set_float("technic_power_machine", 1)
-               meta:set_string("infotext", "Solar Panel")
-               meta:set_float("active", false)
-       end,
-})
-
-minetest.register_craft({
-       output = 'technic:solar_panel 1',
-       recipe = {
-               {'default:sand', 'default:sand',         'default:sand'},
-               {'default:sand', 'default:copper_ingot', 'default:sand'},
-               {'default:sand', 'default:sand',         'default:sand'},
-
-       }
-})
-
-minetest.register_abm(
-       {nodenames = {"technic:solar_panel"},
-       interval = 1,
-       chance = 1,
-       action = function(pos, node, active_object_count, active_object_count_wider)
-               
-               local pos1={}
-               pos1.y=pos.y+1
-               pos1.x=pos.x
-               pos1.z=pos.z
-
-               local light = minetest.env:get_node_light(pos1, nil)
-               local meta = minetest.env:get_meta(pos)
-               if light == nil then light = 0 end
-               if light >= 12 then
-                       meta:set_string("infotext", "Solar Panel is active ")
-                       meta:set_float("active",1)
-               else
-                       meta:set_string("infotext", "Solar Panel is inactive");
-                       meta:set_float("active",0)
-               end
-       end,
-}) 
diff --git a/technic/water_mill.lua b/technic/water_mill.lua
deleted file mode 100644 (file)
index a7e8ce4..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
--- A water mill produces LV EUs by exploiting flowing water across it
--- It is a LV EU supplyer and fairly low yield (max 120EUs)
--- It is a little under half as good as the thermal generator.
-minetest.register_alias("water_mill", "technic:water_mill")
-
-minetest.register_craft({
-       output = 'technic:water_mill',
-       recipe = {
-               {'default:stone', 'default:stone', 'default:stone'},
-               {'default:wood', 'default:diamond', 'default:wood'},
-               {'default:stone', 'default:copper_ingot', 'default:stone'},
-       }
-})
-
-minetest.register_craftitem("technic:water_mill", {
-       description = "Water Mill",
-       stack_max = 99,
-}) 
-
-local water_mill_formspec =
-       "invsize[8,4;]"..
-       "image[1,1;1,2;technic_power_meter_bg.png]"..
-       "label[0,0;Water Mill]"..
-       "label[1,3;Power level]"..
-       "list[current_player;main;0,5;8,4;]"
-       
-
-minetest.register_node(
-   "technic:water_mill",
-   {
-      description = "Water Mill",
-      tiles = {"technic_water_mill_top.png", "technic_machine_bottom.png", "technic_water_mill_side.png",
-              "technic_water_mill_side.png", "technic_water_mill_side.png", "technic_water_mill_side.png"},
-      paramtype2 = "facedir",
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_wood_defaults(),
-      on_construct = function(pos)
-                       local meta = minetest.env:get_meta(pos)
-                       meta:set_string("infotext", "Water Mill")
-                       meta:set_float("technic_power_machine", 1)
-                       meta:set_int("LV_EU_supply", 0)
-                       meta:set_string("formspec", water_mill_formspec)        
-                    end,       
-   })
-
-minetest.register_node(
-   "technic:water_mill_active",
-   {
-      description = "Water Mill",
-      tiles = {"technic_water_mill_top_active.png", "technic_machine_bottom.png", "technic_water_mill_side.png",
-              "technic_water_mill_side.png", "technic_water_mill_side.png", "technic_water_mill_side.png"},
-      paramtype2 = "facedir",
-      groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
-      legacy_facedir_simple = true,
-      sounds = default.node_sound_wood_defaults(),
-      drop="technic:water_mill",
-})
-
-local check_node_around_mill = function(pos)
-                                 local node=minetest.env:get_node(pos)
-                                 if node.name=="default:water_flowing" then return 1 end
-                                 return 0
-                              end
-
-minetest.register_abm(
-   {
-      nodenames = {"technic:water_mill","technic:water_mill_active"},
-      interval = 1,
-      chance   = 1,
-      action = function(pos, node, active_object_count, active_object_count_wider)
-                 local meta             = minetest.env:get_meta(pos)
-                 local water_nodes      = 0
-                 local lava_nodes       = 0
-                 local production_level = 0
-                 local eu_supply        = 0
-
-                 pos.x=pos.x+1
-                 local check=check_node_around_mill (pos)
-                 if check==1 then water_nodes=water_nodes+1 end
-                 pos.x=pos.x-2
-                 check=check_node_around_mill (pos)
-                 if check==1 then water_nodes=water_nodes+1 end
-                 pos.x=pos.x+1
-                 pos.z=pos.z+1
-                 check=check_node_around_mill (pos)
-                 if check==1 then water_nodes=water_nodes+1 end
-                 pos.z=pos.z-2
-                 check=check_node_around_mill (pos)
-                 if check==1 then water_nodes=water_nodes+1 end
-                 pos.z=pos.z+1
-       
-                 if water_nodes==1 then production_level =  25; eu_supply =  30 end
-                 if water_nodes==2 then production_level =  50; eu_supply =  60 end
-                 if water_nodes==3 then production_level =  75; eu_supply =  90 end
-                 if water_nodes==4 then production_level = 100; eu_supply = 120 end
-
-                 if production_level>0 then
-                    meta:set_int("LV_EU_supply", eu_supply)
-                 end
-
-                 local load = 1 -- math.floor((charge/max_charge)*100)
-                 meta:set_string("formspec",
-                                 "invsize[8,4;]"..
-                                    "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
-                                    (load)..":technic_power_meter_fg.png]"..
-                                 "label[0,0;Water Mill]"..
-                                 "label[1,3;Power level]"..
-                                 "label[4,0;Production at "..tostring(production_level).."%]"
-                           )
-                               
-                 if production_level>0 and minetest.env:get_node(pos).name=="technic:water_mill" then
-                    hacky_swap_node (pos,"technic:water_mill_active")
-                    meta:set_int("LV_EU_supply", 0)
-                    return
-                 end
-                 if production_level==0 then hacky_swap_node (pos,"technic:water_mill") end
-              end
-   }) 
-
-technic.register_LV_machine ("technic:water_mill","PR")
-technic.register_LV_machine ("technic:water_mill_active","PR")
diff --git a/technic/wires.lua b/technic/wires.lua
deleted file mode 100644 (file)
index db8c823..0000000
+++ /dev/null
@@ -1,401 +0,0 @@
---LV cable node boxes
-
-
-minetest.register_alias("lv_cable", "technic:lv_cable")
-
-minetest.register_craft({
-       output = 'technic:lv_cable 6',
-       recipe = {
-               {'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
-       }
-}) 
-
-minetest.register_craftitem("technic:lv_cable", {
-       description = "Low Voltage Copper Cable",
-       stack_max = 99,
-}) 
-
-minetest.register_node("technic:lv_cable", {
-       description = "Low Voltage Copper Cable",
-       tiles = {"technic_lv_cable.png"},
-       inventory_image = "technic_lv_cable_wield.png",
-       wield_image = "technic_lv_cable_wield.png",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       sounds = default.node_sound_wood_defaults(),
-       drop = "technic:lv_cable",
-       cablelike=1,
-       rules_x1=0,
-       rules_x2=0,
-       rules_y1=0,
-       rules_y2=0,
-       rules_z1=0,
-       rules_z2=0,
-       paramtype = "light",
-        drawtype = "nodebox", 
-       selection_box = {
-               type = "fixed",
-                fixed = {
-               { -0.1 , -0.1 , -0.1 , 0.1 ,  0.1 , 0.1  },
-               }},
-       node_box = {
-               type = "fixed",
-                fixed = {
-               { -0.1 , -0.1 , -0.1 , 0.1 ,  0.1 , 0.1  },
-               }},
-       on_construct = function(pos)
-       meta=minetest.env:get_meta(pos)
-       meta:set_float("cablelike",1)
-       meta:set_float("x1",0)
-       meta:set_float("x2",0)
-       meta:set_float("y1",0)
-       meta:set_float("y2",0)
-       meta:set_float("z1",0)
-       meta:set_float("z2",0)
-       check_connections (pos)
-       end,
-
-       after_dig_node = function (pos, oldnode, oldmetadata, digger)
-       check_connections_on_destroy (pos)
-       end,
-
-})
-
-
-str_y1=                { -0.1 , -0.1 , -0.1 , 0.1 , 0.5, 0.1  }    --0 y+
-str_x1=                { -0.1 , -0.1 , -0.1 , 0.5, 0.1 , 0.1  }    --0 x+
-str_z1=                { -0.1 , -0.1 ,  0.1 ,  0.1 , 0.1 , 0.5 }   --0 z+
-str_z2=                { -0.1 , -0.1, -0.5 ,  0.1 ,  0.1 , 0.1  }  --0 z-
-str_y2=                { -0.1 , -0.5, -0.1 ,  0.1 ,  0.1 , 0.1  }  --0 y-
-str_x2=                { -0.5 , -0.1, -0.1 ,  0.1 ,  0.1 , 0.1  }  --0 x-
-
-
-
-local x1,x2,y1,y2,z1,z2
-local count=0
-
-for x1 = 0, 1, 1 do    --x-
-for x2 = 0, 1, 1 do    --x+
-for y1 = 0, 1, 1 do    --y-
-for y2 = 0, 1, 1 do    --y-    
-for z1 = 0, 1, 1 do    --z-
-for z2 = 0, 1, 1 do    --z+
-     
-temp_x1={} temp_x2={} temp_y1={} temp_y2={} temp_z1={} temp_z2={}
-
-if x1==1 then  temp_x1=str_x1  end 
-if x2==1 then  temp_x2=str_x2  end 
-if y1==1 then  temp_y1=str_y1  end 
-if y2==1 then  temp_y2=str_y2  end 
-if z1==1 then  temp_z1=str_z1  end 
-if z2==1 then  temp_z2=str_z2  end 
-
-
-minetest.register_node("technic:lv_cable"..count, {
-       description = "Low Voltage Copper Cable",
-       tiles = {"technic_lv_cable.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
-       sounds = default.node_sound_wood_defaults(),
-       drop = "technic:lv_cable",
-       rules_x1=0,
-       rules_x2=0,
-       rules_y1=0,
-       rules_y2=0,
-       rules_z1=0,
-       rules_z2=0,
-       cablelike=1,
-       paramtype = "light",
-        drawtype = "nodebox", 
-       selection_box = {
-               type = "fixed",
-           fixed = {
-               temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
-               }},
-
-       node_box = {
-               type = "fixed",
-           fixed = {
-               temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
-               }},
-
-       after_dig_node = function (pos, oldnode, oldmetadata, digger)
-       check_connections_on_destroy (pos)
-       end,
-       
-})
-
-count=count+1 end end end end end end
-
-check_connections = function(pos)
-               local pos1={}
-               pos1.x=pos.x
-               pos1.y=pos.y
-               pos1.z=pos.z
-               
-               pos1.x=pos1.x+1
-               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
-               x2=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:lv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("x2",x2)
-               meta=minetest.env:get_meta(pos)
-               x1=1
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("x1",x1)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:lv_cable"..rule)
-               end
-
-               pos1.x=pos1.x-2
-               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
-               x1=1
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:lv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("x1",x1)
-               meta=minetest.env:get_meta(pos)
-               x2=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("x2",x2)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:lv_cable"..rule)
-               end
-
-               pos1.x=pos1.x+1
-               
-               pos1.y=pos1.y+1
-               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
-               y2=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:lv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("y2",y2)
-               meta=minetest.env:get_meta(pos)
-               y1=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("y1",y1)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:lv_cable"..rule)
-               end
-               
-               if minetest.env:get_meta(pos1):get_float("technic_power_machine")==1 then
-               y1=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:lv_cable"..rule)
-               meta=minetest.env:get_meta(pos)
-               meta:set_float("y1",y1)
-               end
-
-
-               pos1.y=pos1.y-2
-               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
-               y1=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:lv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("y1",y1)
-               meta=minetest.env:get_meta(pos)
-               y2=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("y2",y2)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:lv_cable"..rule)
-               end
-               pos1.y=pos1.y+1
-
-               pos1.z=pos1.z+1
-               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
-               z2=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:lv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("z2",z2)
-               meta=minetest.env:get_meta(pos)
-               z1=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("z1",z1)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:lv_cable"..rule)
-               end
-               pos1.z=pos1.z-2
-               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
-               z1=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:lv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("z1",z1)
-               meta=minetest.env:get_meta(pos)
-               z2=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               meta:set_float("z2",z2)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:lv_cable"..rule)
-               end
-               pos1.z=pos1.z+1
-end    
-
-function make_rule_number (x1,x2,y1,y2,z1,z2)
-local temp= z2+z1*2+y2*4+y1*8+x2*16+x1*32
-return temp
-end
-
-check_connections_on_destroy = function(pos)
-               local pos1={}
-               pos1.x=pos.x
-               pos1.y=pos.y
-               pos1.z=pos.z
-               
-               pos1.x=pos1.x+1
-               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
-               x2=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("x2",x2)
-               end
-               
-               pos1.x=pos1.x-2
-               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
-               x1=0
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("x1",x1)
-               end
-               pos1.x=pos1.x+1
-
-               pos1.y=pos1.y+1
-               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
-               y2=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("y2",y2)
-               end
-               
-               pos1.y=pos1.y-2
-               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
-               y1=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("y1",y1)
-               end
-               pos1.y=pos1.y+1
-
-               pos1.z=pos1.z+1
-               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
-               z2=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("z2",z2)
-               end
-               
-               pos1.z=pos1.z-2
-               if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
-               z1=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("z1",z1)
-               end
-               pos1.y=pos1.y+1
-               
-end    
-
diff --git a/technic/wires_hv.lua b/technic/wires_hv.lua
deleted file mode 100644 (file)
index b2c9834..0000000
+++ /dev/null
@@ -1,398 +0,0 @@
---HV cable node boxes
-
-
-minetest.register_craft({
-       output = 'technic:hv_cable 3',
-       recipe ={
-               {'technic:rubber','technic:rubber','technic:rubber'},
-               {'technic:mv_cable','technic:mv_cable','technic:mv_cable'},
-               {'technic:rubber','technic:rubber','technic:rubber'},
-               }
-}) 
-
-
-minetest.register_craftitem("technic:hv_cable", {
-       description = "Gigh Voltage Copper Cable",
-       stack_max = 99,
-}) 
-
-minetest.register_node("technic:hv_cable", {
-       description = "High Voltage Copper Cable",
-       tiles = {"technic_hv_cable.png"},
-       inventory_image = "technic_hv_cable_wield.png",
-       wield_image = "technic_hv_cable_wield.png",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       sounds = default.node_sound_wood_defaults(),
-       drop = "technic:hv_cable",
-       hv_cablelike=1,
-       rules_x1=0,
-       rules_x2=0,
-       rules_y1=0,
-       rules_y2=0,
-       rules_z1=0,
-       rules_z2=0,
-       paramtype = "light",
-        drawtype = "nodebox", 
-       selection_box = {
-               type = "fixed",
-                fixed = {
-               { -0.1 , -0.1 , -0.1 , 0.1 ,  0.1 , 0.1  },
-               }},
-       node_box = {
-               type = "fixed",
-                fixed = {
-               { -0.125 , -0.125 , -0.125 , 0.125 ,  0.125 , 0.125  },
-               }},
-       on_construct = function(pos)
-       meta=minetest.env:get_meta(pos)
-       meta:set_float("hv_cablelike",1)
-       meta:set_float("x1",0)
-       meta:set_float("x2",0)
-       meta:set_float("y1",0)
-       meta:set_float("y2",0)
-       meta:set_float("z1",0)
-       meta:set_float("z2",0)
-       HV_check_connections (pos)
-       end,
-
-       after_dig_node = function (pos, oldnode, oldmetadata, digger)
-       HV_check_connections_on_destroy (pos)
-       end,
-
-})
-
-
-str_y1=                { -0.125 , -0.125 , -0.125 , 0.125 , 0.5, 0.125  }    --0 y+
-str_x1=                { -0.125 , -0.125 , -0.125 , 0.5, 0.125 , 0.125  }    --0 x+
-str_z1=                { -0.125 , -0.125 ,  0.125 ,  0.125 , 0.125 , 0.5 }   --0 z+
-str_z2=                { -0.125 , -0.125, -0.5 ,  0.125 ,  0.125 , 0.125  }  --0 z-
-str_y2=                { -0.125 , -0.5, -0.125 ,  0.125 ,  0.125 , 0.125  }  --0 y-
-str_x2=                { -0.5 , -0.125, -0.125 ,  0.125 ,  0.125 , 0.125  }  --0 x-
-
-
-
-local x1,x2,y1,y2,z1,z2
-local count=0
-
-for x1 = 0, 1, 1 do    --x-
-for x2 = 0, 1, 1 do    --x+
-for y1 = 0, 1, 1 do    --y-
-for y2 = 0, 1, 1 do    --y-    
-for z1 = 0, 1, 1 do    --z-
-for z2 = 0, 1, 1 do    --z+
-     
-temp_x1={} temp_x2={} temp_y1={} temp_y2={} temp_z1={} temp_z2={}
-
-if x1==1 then  temp_x1=str_x1  end 
-if x2==1 then  temp_x2=str_x2  end 
-if y1==1 then  temp_y1=str_y1  end 
-if y2==1 then  temp_y2=str_y2  end 
-if z1==1 then  temp_z1=str_z1  end 
-if z2==1 then  temp_z2=str_z2  end 
-
-
-minetest.register_node("technic:hv_cable"..count, {
-       description = "Gigh Voltage Copper Cable",
-       tiles = {"technic_hv_cable.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
-       sounds = default.node_sound_wood_defaults(),
-       drop = "technic:hv_cable",
-       rules_x1=0,
-       rules_x2=0,
-       rules_y1=0,
-       rules_y2=0,
-       rules_z1=0,
-       rules_z2=0,
-       cablelike=1,
-       paramtype = "light",
-        drawtype = "nodebox", 
-       selection_box = {
-               type = "fixed",
-           fixed = {
-               temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
-               }},
-
-       node_box = {
-               type = "fixed",
-           fixed = {
-               temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
-               }},
-
-       after_dig_node = function (pos, oldnode, oldmetadata, digger)
-       HV_check_connections_on_destroy (pos)
-       end,
-       
-})
-
-count=count+1 end end end end end end
-
-HV_check_connections = function(pos)
-               local pos1={}
-               pos1.x=pos.x
-               pos1.y=pos.y
-               pos1.z=pos.z
-               
-               pos1.x=pos1.x+1
-               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
-               x2=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:hv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("x2",x2)
-               meta=minetest.env:get_meta(pos)
-               x1=1
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("x1",x1)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:hv_cable"..rule)
-               end
-
-               pos1.x=pos1.x-2
-               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
-               x1=1
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:hv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("x1",x1)
-               meta=minetest.env:get_meta(pos)
-               x2=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("x2",x2)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:hv_cable"..rule)
-               end
-
-               pos1.x=pos1.x+1
-               
-               pos1.y=pos1.y+1
-               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
-               y2=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:hv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("y2",y2)
-               meta=minetest.env:get_meta(pos)
-               y1=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("y1",y1)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:hv_cable"..rule)
-               end
-               
-               if minetest.env:get_meta(pos1):get_float("technic_hv_power_machine")==1 then
-               y1=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:hv_cable"..rule)
-               meta=minetest.env:get_meta(pos)
-               meta:set_float("y1",y1)
-               end
-
-
-               pos1.y=pos1.y-2
-               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
-               y1=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:hv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("y1",y1)
-               meta=minetest.env:get_meta(pos)
-               y2=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("y2",y2)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:hv_cable"..rule)
-               end
-               pos1.y=pos1.y+1
-
-               pos1.z=pos1.z+1
-               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
-               z2=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:hv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("z2",z2)
-               meta=minetest.env:get_meta(pos)
-               z1=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("z1",z1)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:hv_cable"..rule)
-               end
-               pos1.z=pos1.z-2
-               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
-               z1=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:hv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("z1",z1)
-               meta=minetest.env:get_meta(pos)
-               z2=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               meta:set_float("z2",z2)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:hv_cable"..rule)
-               end
-               pos1.z=pos1.z+1
-end    
-
-
-HV_check_connections_on_destroy = function(pos)
-               local pos1={}
-               pos1.x=pos.x
-               pos1.y=pos.y
-               pos1.z=pos.z
-               
-               pos1.x=pos1.x+1
-               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
-               x2=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("x2",x2)
-               end
-               
-               pos1.x=pos1.x-2
-               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
-               x1=0
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("x1",x1)
-               end
-               pos1.x=pos1.x+1
-
-               pos1.y=pos1.y+1
-               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
-               y2=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("y2",y2)
-               end
-               
-               pos1.y=pos1.y-2
-               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
-               y1=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("y1",y1)
-               end
-               pos1.y=pos1.y+1
-
-               pos1.z=pos1.z+1
-               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
-               z2=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("z2",z2)
-               end
-               
-               pos1.z=pos1.z-2
-               if minetest.env:get_meta(pos1):get_float("hv_cablelike")==1 then
-               z1=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:hv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("z1",z1)
-               end
-               pos1.y=pos1.y+1
-               
-end    
-
diff --git a/technic/wires_mv.lua b/technic/wires_mv.lua
deleted file mode 100644 (file)
index 7924956..0000000
+++ /dev/null
@@ -1,400 +0,0 @@
---MV cable node boxes
-
-
-minetest.register_alias("mv_cable", "technic:mv_cable")
-
-minetest.register_craft({
-       output = 'technic:mv_cable 3',
-       recipe ={
-               {'technic:rubber','technic:rubber','technic:rubber'},
-               {'technic:lv_cable','technic:lv_cable','technic:lv_cable'},
-               {'technic:rubber','technic:rubber','technic:rubber'},
-               }
-}) 
-
-
-minetest.register_craftitem("technic:mv_cable", {
-       description = "Medium Voltage Copper Cable",
-       stack_max = 99,
-}) 
-
-minetest.register_node("technic:mv_cable", {
-       description = "Medium Voltage Copper Cable",
-       tiles = {"technic_mv_cable.png"},
-       inventory_image = "technic_mv_cable_wield.png",
-       wield_image = "technic_mv_cable_wield.png",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       sounds = default.node_sound_wood_defaults(),
-       drop = "technic:mv_cable",
-       mv_cablelike=1,
-       rules_x1=0,
-       rules_x2=0,
-       rules_y1=0,
-       rules_y2=0,
-       rules_z1=0,
-       rules_z2=0,
-       paramtype = "light",
-        drawtype = "nodebox", 
-       selection_box = {
-               type = "fixed",
-                fixed = {
-               { -0.1 , -0.1 , -0.1 , 0.1 ,  0.1 , 0.1  },
-               }},
-       node_box = {
-               type = "fixed",
-                fixed = {
-               { -0.1 , -0.1 , -0.1 , 0.1 ,  0.1 , 0.1  },
-               }},
-       on_construct = function(pos)
-       meta=minetest.env:get_meta(pos)
-       meta:set_float("mv_cablelike",1)
-       meta:set_float("x1",0)
-       meta:set_float("x2",0)
-       meta:set_float("y1",0)
-       meta:set_float("y2",0)
-       meta:set_float("z1",0)
-       meta:set_float("z2",0)
-       MV_check_connections (pos)
-       end,
-
-       after_dig_node = function (pos, oldnode, oldmetadata, digger)
-       MV_check_connections_on_destroy (pos)
-       end,
-
-})
-
-
-str_y1=                { -0.1 , -0.1 , -0.1 , 0.1 , 0.5, 0.1  }    --0 y+
-str_x1=                { -0.1 , -0.1 , -0.1 , 0.5, 0.1 , 0.1  }    --0 x+
-str_z1=                { -0.1 , -0.1 ,  0.1 ,  0.1 , 0.1 , 0.5 }   --0 z+
-str_z2=                { -0.1 , -0.1, -0.5 ,  0.1 ,  0.1 , 0.1  }  --0 z-
-str_y2=                { -0.1 , -0.5, -0.1 ,  0.1 ,  0.1 , 0.1  }  --0 y-
-str_x2=                { -0.5 , -0.1, -0.1 ,  0.1 ,  0.1 , 0.1  }  --0 x-
-
-
-
-local x1,x2,y1,y2,z1,z2
-local count=0
-
-for x1 = 0, 1, 1 do    --x-
-for x2 = 0, 1, 1 do    --x+
-for y1 = 0, 1, 1 do    --y-
-for y2 = 0, 1, 1 do    --y-    
-for z1 = 0, 1, 1 do    --z-
-for z2 = 0, 1, 1 do    --z+
-     
-temp_x1={} temp_x2={} temp_y1={} temp_y2={} temp_z1={} temp_z2={}
-
-if x1==1 then  temp_x1=str_x1  end 
-if x2==1 then  temp_x2=str_x2  end 
-if y1==1 then  temp_y1=str_y1  end 
-if y2==1 then  temp_y2=str_y2  end 
-if z1==1 then  temp_z1=str_z1  end 
-if z2==1 then  temp_z2=str_z2  end 
-
-
-minetest.register_node("technic:mv_cable"..count, {
-       description = "Medium Voltage Copper Cable",
-       tiles = {"technic_mv_cable.png"},
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
-       sounds = default.node_sound_wood_defaults(),
-       drop = "technic:mv_cable",
-       rules_x1=0,
-       rules_x2=0,
-       rules_y1=0,
-       rules_y2=0,
-       rules_z1=0,
-       rules_z2=0,
-       cablelike=1,
-       paramtype = "light",
-        drawtype = "nodebox", 
-       selection_box = {
-               type = "fixed",
-           fixed = {
-               temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
-               }},
-
-       node_box = {
-               type = "fixed",
-           fixed = {
-               temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
-               }},
-
-       after_dig_node = function (pos, oldnode, oldmetadata, digger)
-       MV_check_connections_on_destroy (pos)
-       end,
-       
-})
-
-count=count+1 end end end end end end
-
-MV_check_connections = function(pos)
-               local pos1={}
-               pos1.x=pos.x
-               pos1.y=pos.y
-               pos1.z=pos.z
-               
-               pos1.x=pos1.x+1
-               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
-               x2=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:mv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("x2",x2)
-               meta=minetest.env:get_meta(pos)
-               x1=1
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("x1",x1)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:mv_cable"..rule)
-               end
-
-               pos1.x=pos1.x-2
-               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
-               x1=1
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:mv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("x1",x1)
-               meta=minetest.env:get_meta(pos)
-               x2=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("x2",x2)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:mv_cable"..rule)
-               end
-
-               pos1.x=pos1.x+1
-               
-               pos1.y=pos1.y+1
-               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
-               y2=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:mv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("y2",y2)
-               meta=minetest.env:get_meta(pos)
-               y1=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("y1",y1)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:mv_cable"..rule)
-               end
-               
-               if minetest.env:get_meta(pos1):get_float("technic_mv_power_machine")==1 then
-               y1=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:mv_cable"..rule)
-               meta=minetest.env:get_meta(pos)
-               meta:set_float("y1",y1)
-               end
-
-
-               pos1.y=pos1.y-2
-               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
-               y1=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:mv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("y1",y1)
-               meta=minetest.env:get_meta(pos)
-               y2=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("y2",y2)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:mv_cable"..rule)
-               end
-               pos1.y=pos1.y+1
-
-               pos1.z=pos1.z+1
-               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
-               z2=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:mv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("z2",z2)
-               meta=minetest.env:get_meta(pos)
-               z1=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z2=minetest.env:get_meta(pos):get_float("z2")
-               meta:set_float("z1",z1)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:mv_cable"..rule)
-               end
-               pos1.z=pos1.z-2
-               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
-               z1=1
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos1,"technic:mv_cable"..rule)
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("z1",z1)
-               meta=minetest.env:get_meta(pos)
-               z2=1
-               x1=minetest.env:get_meta(pos):get_float("x1")
-               x2=minetest.env:get_meta(pos):get_float("x2")
-               y1=minetest.env:get_meta(pos):get_float("y1")
-               y2=minetest.env:get_meta(pos):get_float("y2")
-               z1=minetest.env:get_meta(pos):get_float("z1")
-               meta:set_float("z2",z2)
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               hacky_swap_node(pos,"technic:mv_cable"..rule)
-               end
-               pos1.z=pos1.z+1
-end    
-
-
-MV_check_connections_on_destroy = function(pos)
-               local pos1={}
-               pos1.x=pos.x
-               pos1.y=pos.y
-               pos1.z=pos.z
-               
-               pos1.x=pos1.x+1
-               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
-               x2=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("x2",x2)
-               end
-               
-               pos1.x=pos1.x-2
-               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
-               x1=0
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("x1",x1)
-               end
-               pos1.x=pos1.x+1
-
-               pos1.y=pos1.y+1
-               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
-               y2=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("y2",y2)
-               end
-               
-               pos1.y=pos1.y-2
-               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
-               y1=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("y1",y1)
-               end
-               pos1.y=pos1.y+1
-
-               pos1.z=pos1.z+1
-               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
-               z2=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z1=minetest.env:get_meta(pos1):get_float("z1")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("z2",z2)
-               end
-               
-               pos1.z=pos1.z-2
-               if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
-               z1=0
-               x1=minetest.env:get_meta(pos1):get_float("x1")
-               x2=minetest.env:get_meta(pos1):get_float("x2")
-               y1=minetest.env:get_meta(pos1):get_float("y1")
-               y2=minetest.env:get_meta(pos1):get_float("y2")
-               z2=minetest.env:get_meta(pos1):get_float("z2")
-               rule=make_rule_number(x1,x2,y1,y2,z1,z2)
-               if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
-               if rule>0  then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
-               meta=minetest.env:get_meta(pos1)
-               meta:set_float("z1",z1)
-               end
-               pos1.y=pos1.y+1
-               
-end    
-