Add getter/setter for routingcode in LuaATC

master
orwell96 2019-01-15 17:54:13 +01:00
parent a3baead979
commit f5e8b70202
2 changed files with 18 additions and 1 deletions

View File

@ -147,6 +147,7 @@ The Lua-controlled ATC rails are the only components that can actually interface
{type="train", train=true, id="<train_id>"}
This event is fired when a train enters the rail. The field 'id' is the unique train ID, which is 6-digit random numerical string.
If the world contains trains from an older advtrains version, this string may be longer and contain a dot (.)
{type="int", int=true, msg=<message>}
Fired when an interrupt set by the 'interrupt' function runs out. 'message' is the message passed to the interrupt function.
@ -177,10 +178,16 @@ get_line()
Returns the "Line" property of the train (a string).
This can be used to distinguish between trains of different lines and route them appropriately.
The interlocking system also uses this property for Automatic Routesetting.
set_line(number)
set_line(line)
Sets the "Line" property of the train (a string).
If the first digit of this string is a number (0-9), any subway wagons on the train will have this one displayed as line number
(where "0" is actually shown as Line 10 on the train)
get_rc()
Returns the "Routingcode" property of the train (a string).
The interlocking system uses this property for Automatic Routesetting.
set_rc(routingcode)
Sets the "Routingcode" property of the train (a string).
The interlocking system uses this property for Automatic Routesetting.
# Operator panel
This simple node executes its actions when punched. It can be used to change a switch and update the corresponding signals or similar applications.

View File

@ -63,6 +63,16 @@ function r.fire_event(pos, evtdata)
get_line = function()
return train.line
end,
set_rc = function(rc)
if type(rc)~="string"then
return false
end
train.routingcode = rc
return true
end,
get_rc = function()
return train.routingcode
end,
atc_reset = function(cmd)
if not train_id then return false end
assertt(cmd, "string")