aboutsummaryrefslogtreecommitdiff
path: root/signals.lua
blob: 803b1a7bb81e4a32cadf561913e4e3320e8ba9e2 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--advtrains by orwell96
--signals.lua

for r,f in pairs({on="off", off="on"}) do
	minetest.register_node("advtrains:retrosignal_"..r, {
		drawtype = "mesh",
		paramtype="light",
		paramtype2="facedir",
		walkable = false,
		selection_box = {
			type = "fixed",
			fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4},
		},
		mesh = "advtrains_retrosignal_"..r..".b3d",
		tiles = {"advtrains_retrosignal.png"},
		description="Lampless Signal ("..r..")",
		on_rightclick=switchfunc,
		sunlight_propagates=true,
		groups = {
			choppy=3,
			not_blocking_trains=1
		},
		mesecons = {effector = {
			["action_"..f] = function (pos, node)
				minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f, param2 = node.param2})
			end
		}},
		on_rightclick=function(pos, node, clicker)
			minetest.swap_node(pos, {name = "advtrains:retrosignal_"..f, param2 = node.param2})
		end,
	})
	minetest.register_node("advtrains:signal_"..r, {
		drawtype = "mesh",
		paramtype="light",
		paramtype2="facedir",
		walkable = false,
		selection_box = {
			type = "fixed",
			fixed = {-1/4, -1/2, -1/4, 1/4, 2, 1/4},
		},
		mesh = "advtrains_signal.b3d",
		tiles = {"advtrains_signal_"..r..".png"},
		description="Signal ("..r..")",
		on_rightclick=switchfunc,
		groups = {
			choppy=3,
			not_blocking_trains=1
		},
		light_source = 1,
		sunlight_propagates=true,
		mesecons = {effector = {
			["action_"..f] = function (pos, node)
				minetest.swap_node(pos, {name = "advtrains:signal_"..f, param2 = node.param2})
			end
		}},
		on_rightclick=function(pos, node, clicker)
			minetest.swap_node(pos, {name = "advtrains:signal_"..f, param2 = node.param2})
		end,
	})
end