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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
-- Demonstration signals
-- Those can display the 3 main aspects of Ks signals
minetest.register_node("advtrains_interlocking:ds_danger", {
description = "Demo signal at Danger",
tiles = {"at_il_signal_asp_danger.png"},
groups = {
cracky = 3,
advtrains_signal = 1,
save_in_at_nodedb = 1,
},
sounds = default.node_sound_stone_defaults(),
advtrains = {
set_aspect = function(pos, node, asp)
if asp.main.free then
if asp.dst.free and asp.main.speed > 50 then
advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_free"})
else
advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_slow"})
end
else
advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_danger"})
end
local meta = minetest.get_meta(pos)
if meta then
meta:set_string("infotext", minetest.serialize(asp))
end
end
},
on_rightclick = advtrains.interlocking.signal_rc_handler
})
minetest.register_node("advtrains_interlocking:ds_free", {
description = "Demo signal at Free",
tiles = {"at_il_signal_asp_free.png"},
groups = {
cracky = 3,
advtrains_signal = 1,
save_in_at_nodedb = 1,
},
sounds = default.node_sound_stone_defaults(),
advtrains = {
set_aspect = function(pos, node, asp)
if asp.main.free then
if asp.dst.free and asp.main.speed > 50 then
advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_free"})
else
advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_slow"})
end
else
advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_danger"})
end
local meta = minetest.get_meta(pos)
if meta then
meta:set_string("infotext", minetest.serialize(asp))
end
end
},
on_rightclick = advtrains.interlocking.signal_rc_handler
})
minetest.register_node("advtrains_interlocking:ds_slow", {
description = "Demo signal at Slow",
tiles = {"at_il_signal_asp_slow.png"},
groups = {
cracky = 3,
advtrains_signal = 1,
save_in_at_nodedb = 1,
},
sounds = default.node_sound_stone_defaults(),
advtrains = {
set_aspect = function(pos, node, asp)
if asp.main.free then
if asp.dst.free and asp.main.speed > 50 then
advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_free"})
else
advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_slow"})
end
else
advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_danger"})
end
local meta = minetest.get_meta(pos)
if meta then
meta:set_string("infotext", minetest.serialize(asp))
end
end
},
on_rightclick = advtrains.interlocking.signal_rc_handler
})
|