Added Flashlight
authorMaciej Kasatkin <mk@realbadangel.pl>
Sun, 14 Oct 2012 21:36:34 +0000 (23:36 +0200)
committerMaciej Kasatkin <mk@realbadangel.pl>
Sun, 14 Oct 2012 21:36:34 +0000 (23:36 +0200)
15 files changed:
alloy_furnace.lua
battery_box.lua
cables.lua [new file with mode: 0644]
depends.txt
dyes.lua [deleted file]
electric.lua
electric_furnace.lua
flashlight.lua
generator.lua
init.lua
injector1.lua [deleted file]
mithril_subspace_chest.lua [deleted file]
tree_tap.lua
water.lua [deleted file]
water_can1.lua [new file with mode: 0644]

index 3f02d9ac7981ab0b633cacc4efcce29ee0bc19a7..1d2a1aa45be3df6e0bb35db2075f6bce70e81f53 100644 (file)
@@ -28,7 +28,7 @@ register_alloy_recipe ("default:steel_ingot",3, "technic:chromium_ingot",1, "tec
 register_alloy_recipe ("technic:copper_dust",2, "technic:zinc_dust",1, "technic:brass_dust",3)
 register_alloy_recipe ("technic: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:mithril_dust",2, "technic:doped_silicon_wafer",1)
+register_alloy_recipe ("technic:silicon_wafer",1, "technic:mithril_dust",1, "technic:doped_silicon_wafer",1)
 
 minetest.register_alias("alloy_furnace", "technic:alloy_furnace")
 
index dae2c0f79803ac5211a1bd2cd835d2f695a82b15..225984b73a8ce46e31b0980c1834b7d9cc043088 100644 (file)
@@ -13,6 +13,7 @@ register_power_tool ("technic:mining_drill",60000)
 register_power_tool ("technic:laser_mk1",40000)
 register_power_tool ("technic:battery",10000)
 register_power_tool ("technic:sonic_screwdriver",15000)
+register_power_tool ("technic:flashlight",30000)
 
 minetest.register_alias("battery", "technic:battery")
 minetest.register_alias("battery_box", "technic:battery_box")
diff --git a/cables.lua b/cables.lua
new file mode 100644 (file)
index 0000000..e69de29
index 3beb88bf769c231ffa9472a413e199c802c4d2fc..bfbfdf1d7a6c9beae01a037833601329e258f6bb 100644 (file)
@@ -1,7 +1,5 @@
-default
 moreores
 flowers
-dye
 pipeworks
 mesecons
 farming
diff --git a/dyes.lua b/dyes.lua
deleted file mode 100644 (file)
index a81988e..0000000
--- a/dyes.lua
+++ /dev/null
@@ -1,40 +0,0 @@
-minetest.register_craft({
-       type = "cooking",
-       output = "dye:black 2",
-       recipe = "default:coal_lump",
-})
-minetest.register_craft({
-       type = "cooking",
-       output = "dye:green 2",
-       recipe = "default:cactus",
-})
-minetest.register_craft({
-       type = "cooking",
-       output = "dye:red 2",
-       recipe = "flowers:flower_rose",
-})
-minetest.register_craft({
-       type = "cooking",
-       output = "dye:blue 2",
-       recipe = "flowers:flower_viola",
-})
-minetest.register_craft({
-       type = "cooking",
-       output = "dye:white 2",
-       recipe = "flowers:flower_dandelion_white",
-})
-minetest.register_craft({
-       type = "cooking",
-       output = "dye:yellow 2",
-       recipe = "flowers:flower_dandelion_yellow",
-})
-minetest.register_craft({
-       type = "cooking",
-       output = "dye:orange 2",
-       recipe = "flowers:flower_tulip",
-})
-minetest.register_craft({
-       type = "cooking",
-       output = "dye:brown 2",
-       recipe = "default:dry_shrub",
-})
\ No newline at end of file
index 0faee798106a439f751666160b2af829ff0bc209..2eb2bf3942bd6c4387545ab841227d054525ec5d 100644 (file)
@@ -265,275 +265,4 @@ minetest.register_abm({
                
        
 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()
-       local item_max_charge = nil
-       local counter=registered_power_tools_count-1
-       for i=1, counter,1 do
-               if power_tools[i].tool_name==src_item["name"] then
-               item_max_charge=power_tools[i].max_charge       
-               end
-               end
-       if item_max_charge then
-               local load1=tonumber((src_item["wear"])) 
-               load1=get_RE_item_load(load1,item_max_charge)
-               load_step=1000
-               if load1<item_max_charge and charge>0 then 
-                if charge-load_step<0 then load_step=charge end
-                if load1+load_step>item_max_charge then load_step=item_max_charge-load1 end
-               load1=load1+load_step
-               charge=charge-load_step
-       
-               load1=set_RE_item_load(load1,item_max_charge)
-               src_item["wear"]=tostring(load1)
-               inv:set_stack("src", 1, src_item)
-               end
-               meta:set_float("battery_charge",charge)
-       end     
-       end
-       
-               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 -- gettin power from all connected producers
-               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 internal_EU_buffer=meta1:get_float("internal_EU_buffer")
-       if charge<max_charge then 
-       charge_to_take=200      
-       if internal_EU_buffer-charge_to_take<=0 then
-               charge_to_take=internal_EU_buffer
-       end
-       if charge_to_take>0 then 
-       charge=charge+charge_to_take 
-       internal_EU_buffer=internal_EU_buffer-charge_to_take
-       meta1:set_float("internal_EU_buffer",internal_EU_buffer)
-       end
-       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:generator" then        new_node_added=add_new_cable_node(PR_nodes,pos1) end            
-if minetest.env:get_node(pos1).name == "technic:generator_active" then         new_node_added=add_new_cable_node(PR_nodes,pos1) end            
-if minetest.env:get_node(pos1).name == "technic:geothermal" then       new_node_added=add_new_cable_node(PR_nodes,pos1) end            
-if minetest.env:get_node(pos1).name == "technic:geothermal_active" then        new_node_added=add_new_cable_node(PR_nodes,pos1) end            
-if minetest.env:get_node(pos1).name == "technic:water_mill" then       new_node_added=add_new_cable_node(PR_nodes,pos1) end            
-if minetest.env:get_node(pos1).name == "technic:water_mill_active" 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:alloy_furnace" then    new_node_added=add_new_cable_node(RE_nodes,pos1) end            
-if minetest.env:get_node(pos1).name == "technic:alloy_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
\ No newline at end of file
+})
\ No newline at end of file
index d4d70ff088c4b1c441c896ed42e57763a8f8b64f..f6bf0dbc8feb0d42da039a170dfae4a2cab8a55d 100644 (file)
@@ -12,6 +12,7 @@ minetest.register_craft({
 
 electric_furnace_formspec =
        "invsize[8,9;]"..
+       "image[0,0;8,5;technic_electric_furnace_menu.png]"..
        "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;]"..
@@ -107,6 +108,7 @@ minetest.register_abm({
                local load = math.floor(internal_EU_buffer/2000 * 100)
                meta:set_string("formspec",
                                "invsize[8,9;]"..
+                               "image[0,0;9,5;technic_menu_bg.png]"..
                                "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;]"..
index 8b34e9474c96c98252b974957a302cbd8bf69a0c..4247f2daf8a7657fc4579d88184a8d602eb473ab 100644 (file)
@@ -1,8 +1,11 @@
+-- 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,            
     })
@@ -15,3 +18,160 @@ flashlight_max_charge=30000
                     {"","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] = player:get_wielded_item():get_name()
+       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] ~= "technic:flashlight") 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] = "technic:flashlight";
+               elseif last_wielded[player_name] == "technic:flashlight"  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] = wielded_item
+               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()
+                       local charge=tonumber((item["wear"])) 
+                       if charge ==0 then charge =65535 end
+                       charge=get_RE_item_load(charge,flashlight_max_charge)
+                       if charge-2>0 then
+                        flashlight_on=true     
+                        charge =charge-2;      
+                       charge=set_RE_item_load(charge,flashlight_max_charge)
+                       item["wear"]=tostring(charge)
+                       hotbar[i]:replace(item)
+                       inv:set_stack("main",i,hotbar[i])
+                       end
+                       return flashlight_on
+                       end
+               end
+return flashlight_on
+end    
\ No newline at end of file
index a4f096e0ad7ee921ed31c51beb805e0f93286089..c8ac802a4b3de15c03400220bca383a38d947d2d 100644 (file)
@@ -15,10 +15,11 @@ minetest.register_craftitem("technic:generator", {
        stack_max = 99,
 }) 
 
-generatorr_formspec =
+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[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]"..
index e931bdfed99cea677a4d9e9cb85a831d5ef11306..c72509ea6b8deb19f532fb0ec62c3ccbde9ed8bd 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -24,7 +24,6 @@ dofile(minetest.get_modpath("technic").."/electric_furnace.lua")
 dofile(minetest.get_modpath("technic").."/battery_box.lua")
 dofile(minetest.get_modpath("technic").."/wires.lua")
 dofile(minetest.get_modpath("technic").."/wires_mv.lua")
-dofile(minetest.get_modpath("technic").."/dyes.lua")
 dofile(minetest.get_modpath("technic").."/ores.lua")
 
 dofile(minetest.get_modpath("technic").."/tool_workshop.lua")
diff --git a/injector1.lua b/injector1.lua
deleted file mode 100644 (file)
index 537e478..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-minetest.register_craftitem("technic:injector", {
-       description = "Injector",
-       stack_max = 99,
-})
-
-minetest.register_node("technic:injector", {
-       description = "Injector",
-       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", "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)
-                       item1=tube_item({x=pos.x+.5,y=pos.y,z=pos.z},stack)
-                       return
-                       end
-       end
-end,
-})
-
-
-function tube_item(pos, item)
-       -- 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())
-       obj:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
-       obj:setacceleration({x=0, y=0, z=0})
-       pos.x=pos.x+1
-       local meta = minetest.env:get_meta(pos)
-       if meta:get_int("tubelike")==1 then obj:setvelocity({x=1, y=0, z=0}) return obj end
-       pos.x=pos.x-2
-       meta = minetest.env:get_meta(pos)
-       if meta:get_int("tubelike")==1 then obj:setvelocity({x=-1, y=0, z=0}) return obj end
-       pos.x=pos.x+1
-       pos.z=pos.z+1
-       meta = minetest.env:get_meta(pos)
-       if meta:get_int("tubelike")==1 then obj:setvelocity({x=0, y=0, z=1}) return obj end
-       pos.z=pos.z-2
-       meta = minetest.env:get_meta(pos)
-       if meta:get_int("tubelike")==1 then obj:setvelocity({x=0, y=0, z=-1}) return obj end
-       pos.z=pos.z+1
-       pos.y=pos.y+1
-       meta = minetest.env:get_meta(pos)
-       if meta:get_int("tubelike")==1 then obj:setvelocity({x=0, y=1, z=0}) return obj end
-       pos.y=pos.y-2
-       meta = minetest.env:get_meta(pos)
-       if meta:get_int("tubelike")==1 then obj:setvelocity({x=0, y=-2, z=0}) return obj end
-       pos.y=pos.y+1
-       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={}
-       },
-       
-       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)
-               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 velocity=self.object:getvelocity()
-       
-       if not velocity then 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 
-                       check_next_step (self.start_pos, velocity) 
-                       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
-                       check_next_step (self.start_pos, velocity) 
-                       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
-                       check_next_step (self.start_pos, velocity) 
-                       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 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 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 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 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 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 end
-end
-
---velocity.x=0
---velocity.y=0
---velocity.z=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
diff --git a/mithril_subspace_chest.lua b/mithril_subspace_chest.lua
deleted file mode 100644 (file)
index 89683f8..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-minetest.register_craft({
-       output = 'technic:mithril_chest 1',
-       recipe = {
-               {'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'},
-               {'moreores:mithril_ingot','technic:gold_chest','moreores:mithril_ingot'},
-               {'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'},
-       }
-})
-
-minetest.register_craft({
-       output = 'technic:mithril_locked_chest 1',
-       recipe = {
-               {'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'},
-               {'moreores:mithril_ingot','technic:gold_locked_chest','moreores:mithril_ingot'},
-               {'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'},
-       }
-})
-
-minetest.register_craft({
-       output = 'technic:mithril_locked_chest 1',
-       recipe = {
-               {'default:steel_ingot'},
-               {'technic:mithril_chest'},
-       }
-})
-
-minetest.register_node("technic:mithril_chest", {
-       description = "Mithril Chest",
-       tiles = {"technic_mithril_chest_top.png", "technic_mithril_chest_top.png", "technic_mithril_chest_side.png",
-               "technic_mithril_chest_side.png", "technic_mithril_chest_side.png", "technic_mithril_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[13,9;]"..
-                               "list[current_name;main;0,0;13,4;]"..
-                               "list[current_player;main;0,5;8,4;]")
-               meta:set_string("infotext", "Mithril Chest")
-               local inv = meta:get_inventory()
-               inv:set_size("main", 13*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_metadata_inventory_move = function(pos, from_list, from_index,
-                       to_list, to_index, count, player)
-               minetest.log("action", player:get_player_name()..
-                               " moves stuff in chest at "..minetest.pos_to_string(pos))
-               return minetest.node_metadata_inventory_move_allow_all(
-                               pos, from_list, from_index, to_list, to_index, count, player)
-       end,
-    on_metadata_inventory_offer = function(pos, listname, index, stack, player)
-               minetest.log("action", player:get_player_name()..
-                               " moves stuff to chest at "..minetest.pos_to_string(pos))
-               return minetest.node_metadata_inventory_offer_allow_all(
-                               pos, listname, index, stack, player)
-       end,
-    on_metadata_inventory_take = function(pos, listname, index, stack, player)
-               minetest.log("action", player:get_player_name()..
-                               " takes stuff from chest at "..minetest.pos_to_string(pos))
-       end,
-})
-
-minetest.register_node("technic:mithril_locked_chest", {
-       description = "Mithril Locked Chest",
-       tiles = {"technic_mithril_chest_top.png", "technic_mithril_chest_top.png", "technic_mithril_chest_side.png",
-               "technic_mithril_chest_side.png", "technic_mithril_chest_side.png", "technic_mithril_chest_locked.png"},
-       paramtype2 = "facedir",
-       groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
-       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", "Mithril 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[13,9;]"..
-                               "list[current_name;main;0,0;13,4;]"..
-                               "list[current_player;main;0,5;8,4;]")
-               meta:set_string("infotext", "Mithril Locked Chest")
-               meta:set_string("owner", "")
-               local inv = meta:get_inventory()
-               inv:set_size("main", 13*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,
-       allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
-               local meta = minetest.env:get_meta(pos)
-               if not has_locked_chest_privilege(meta, player) then
-                       minetest.log("action", player:get_player_name()..
-                                       " tried to access a locked chest belonging to "..
-                                       meta:get_string("owner").." at "..
-                                       minetest.pos_to_string(pos))
-                       return 0
-               end
-               return count
-       end,
-    allow_metadata_inventory_put = function(pos, listname, index, stack, player)
-               local meta = minetest.env:get_meta(pos)
-               if not has_locked_chest_privilege(meta, player) then
-                       minetest.log("action", player:get_player_name()..
-                                       " tried to access a locked chest belonging to "..
-                                       meta:get_string("owner").." at "..
-                                       minetest.pos_to_string(pos))
-                       return 0
-               end
-               return stack:get_count()
-       end,
-    allow_metadata_inventory_take = function(pos, listname, index, stack, player)
-               local meta = minetest.env:get_meta(pos)
-               if not has_locked_chest_privilege(meta, player) then
-                       minetest.log("action", player:get_player_name()..
-                                       " tried to access a locked chest belonging to "..
-                                       meta:get_string("owner").." at "..
-                                       minetest.pos_to_string(pos))
-                       return 0
-               end
-               return stack:get_count()
-       end,
-       on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
-               minetest.log("action", player:get_player_name()..
-                               " moves stuff in locked chest at "..minetest.pos_to_string(pos))
-       end,
-    on_metadata_inventory_put = function(pos, listname, index, stack, player)
-               minetest.log("action", player:get_player_name()..
-                               " moves stuff to locked chest at "..minetest.pos_to_string(pos))
-       end,
-    on_metadata_inventory_take = function(pos, listname, index, stack, player)
-               minetest.log("action", player:get_player_name()..
-                               " takes stuff from locked chest at "..minetest.pos_to_string(pos))
-       end,
-})
index 6f38fed3b0ca3a09f52bebade4464f03a5ef410f..92c56b0511b95d597273546e845ed93454b9c1ef 100644 (file)
@@ -7,7 +7,7 @@
                             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 == "farming_plus:rubber_tree_full" then
+                            if node_name == "farming:rubber_tree_full" then
                                     user:get_inventory():add_item("main",ItemStack("technic:caouthouc"))
                                     minetest.env:set_node(pos,node)
                                     local item=itemstack:to_table()
diff --git a/water.lua b/water.lua
deleted file mode 100644 (file)
index 6ddaa46..0000000
--- a/water.lua
+++ /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', 'moreores:copper_ingot', 'default:wood'},
-               {'default:wood', 'moreores:tin_ingot', 'default:wood'},
-               {'default:wood', 'moreores:copper_ingot', 'default:wood'},
-       }
-}) 
-
-minetest.register_craft({
-       output = 'technic:battery_box 1',
-       recipe = {
-               {'technic:battery', 'default:wood', 'technic:battery'},
-               {'technic:battery', 'moreores: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', 'moreores: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', 'moreores: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,
-}) 
\ No newline at end of file
diff --git a/water_can1.lua b/water_can1.lua
new file mode 100644 (file)
index 0000000..c61ccac
--- /dev/null
@@ -0,0 +1,68 @@
+water_can_max_load = 16
+
+minetest.register_craft({
+       output = 'technic:water_can 1',
+       recipe = {
+               {'technic:zinc_ingot', 'technic:rubber_fiber','technic:zinc_ingot'},
+               {'default:steel_ingot', '', 'default:steel_ingot'},
+               {'technic:zinc_ingot', 'default: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)
+               if n.name == "default:water_source" then
+                       item=itemstack:to_table()
+                       local load=tonumber((item["wear"])) 
+                       if  load==0 then load =65535 end
+                       load=get_RE_item_load(load,water_can_max_load)
+                       print ("Water can load"..load)
+                       if load+1<17 then
+                       minetest.env:add_node(pointed_thing.under, {name="air"})
+                        load=load+1;   
+                       load=set_RE_item_load(load,water_can_max_load)
+                       item["wear"]=tostring(load)
+                       itemstack:replace(item)
+                       end
+                       return itemstack
+               end
+               item=itemstack:to_table()
+                       load=tonumber((item["wear"])) 
+                       if  load==0 then load =65535 end
+                       load=get_RE_item_load(load,water_can_max_load)
+                       if load==0 then return end
+                       n = minetest.env:get_node(pointed_thing.under)
+                       if minetest.registered_nodes[n.name].buildable_to then
+                       -- buildable
+                       minetest.env:add_node(pointed_thing.under, {name="default:water_source"})
+                       load=load-1;    
+                       load=set_RE_item_load(load,water_can_max_load)
+                       item["wear"]=tostring(load)
+                       itemstack:replace(item)
+                       return itemstack
+                       else
+                       n = minetest.env:get_node(pointed_thing.above)
+                       -- not buildable
+                       -- check if its allowed to replace the node
+                       if not minetest.registered_nodes[n.name].buildable_to then
+                       return
+                       end
+                       minetest.env:add_node(pointed_thing.above, {name="default:water_source"})
+                       load=load-1;    
+                       load=set_RE_item_load(load,water_can_max_load)
+                       item["wear"]=tostring(load)
+                       itemstack:replace(item)
+                       return itemstack
+                       end
+
+       end,
+})