This is an old revision of the document!
A level crossing is very dangerous as trains travel at a high speed and are often very quiet. They kill instantly whilst leaving no trace.
As such, a level crossing warning system is a very good idea.
To use this system, one needs a luacontroller, digilines, and an Andrew's Cross. When a train approaches, it causes a digiline signal and then this is interpreted by the luacontroller and sent to the Andrew's Cross.
This code is also compatible with traffic lights from the streets mod.
Track:
-- Andrew's cross activation code. Compatible with traffic signals. Use channel "a" using digilines connected to tracks. __approach_callback_mode = 2 if event.type == "approach" then digiline_send("a", "RED") end if event.type == "train" then digiline_send("a", "GREEN") end
Luacontroller:
-- Connect to rail with digilines. Turns ports on if there is a train. if event.type == "digiline" and event.msg == "RED" then port.a = true port.b = true port.c = true port.d = true end if event.type == "digiline" and event.msg == "GREEN" then port.a = false port.b = false port.c = false port.d = false end