This is an old revision of the document!
This code comes from a mailing list request. It takes a signal, and runs through each route looking for one which can be set and gives up if unable to. It requires that routes are arranged in ascending numeric order, routes named like this:
There is no concept of ARS matching and this simply sets the first available route.
The code takes the name of the signal and the last route as constants. When a train runs over the rail, the code attempts to find a setabble route. If unable to, the code gives up.
signalPos = "" -- Add the name of the signal lastRoute = "" -- The number name of the final route if event.type == "train" then for i = lastRoute,1,-1 do l = tostring(i) if can_set_route(signalPos, l) then set_route(signalPos, "t" .. l) end end end