Add pipeworks support to generators
authorSmallJoker <st.rentsch@hotmail.com>
Sun, 1 Dec 2013 17:45:45 +0000 (18:45 +0100)
committerShadowNinja <shadowninja@minetest.net>
Tue, 3 Dec 2013 16:22:48 +0000 (11:22 -0500)
technic/machines/HV/generator.lua
technic/machines/MV/generator.lua
technic/machines/register/generator.lua

index d73b68a7edcf3b28fb622d6da5dd6199b30d09ff..4ed6ab2838b28c5eabd699539a32062174d651ff 100644 (file)
@@ -1,4 +1,3 @@
-
 minetest.register_alias("hv_generator", "technic:hv_generator")
 
 minetest.register_craft({
@@ -10,5 +9,5 @@ minetest.register_craft({
        }
 })
 
-technic.register_generator({tier="HV", supply=1200})
+technic.register_generator({tier="HV", tube=1, supply=1200})
 
index 973bbd2e33f6009d8ee16a43a6f6327fb0d59217..5a84d120b5789e0939a7c3b4156e13b7b0d6440d 100644 (file)
@@ -1,4 +1,3 @@
-
 minetest.register_alias("generator_mv", "technic:generator_mv")
 
 minetest.register_craft({
@@ -10,5 +9,5 @@ minetest.register_craft({
        }
 })
 
-technic.register_generator({tier="MV", supply=600})
+technic.register_generator({tier="MV", tube=1, supply=600})
 
index 2665e45274a92b4bd75f6ecd0e83e8390e62143b..0b04815352e1ef2a73af6d807a1582ae031c3bdb 100644 (file)
@@ -1,10 +1,32 @@
-
 local S = technic.getter
 
+local tube = {
+       insert_object = function(pos, node, stack, direction)
+               local meta = minetest.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.get_meta(pos)
+               local inv = meta:get_inventory()
+               return inv:room_for_item("src", stack)
+       end,
+       connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
+}
+
 function technic.register_generator(data) 
        local tier = data.tier
        local ltier = string.lower(tier)
-
+       
+       local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}
+       local active_groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1}
+       if data.tube then
+               groups.tubedevice = 1
+               groups.tubedevice_receiver = 1
+               active_groups.tubedevice = 1
+               active_groups.tubedevice_receiver = 1
+       end
+       
        local generator_formspec =
                "invsize[8,9;]"..
                "label[0,0;"..S("%s Generator"):format(tier).."]"..
@@ -19,14 +41,16 @@ function technic.register_generator(data)
                         "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
                         "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front.png"}, 
                paramtype2 = "facedir",
-               groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
+               groups = groups,
                legacy_facedir_simple = true,
                sounds = default.node_sound_wood_defaults(),
+               tube = data.tube and tube or nil,
                on_construct = function(pos)
                        local meta = minetest.get_meta(pos)
                        meta:set_string("infotext", desc)
                        meta:set_int(data.tier.."_EU_supply", 0)
                        meta:set_int("burn_time", 0)
+                       meta:set_int("tube_time",  0)
                        meta:set_string("formspec", generator_formspec)
                        local inv = meta:get_inventory()
                        inv:set_size("src", 1)
@@ -43,10 +67,10 @@ function technic.register_generator(data)
                         "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
                         "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front_active.png"},
                paramtype2 = "facedir",
-               groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
-                       not_in_creative_inventory=1},
+               groups = active_groups,
                legacy_facedir_simple = true,
                sounds = default.node_sound_wood_defaults(),
+               tube = data.tube and tube or nil,
                drop = "technic:"..ltier.."_generator",
                can_dig = technic.machine_can_dig,
                allow_metadata_inventory_put = technic.machine_inventory_put,
@@ -67,6 +91,11 @@ function technic.register_generator(data)
                                burn_time = burn_time - 1
                                meta:set_int("burn_time", burn_time)
                        end
+                       local tube_upgrade = 0, 0
+                       if data.tube then
+                               technic.handle_machine_pipeworks(pos, tube_upgrade)
+                       end
+                       
                        -- Burn another piece of fuel
                        if burn_time == 0 then
                                local inv = meta:get_inventory()