From 7a3cd495972f2dc399d7af7f596a6d9a4a5c728b Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sun, 1 Dec 2013 18:45:45 +0100 Subject: [PATCH] Add pipeworks support to generators --- technic/machines/HV/generator.lua | 3 +- technic/machines/MV/generator.lua | 3 +- technic/machines/register/generator.lua | 39 +++++++++++++++++++++---- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/technic/machines/HV/generator.lua b/technic/machines/HV/generator.lua index d73b68a..4ed6ab2 100644 --- a/technic/machines/HV/generator.lua +++ b/technic/machines/HV/generator.lua @@ -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}) diff --git a/technic/machines/MV/generator.lua b/technic/machines/MV/generator.lua index 973bbd2..5a84d12 100644 --- a/technic/machines/MV/generator.lua +++ b/technic/machines/MV/generator.lua @@ -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}) diff --git a/technic/machines/register/generator.lua b/technic/machines/register/generator.lua index 2665e45..0b04815 100644 --- a/technic/machines/register/generator.lua +++ b/technic/machines/register/generator.lua @@ -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() -- 2.30.2