-
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).."]"..
"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)
"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,
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()