Luaautomation: add section_occupancy()
Returns a table of train ids for the specified section. Returns nil if the section id is not provided.. Returns false if the section id is invalid. Returns an empty table if the section id is valid but empty of trains.
This commit is contained in:
parent
5912f778e1
commit
23d524df71
|
@ -314,13 +314,16 @@ Deprecated:
|
||||||
|
|
||||||
|
|
||||||
#### Interlocking
|
#### Interlocking
|
||||||
This additional function is available when advtrains_interlocking is enabled:
|
These additional functions are available when advtrains_interlocking is enabled:
|
||||||
|
|
||||||
- `atc_set_ars_disable(boolean)`
|
- `atc_set_ars_disable(boolean)`
|
||||||
Disables (true) or enables (false) the use of ARS for this train. The train will not trigger ARS (automatic route setting) on signals then.
|
Disables (true) or enables (false) the use of ARS for this train. The train will not trigger ARS (automatic route setting) on signals then.
|
||||||
|
|
||||||
Note: If you want to disable ARS from an approach callback, the call to `atc_set_ars_disable(true)` *must* happen during the approach callback, and may not be deferred to an interrupt(). Else the train might trigger an ARS before the interrupt fires.
|
Note: If you want to disable ARS from an approach callback, the call to `atc_set_ars_disable(true)` *must* happen during the approach callback, and may not be deferred to an interrupt(). Else the train might trigger an ARS before the interrupt fires.
|
||||||
|
|
||||||
|
- `section_occupancy(section_id)`
|
||||||
|
Returns a table of train ids for the specified section, nil if no section id is provided, false if the section id is invalid, an empty table if the section id is valid but empty of trains.
|
||||||
|
|
||||||
#### Approach callbacks
|
#### Approach callbacks
|
||||||
The LuaATC interface provides a way to hook into the approach callback system, which is for example used in the TSR rails (provided by advtrains_interlocking) or the station tracks (provided by advtrains_lines). However, for compatibility reasons, this behavior needs to be explicitly enabled.
|
The LuaATC interface provides a way to hook into the approach callback system, which is for example used in the TSR rails (provided by advtrains_interlocking) or the station tracks (provided by advtrains_lines). However, for compatibility reasons, this behavior needs to be explicitly enabled.
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,18 @@ if advtrains.interlocking then
|
||||||
local pos = atlatc.pcnaming.resolve_pos(signal)
|
local pos = atlatc.pcnaming.resolve_pos(signal)
|
||||||
return advtrains.interlocking.signal_set_aspect(pos)
|
return advtrains.interlocking.signal_set_aspect(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--section_occupancy()
|
||||||
|
static_env.section_occupancy = function(ts_id)
|
||||||
|
if not ts_id then return nil end
|
||||||
|
ts_id = tostring(ts_id)
|
||||||
|
local response = advtrains.interlocking.db.get_ts(ts_id)
|
||||||
|
if response == nil then
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return response.trains
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Lines-specific:
|
-- Lines-specific:
|
||||||
|
|
Loading…
Reference in New Issue