summaryrefslogtreecommitdiff
path: root/extranodes/straight_tube.lua
blob: d3c19b84b921a22c2db066b4a7591d17f670002a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-- straight-only pipe
-- does not connect side-wise, allows items in both directions
-- a counterpart to straight-only pipe, and a cheap alternative 
-- to one-way tube for long segments of parallel pipes

if minetest.get_modpath("pipeworks") then

	minetest.register_node(":pipeworks:straight_tube", {
		description = "Straight-only Tube",
		tiles = {"pipeworks_straight_tube_side.png", 
			"pipeworks_straight_tube_side.png", 
			"pipeworks_straight_tube_output.png",
			"pipeworks_straight_tube_input.png", 
			"pipeworks_straight_tube_side.png", 
			"pipeworks_straight_tube_side.png"},
		paramtype2 = "facedir",
		drawtype = "nodebox",
		paramtype = "light",
		node_box = {type = "fixed",
			fixed = {{-1/2, -9/64, -9/64, 1/2, 9/64, 9/64}}},
		groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1},
		sounds = default.node_sound_wood_defaults(),
		tube = {
			connect_sides = {left = 1, right = 1},
			can_go = function(pos, node, velocity, stack)
					return {velocity}
				end,
			can_insert = function(pos, node, stack, direction)
					local dir = pipeworks.facedir_to_right_dir(node.param2)
					local opdir = vector.multiply(dir, -1)
					return vector.equals(dir, direction) or vector.equals(opdir, direction)
				end,
			priority = 60 -- Higher than normal tubes, but lower than one-way tubes
		},
		after_place_node = pipeworks.after_place,
		after_dig_node = pipeworks.after_dig,
	})

	minetest.register_craft({
		output = "pipeworks:straight_tube 3",
		recipe = {
			{ "pipeworks:tube_1", "pipeworks:tube_1", "pipeworks:tube_1" },
		},
	})

end