User Tools

Site Tools


Sidebar



Minetest Forum
Content Database
Git Repository
Bug Tracker
Website

usage:atlatc:examples:level_crossing

This is an old revision of the document!


Level Crossing Warning System

Introduction

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.

Explanation

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.

Code

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
usage/atlatc/examples/level_crossing.1656850074.txt.gz · Last modified: 2022-07-03 14:07 by 56independent