Add pipeworks support to generators
This commit is contained in:
parent
ef70cbfbf2
commit
7a3cd49597
@ -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})
|
||||
|
||||
|
@ -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})
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user