API reference
Everything a script can use, object by object. With every object stands what it is, what you use it for and an example, and then its properties (without brackets: blocks.B3.occupied), methods (with brackets: turnouts.W5.diverging()) and events (a handler as a closure: stations.South.onArrival { Train train -> … }). How that works is in Objects, collections and events.
“Gives” is the type: what a property or method returns, or what an event passes to the handler. A click on an object's name takes you to that object; type in the search box to filter on object, name or explanation.
This is version 2 of what scripts see. Things are only added; what is there does not change its name.
Script.trainsProperties Every train on the layout by its name.Script.blocksProperties Every block by its name.Script.placesProperties Every station, yard, staging yard, siding and depot.Script.stationsProperties The stations.Script.yardsProperties The shunting yards.Script.stagingProperties The staging yards.Script.turnoutsProperties Every turnout with a name.Script.dutiesProperties Every duty.Script.signalsProperties Every signal placed on the layout.Script.devicesProperties Every tablet, phone or other computer registered with TRAX Control.Script.atMethods Every day at this time of this computer's clock.Script.layoutProperties The layout itself: start, shutdown, messages, power.Script.clockProperties The model clock: its time, and every model day at a time.Script.inputMethods A feedback address: a detector's or a push button's.Script.outputMethods An accessory address: a light, a signal, an uncoupler.Script.flagMethods A flag, which rules can ask too.Script.routeMethods The first way from one block to another.Script.everyMethods Again and again, every so many seconds.Script.betweenMethods Whether this computer's clock is between two times.Script.sayMethods A message on every screen.Script.announceMethods An announcement: shown and spoken on every screen.Script.logMethods A line in this script's log.Script.powerMethods The track power on or off.Script.stopAllMethods The emergency stop: every train, at once.Things.findMethods The thing with this name, or null.Things.eachMethods Every one of them.Things.valuesMethods All of them.Things.findAllMethods Those that match.Things.containsKeyMethods Whether one has this name.Layout.onStartEvents Once every script has run its own lines.Layout.onRouteSetEvents When a route is set: its turnouts sent.Layout.onRouteReadyEvents When every turnout of a route is reported in place.Layout.onRouteDisturbedEvents When a turnout of a route is reported the other way.Layout.onRouteReleasedEvents When a route is released.Layout.onStationConnectedEvents When the command station is connected again.Layout.onStationLostEvents When the command station is lost.Layout.onPowerOnEvents When the track power goes on.Layout.onPowerOffEvents When the track power goes off.Layout.onEmergencyStopEvents When every train is stopped at once.Layout.onDeviceCameEvents When a device opens TRAX Control while it had none open.Layout.onDeviceWentEvents When a device has had TRAX Control closed for a little while.Layout.onDeviceAsksEvents When a new device registers and asks to be admitted.Layout.onShutdownEvents When the scripts stop: a few seconds at most.Layout.sayMethods A message on every screen.Layout.announceMethods An announcement: shown and spoken on every screen.Layout.powerMethods The track power on or off.Layout.stopAllMethods The emergency stop.Layout.betweenMethods Whether the clock is between two times.Train.nameProperties Its name.Train.onArrivalEvents When it comes into a station or yard.Train.onDepartureEvents When it has left a station or yard altogether.Train.onEnteredEvents When its front comes into a block.Train.onLeftEvents When it has left a block altogether.Train.onWaitingEvents When its agent waits for its way to its next stop: at once and every half minute.Train.onTrackChosenEvents When its agent chose its track in a station or yard.Train.onDelayedEvents When it runs late on its timetable's service: at the threshold, and again at every as many more.Train.onNotThereEvents When it is not where its circulation expects it: not at the first stop of its run when due, or not ready to join another train.Train.arriveAtMethods The track its agent is to take at the stop it goes to now; tried at once when it waits.Train.isInMethods Whether it stands in a block or a place now.Train.startAgentMethods Starts its agent, on its own duty or the one given.Train.stopAgentMethods Stops its agent where it is.Block.nameProperties Its name.Block.occupiedProperties Whether it is occupied now.Block.placeProperties The station or yard it belongs to, or null.Block.onOccupiedEvents When it becomes occupied.Block.onFreeEvents When it becomes free.Block.onEnteredEvents When a train's front comes into it.Block.onLeftEvents When a train has left it altogether.Place.nameProperties Its name.Place.kindProperties station, yard, staging, siding, industrialSiding or depot.Place.blocksProperties Its tracks.Place.freeTracksProperties Its tracks that are free now.Place.onWaitingEvents When a train's agent waits for its way here: at once and every half minute.Place.onTrackChosenEvents When a train's agent chose its track here.Place.onArrivalEvents When a train comes into it.Place.onDepartureEvents When a train has left it altogether.Turnout.nameProperties Its name.Turnout.straightMethods Sets it straight, as a click does.Turnout.divergingMethods Sets it diverging, as a click does.Turnout.isStraightMethods Whether it is reported straight now.Turnout.onReportedEvents When it is reported set: "straight" or "diverging".Signal.nameProperties Its name.Signal.showsMethods Whether it shows this aspect now: red, green or caution.Signal.onAspectEvents When it changes: "red", "green" or "caution".Signal.onGreenEvents When it shows green.Signal.onRedEvents When it shows red.Duty.nameProperties Its name.DutyStep.trainProperties The train whose agent goes through the stop.DutyStep.stepProperties Which stop of the duty, counted from 1.DutyStep.momentProperties start, arrived, finished or waiting.DutyStep.placeProperties The stop's station or yard; null when the stop is one block.DutyStep.blockProperties The stop's block, when it is one.DutyStep.secondsProperties While waiting: how long, in seconds.DutyStep.reasonProperties While waiting: why, in TRAX Control's words.Device.nameProperties The name it registered under.Device.isHereMethods Whether it has TRAX Control open now.Device.onCameEvents When it opens TRAX Control while it had none open.Device.onWentEvents When it has had TRAX Control closed for a little while.ModelClock.timeProperties The time of day on the layout now.ModelClock.runningProperties Whether it runs.ModelClock.rateProperties How many times as fast as real time.ModelClock.atMethods Every model day at this time.ModelClock.betweenMethods Whether the model time is between two times.Input.onOnEvents When it goes on.Input.onOffEvents When it goes off.Input.onProperties Whether it is on now.Output.greenMethods Switches it green (on).Output.redMethods Switches it red (off).Flag.onMethods Sets it.Flag.offMethods Clears it.Flag.isOnMethods Whether it is set.Route.setMethods Sets it through the interlocking.Waiting.trainProperties The train.Waiting.placeProperties The station or yard it waits to go to; null for a stop of one block.Waiting.blockProperties The block it waits to go to, for a stop of one block.Waiting.secondsProperties How long it has waited.Waiting.reasonProperties Why, in TRAX Control's words.Delay.trainProperties The train.Delay.serviceProperties Its service's number this run.Delay.minutesProperties How many minutes late.Delay.placeProperties Where the service goes, when that is a station or yard.NotThere.trainProperties The train that is not there.NotThere.serviceProperties The service's number this run.NotThere.placeProperties Where it was expected, when that is a station or yard.NotThere.blockProperties Where it was expected, when that is one block.TrackChoice.trainProperties The train.TrackChoice.blockProperties The track.TrackChoice.placeProperties The station or yard.RouteEvent.nameProperties Its name.RouteEvent.fromProperties The block it starts in.RouteEvent.toProperties The block it runs to.RouteEvent.stateProperties setting, set, disturbed or released.
Nothing found.
The objects
- Script The script itselfEverything a script can write without an object in front: the layout's collections (trains, blocks, stations …), the layout as a whole (layout), the model clock (clock), and a few helpers: messages, addresses, flags, routes and time.
- Things A collectionAll things of one sort on your layout, by name: all trains, all blocks, all stations.
- Layout The layoutThe layout as a whole: what happens to all of it (the scripts starting and stopping, routes, the command station, track power, devices coming and going) and what you do for the whole layout (a message, an announcement, track power, the emergency stop).
- Train A trainA train made up on your layout, as in the Trains panel.
- Block A blockA stretch of track with a detector, as in the diagram: a track in a station, a stretch of open line.
- Place A station or yardA station, shunting yard, staging yard, siding or depot: a named group of tracks (blocks).
- Turnout A turnoutA named turnout in the diagram.
- Signal A signalA signal placed on your layout.
- Duty A dutyA duty from the Duties panel: a series of stops a train's agent runs.
- DutyStep A duty's stopWhat a method is given when a duty's stop calls it.
- Device A deviceA tablet, phone or other computer registered with TRAX Control, as on the Devices page.
- ModelClock The model clockYour layout's clock, which can run faster than real time and can stand still; the timetable runs on it.
- Input A feedback addressA feedback address on your command station or feedback module: of a detector, or of a push button or switch on the layout.
- Output An accessory addressAn accessory address on your command station: a light, a bell, an uncoupler, a signal not in the diagram.
- Flag A flagA named on/off switch that exists only inside TRAX Control.
- Route A routeA route from one block to another as TRAX Control finds it: the first way that keeps its direction and needs no turnout by hand.
- Waiting A waiting agentWhat onWaiting gives when a train's agent waits for its route to the next stop: which train, where to, how long already and why.
- Delay A delayWhat onDelayed gives when a timetable train runs late: which train, which service, how many minutes and where to.
- NotThere Stock that is not thereWhat onNotThere gives when a train is not where its circulation expects it: which train, which service and where it should have been.
- TrackChoice A chosen trackWhat a station's onTrackChosen gives when a train's agent chooses a track there: the train, the track and the station.
- RouteEvent A route changingWhat the layout's route events give (onRouteSet, onRouteReady, onRouteDisturbed, onRouteReleased): the route's name, from which block to which, and how it stands now.