2018-06-19 19:50:11 +02:00
|
|
|
-- Demonstration signals
|
|
|
|
-- Those can display the 3 main aspects of Ks signals
|
|
|
|
|
2018-07-04 17:48:33 +02:00
|
|
|
-- Note that the group value of advtrains_signal is 2, which means "step 2 of signal capabilities"
|
|
|
|
-- advtrains_signal=1 is meant for signals that do not implement set_aspect.
|
|
|
|
|
2018-06-19 19:50:11 +02:00
|
|
|
|
2018-10-25 22:49:30 +02:00
|
|
|
local setaspect = function(pos, node, asp)
|
2020-01-30 08:45:16 +01:00
|
|
|
if asp.main == 0 then
|
2018-10-25 22:49:30 +02:00
|
|
|
advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_danger"})
|
|
|
|
else
|
2020-01-30 08:45:16 +01:00
|
|
|
if asp.dst != 0 and asp.main == -1 then
|
2018-10-25 22:49:30 +02:00
|
|
|
advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_free"})
|
|
|
|
else
|
|
|
|
advtrains.ndb.swap_node(pos, {name="advtrains_interlocking:ds_slow"})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
if meta then
|
|
|
|
meta:set_string("infotext", minetest.serialize(asp))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local suppasp = {
|
2020-01-30 08:45:16 +01:00
|
|
|
main = {0, 6, -1},
|
|
|
|
dst = {0, false},
|
|
|
|
shunt = false,
|
|
|
|
proceed_as_main = true,
|
2018-10-25 22:49:30 +02:00
|
|
|
info = {
|
|
|
|
call_on = false,
|
|
|
|
dead_end = false,
|
|
|
|
w_speed = nil,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-19 19:50:11 +02:00
|
|
|
minetest.register_node("advtrains_interlocking:ds_danger", {
|
|
|
|
description = "Demo signal at Danger",
|
|
|
|
tiles = {"at_il_signal_asp_danger.png"},
|
|
|
|
groups = {
|
|
|
|
cracky = 3,
|
2018-07-04 17:48:33 +02:00
|
|
|
advtrains_signal = 2,
|
2018-06-19 19:50:11 +02:00
|
|
|
save_in_at_nodedb = 1,
|
|
|
|
},
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
advtrains = {
|
2018-10-25 22:49:30 +02:00
|
|
|
set_aspect = setaspect,
|
|
|
|
supported_aspects = suppasp,
|
|
|
|
get_aspect = function(pos, node)
|
|
|
|
return advtrains.interlocking.DANGER
|
|
|
|
end,
|
2018-06-19 19:50:11 +02:00
|
|
|
},
|
2018-08-12 14:25:38 +02:00
|
|
|
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
|
|
|
can_dig = advtrains.interlocking.signal_can_dig,
|
2018-06-19 19:50:11 +02:00
|
|
|
})
|
|
|
|
minetest.register_node("advtrains_interlocking:ds_free", {
|
|
|
|
description = "Demo signal at Free",
|
|
|
|
tiles = {"at_il_signal_asp_free.png"},
|
|
|
|
groups = {
|
|
|
|
cracky = 3,
|
2018-07-04 17:48:33 +02:00
|
|
|
advtrains_signal = 2,
|
2018-06-19 19:50:11 +02:00
|
|
|
save_in_at_nodedb = 1,
|
|
|
|
},
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
advtrains = {
|
2018-10-25 22:49:30 +02:00
|
|
|
set_aspect = setaspect,
|
|
|
|
supported_aspects = suppasp,
|
|
|
|
get_aspect = function(pos, node)
|
|
|
|
return {
|
2020-01-30 08:45:16 +01:00
|
|
|
main = -1,
|
2018-10-25 22:49:30 +02:00
|
|
|
}
|
|
|
|
end,
|
2018-06-19 19:50:11 +02:00
|
|
|
},
|
2018-08-12 14:25:38 +02:00
|
|
|
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
|
|
|
can_dig = advtrains.interlocking.signal_can_dig,
|
2018-06-19 19:50:11 +02:00
|
|
|
})
|
|
|
|
minetest.register_node("advtrains_interlocking:ds_slow", {
|
|
|
|
description = "Demo signal at Slow",
|
|
|
|
tiles = {"at_il_signal_asp_slow.png"},
|
|
|
|
groups = {
|
|
|
|
cracky = 3,
|
2018-07-04 17:48:33 +02:00
|
|
|
advtrains_signal = 2,
|
2018-06-19 19:50:11 +02:00
|
|
|
save_in_at_nodedb = 1,
|
|
|
|
},
|
|
|
|
sounds = default.node_sound_stone_defaults(),
|
|
|
|
advtrains = {
|
2018-10-25 22:49:30 +02:00
|
|
|
set_aspect = setaspect,
|
|
|
|
supported_aspects = suppasp,
|
|
|
|
get_aspect = function(pos, node)
|
|
|
|
return {
|
2020-01-30 08:45:16 +01:00
|
|
|
main = 6,
|
2018-10-25 22:49:30 +02:00
|
|
|
}
|
|
|
|
end,
|
2018-06-19 19:50:11 +02:00
|
|
|
},
|
2018-08-12 14:25:38 +02:00
|
|
|
on_rightclick = advtrains.interlocking.signal_rc_handler,
|
|
|
|
can_dig = advtrains.interlocking.signal_can_dig,
|
2018-06-19 19:50:11 +02:00
|
|
|
})
|
|
|
|
|