aboutsummaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
authorY. Wang <yw05@forksworld.de>2021-11-25 18:56:38 +0100
committerY. Wang <yw05@forksworld.de>2021-11-25 18:56:38 +0100
commitaafbf456adb28730cbb8451c3889f530b841e5c9 (patch)
treea581697c898959a19a2bf476e919acf80fbb4cb1 /assets
parent64d96a35feb9a2035fa4d7627a617e7d87ef0574 (diff)
downloadadvtrains-aafbf456adb28730cbb8451c3889f530b841e5c9.tar.gz
advtrains-aafbf456adb28730cbb8451c3889f530b841e5c9.tar.bz2
advtrains-aafbf456adb28730cbb8451c3889f530b841e5c9.zip
Reformat API documentation; change font as this was requested
Diffstat (limited to 'assets')
-rw-r--r--assets/manual2/manual.tex448
1 files changed, 232 insertions, 216 deletions
diff --git a/assets/manual2/manual.tex b/assets/manual2/manual.tex
index e5eb713..dcbe1e7 100644
--- a/assets/manual2/manual.tex
+++ b/assets/manual2/manual.tex
@@ -1,5 +1,7 @@
\documentclass[notitlepage]{article}
\usepackage[a4paper,margin=2cm]{geometry}
+\usepackage{beton}
+\usepackage{eulervm}
\usepackage[T1]{fontenc}
\setlength{\parindent}{0pt}
\usepackage{listings}
@@ -22,9 +24,6 @@
\newcommand{\ovar}[1]{$\mathit{[\langle}$\textrm{\textmd{\textit{#1}}}$\mathit{\rangle]}$}
-\newcommand{\argname}[1]{\var{#1}}
-\newcommand{\optargname}[1]{\ovar{#1}}
-
\def\luatrue{\texttt{true}}
\def\luafalse{\texttt{false}}
\def\luanil{\texttt{nil}}
@@ -38,12 +37,25 @@
\end{center}
}
-\newenvironment{ttdescription}{
- \renewcommand{\descriptionlabel}[1]{\hspace{\labelsep}\texttt{\textbf{##1}}}
- \begin{description}
- }{
- \end{description}
+\newenvironment{apidoc}{
+ \begin{list}{}{
+ \setlength{\labelwidth}{0pt}
+ \setlength{\labelsep}{0pt}
+ \setlength{\leftmargin}{0pt}
+ \setlength{\listparindent}{1em}
}
+\newcommand{\apient}[2]{##1\hfill {##2}\par}
+\newcommand{\api}[2]{\apient{\texttt{##1}}{##2}}
+\newcommand{\apiasp}[1]{\apient{##1}{signal aspect}}
+\newcommand{\apicmd}[1]{\api{##1}{command}}
+\newcommand{\apienum}[1]{\api{##1}{enumeration}}
+\newcommand{\apifield}[1]{\api{##1}{field}}
+\newcommand{\apiitem}[1]{\apient{##1}{item}}
+\newcommand{\apivar}[1]{\api{##1}{variable}}
+\newcommand{\apifunc}[1]{\api{##1}{function}}
+\newcommand{\apilex}[1]{\api{##1}{lexical syntax}}
+\newcommand{\apipat}[1]{\api{##1}{pattern}}
+}{\end{list}}
\tikzset{
signal/.pic = {
@@ -78,6 +90,7 @@ This manual is written for the specific version of \advtrains{} that the corresp
A notable portion of the manual is influenced by various other guides and manuals for \advtrains. In particular:
\begin{itemize}
+\item The format of the API documentation is influenced by R$^7$RS.
\item Section \ref{s:interlocking} is written with reference to orwell's interlocking guide and Blockhead's video explaining the three-station setup. The links to both sources can be found in that section.
\item Section \ref{s:luaatc} is a reformatted and restructured version of the LuaATC documentation, written by orwell and Maverick2797.
\item Section \ref{s:tilrwt} is a modified version of the railway time API documentation written by orwell. Part of the section is also taken from \texttt{advtrains\_line\_automation/railwaytime.lua}
@@ -90,7 +103,7 @@ A notable portion of the manual is influenced by various other guides and manual
\item Unless otherwise specified, the unit of acceleration is meter per second squared.
\item The \tikz \pic at (0,0) {tcb}; symbol stands for a TCB assigned to the track.
\item The \tikz \pic (0,0) {signal=red}; symbol stands for a TCB assigned to the track with a signal assigned to the TCB side opposite of that of the direction in which the TCB is facing (here: the signal is assigned to the left side of the TCB).
-\item Arguments to functions and ATC commands are delimited using angle brackets \argname{like this}.
+\item Arguments to functions and ATC commands are delimited using angle brackets \var{like this}.
\item Argument names are generally lowercase, but the first letter may be capitalized.
\item Lua string constants are written without quotation marks when the content does not resemble any numeric or symbolic constant and when used as enumerators or table indices.
\item Like in other parts of \advtrains, Lua code is indented with tabs.
@@ -241,14 +254,14 @@ Exercise: Build a T junction. You will need this later in section \ref{s:iljunct
\advtrains{} also have a few special tracks, some of which are explain in their own sections.
-\begin{itemize}
-\item ATC track: track that sends ATC commands to a train (see section \ref{s:atc} for more information)
-\item Loading track: track that makes a train load as many items as possible from a chest below the track if the train is moving in the direction indicated by the arrow on the track at a speed lower than 2m/s.
-\item Unloading track: track that makes a train unload as many items as possible into a chest below the track if the train is moving in the direction indicated by the arrow on the track at a speed lower than 2m/s.
-\item Temporary speed restriction rail: track that forces a train to pass with an arbitrary speed limit.
-\item Station track: track that makes trains temporarily stop at a given point (see section \ref{s:stoprail} for more information)
-\item LuaATC track: track that can be programmed in Lua (see section \ref{s:luaatc} for more information).
-\end{itemize}
+\begin{apidoc}
+\item \apiitem{ATC track} Track that sends ATC commands to a train (see section \ref{s:atc} for more information)
+\item \apiitem{Loading track} Track that makes a train load as many items as possible from a chest below the track if the train is moving in the direction indicated by the arrow on the track at a speed lower than 2m/s.
+\item \apiitem{Unloading track} Track that makes a train unload as many items as possible into a chest below the track if the train is moving in the direction indicated by the arrow on the track at a speed lower than 2m/s.
+\item \apiitem{Temporary speed restriction rail} Track that forces a train to pass with an arbitrary speed limit.
+\item \apiitem{Station track} Track that makes trains temporarily stop at a given point (see section \ref{s:stoprail} for more information)
+\item \apiitem{LuaATC track} Track that can be programmed in Lua (see section \ref{s:luaatc} for more information).
+\end{apidoc}
\section{Train controls}\label{s:controls}
To get on a train, click on the train while its doors are open, or click on the train while holding Sneak key. You need to be in the driver stand in order to control the train.
@@ -429,36 +442,36 @@ ATC is a method of automatically controlling trains. Certain modes can be direct
ATC tracks can be used to send custom ATC commands to the train passing the track. The ATC commands available are listed below:
-\begin{ttdescription}
-\item[A0] Disable ARS.
-\item[A1] Enable ARS.
-\item[BB] Activate the emergency brake until the train stops.
-\item[B\argname{speed}] Brake until \argname{speed} is reached.
-\item[Cpl] Enable autocouple mode.
-\item[D\argname{time}] Wait for \argname{time} seconds before continuing execution.
-\item[I\argname{condition}\argname{consequent};] Execute \argname{consequent} if \argname{condition} is met.
-\item[I\argname{condition}\argname{consequent}E\argname{alternate};] Execute \argname{consequent} if \argname{condition} is met, \argname{alternate} otherwise.
-\item[K] Kick all passengers (players not driving the train) off the train \textbf{only when the train is stopped and its doors are open}.
-\item[OC] Close doors on both sides.
-\item[OL] Open doors on the left side while, closing doors on the right side (if open).
-\item[OR] Open doors on the right side while, closing doors on the left side (if open).
-\item[R] Reverse the train \textbf{only when the train is not moving}.
-\item[S\argname{speed}] Accelerate to \argname{speed}, or roll if the train is faster than \argname{speed}.
-\item[W] Wait until the target speed set by the \texttt{S} or \texttt{B} command is reached.
-\end{ttdescription}
+\begin{apidoc}
+\item \apilex{A0} Disables ARS.
+\item \apilex{A1} Enables ARS.
+\item \apilex{BB} Actives the emergency brake until the train stops.
+\item \apilex{B\var{speed}} Brakes until \var{speed} is reached.
+\item \apilex{Cpl} Enables autocouple mode.
+\item \apilex{D\var{time}} Waits for \var{time} seconds before continuing execution.
+\item \apilex{I\var{condition}\var{consequent};} Executes \var{consequent} if \var{condition} is met.
+\item \apilex{I\var{condition}\var{consequent}E\var{alternate};} Executes \var{consequent} if \var{condition} is met, \var{alternate} otherwise.
+\item \apilex{K} Kicks all passengers (players not driving the train) off the train only when the train is stopped and its doors are open.
+\item \apilex{OC} Closes doors on both sides.
+\item \apilex{OL} Opens doors on the left side and closes doors on the right side (if open).
+\item \apilex{OR} Opens doors on the right side and closes doors on the left side (if open).
+\item \apilex{R} Reverses the train only when the train is not moving.
+\item \apilex{S\var{speed}} Accelerates to \var{speed} or roll if the train is faster then \var{speed}.
+\item \apilex{W} Waits until the target set by \texttt{S} or \texttt{B} command is reached.
+\end{apidoc}
For the \texttt{B}, \texttt{D}, and \texttt{S} commands, the argument should be written immediately after the command, without any whitespace.
-The following \argname{condition}s are available for the ATC \texttt{I} command:
+The following \var{condition}s are available for the ATC \texttt{I} command:
-\begin{ttdescription}
-\item[+] True when the train is driving in the same direction as the arrows on the ATC rail.
-\item[-] True when the train is driving in the opposite direction of the arrow on the ATC rail.
-\item[<\argname{speed}] True when the train is slower than \argname{speed}.
-\item[>\argname{speed}] True when the train is faster than \argname{speed}.
-\item[<=\argname{speed}] True when the train is not faster than \argname{speed}.
-\item[>=\argname{speed}] True when the train is not slower than \argname{speed}.
-\end{ttdescription}
+\begin{apidoc}
+\item \apilex{+} True when the train is driving in the same direction as the arrows on the ATC rail.
+\item \apilex{-} True when the train is driving in the opposite direction of the arrow on the ATC rail.
+\item \apilex{<\var{speed}} True when the train is slower than \var{speed}.
+\item \apilex{>\var{speed}} True when the train is faster than \var{speed}.
+\item \apilex{<=\var{speed}} True when the train is not faster than \var{speed}.
+\item \apilex{>=\var{speed}} True when the train is not slower than \var{speed}.
+\end{apidoc}
\subsection{LZB}\label{s:lzb}
@@ -543,7 +556,7 @@ In some cases, you may need to manually add TCB sides to a track section. This c
To merge two track sections:
\begin{itemize}
\item Click ``Join into other section'' in the formspec of the section that needs to be merged.
-\item Click ``Join with \argname{section}'' in the formspec of the section to merge the other section into, where \argname{section} is the ID of the section that needs to be merged.
+\item Click ``Join with \var{section}'' in the formspec of the section to merge the other section into, where \var{section} is the ID of the section that needs to be merged.
\end{itemize}
To abort the procedure above, click on the ``X'' button on the right.
@@ -623,14 +636,14 @@ After finishing the route, you are prompted for the name of the route. It is rec
Automatic routesetting (ARS) is a method of choosing a route based on a set of matching patterns. In the previous section, you learned to set up a route, and there is a text input box where you can enter the ARS rules. This area is empty by default, which means that the route is not selected in any case.
ARS rules are delimited by a newline. Each line can be one of the following:
-\begin{ttdescription}
-\item[\# \argname{comment}] Comment
-\item[LN \argname{line}] Matches trains with the exact line name \argname{line}.
-\item[RC \argname{routing code}] Matches trains that contain the routing code \argname{routing code}.
-\item[!LN \argname{line}] Matches trains with a different line name than \argname{line}.
-\item[!RC \argname{routing code}] Matches trains that do not contain the routing code \argname{routing code}.
-\item[*] Matches all trains
-\end{ttdescription}
+\begin{apidoc}
+\item \apipat{\# \var{comment}} Comment
+\item \apipat{LN \var{line}} Matches trains with the exact line name \var{line}.
+\item \apipat{RC \var{routing code}} Matches trains that contain the routing code \var{routing code}.
+\item \apipat{!LN \var{line}} Matches trains with a different line name than \var{line}.
+\item \apipat{!RC \var{routing code}} Matches trains that do not contain the routing code \var{routing code}.
+\item \apipat{*} Matches all trains
+\end{apidoc}
A whitespace is required before the argument.
@@ -808,39 +821,32 @@ The signal placement conventions assume right-hand traffic.
Ks signals are combined signals that combines the features of main signals and distant signals. The system was developed by the Deutsche Bahn AG after the Deutsche Bundesbahn in West Germany and the Deutsche Reichsbahn in East Germany merged, and the goal was to replace the other four signaling system in use in Germany, which still exist today.
Ks signals have the following aspects:
-\begin{description}
-\item[Hp 0] (Red light) Stop.
-\item[Ks 1] (Green light) Proceed at maximum speed or with the speed limit shown on the Zs 3 indicator on the main signal (if present) and expect to pass the next main signal at maximum speed or, if the green light is flashing, with the speed limit shown on the Zs 3v indicator directly below the main signal.
-\item[Ks 2] (Yellow light) Proceed at maximum speed or with the speed limit shown on the Zs 3 indicator on the main signal (if present) and expect to stop at the next main signal.
-\end{description}
+\begin{apidoc}
+\item \apiasp{Hp 0} Red light: Stop.
+\item \apiasp{Ks 1} Green light: Proceed at maximum speed or with the speed limit shown on the Zs 3 indicator on the main signal (if present) and expect to pass the next main signal at maximum speed or, if the green light is flashing, with the speed limit shown on the Zs 3v indicator directly below the main signal.
+\item \apiasp{Ks 2} Yellow light: Proceed at maximum speed or with the speed limit shown on the Zs 3 indicator on the main signal (if present) and expect to stop at the next main signal.
+\end{apidoc}
In addition, Sh 1 (see below) may also appear along with Hp 0, in which case the train proceeds in shunt mode.
\subsubsection{Shunt signals}
-\begin{description}
-\item[Sh 0] (two horizontally aligned red lights) Stop.
-\item[Sh 1/(ex-DR) Ra 12] (two white lights aligned on a slanted line) Shunting allowed.
-\end{description}
+\begin{apidoc}
+\item \apiasp{Sh 0} Two horizontally aligned red lights: Stop.
+\item \apiasp{Sh 1/(ex-DR) Ra 12} Two white lights aligned on a slanted line: Shunting allowed.
+\end{apidoc}
\subsubsection{Signal signs}
-\advtrains{} has a few types of signal signs, which can be placed by the corresponding placers.
-\begin{description}
-\item[Permanent speed restriction sign] Signal signs that set the permanent speed restriction (the same ones set by most regular signals): Zs 3 and Zs 10.
-\item[Line speed restriction sign] Signal signs that set the line speed restriction: Lf 7.
-\item[Temporary speed restriction sign] Signal signs that set the temporary speed restriction: Lf 1/2 and Lf 3.
-\item[Miscellaneous signal sign] Signal signs that do not give speed restriction.
-\end{description}
-
-The aspect of the signal sign can be adjusted with the trackworker, but only in the range limited by the placer. The following signal aspects exist for signal signs:
-\begin{description}
-\item[Zs 3] (white number on a black background) Proceed with the speed restriction shown on the sign.
-\item[Zs 10] (a sign shaped like an upward-pointing arrow) The speed restriction set by Zs 3 and regular signals is lifted.
-\item[(ex-DR) Lf 1/2] (black number on an orange background) Proceed with the temporary speed restriction shown on the sign.
-\item[Lf 3] (black ``E'' on a white background) The temporary speed restriction set by Lf 1/2 is lifted.
-\item[Lf 7] (black number on a white background) Proceed with the line speed restriction shown on the sign.
-\item[Ra 10] (the text ``Halt für Rangierfahrten'' on a white semicircle) Do not proceed if the train is in shunt mode. This signal is conventionally placed on the left side of the track.
-\item[PAM] (in-game only; ``S'' below a green arrow) Proceed without shunt mode.
-\end{description}
+\advtrains{} has a few types of signal signs, which can be placed by the corresponding placers. The aspect of the signal sign can be adjusted with the trackworker, but only in the range limited by the placer.
+
+\begin{apidoc}
+\item \apiasp{Zs 3} White number on a black background: Proceed with the main speed restriction shown on the sign.
+\item \apiasp{Zs 10} An upward-pointing arrow: The speed restriction set by Zs 3 and regular signals is lifted.
+\item \apiasp{(ex-DR) Lf 1/2} Black number on an orange background: Proceed with the temporary speed restriction shown on the sign.
+\item \apiasp{Lf 3} Black ``E'' on a white background: The temporary speed restriction set by Lf 1/2 is lifted.
+\item \apiasp{Lf 7} Black number on a white background: Proceed with the line speed restriction shown on the sign.
+\item \apiasp{Ra 10} The text ``Halt für Rangierfahrten'' on a white semicircle: Do not proceed if the train is in shunt mode. This signal is conventionally placed on the left side of the track.
+\item \apiasp{PAM} The text ``S'' below a green arrow: Proceed without shunt mode. This sign does not have a real-life counterpart.
+\end{apidoc}
\subsubsection{Differences from real-life signals}
The signal book at \url{https://www.bahnstatistik.de/Signale_pdf/SB-DBAG.pdf} is used for reference. This list is not comprehensive.
@@ -869,25 +875,25 @@ Each active component in LuaATC is assigned to an environment where all relevant
The following chat commands are available. These commands also require the \texttt{atlatc} privilege.
-\begin{ttdescription}
-\item[/env\_create \argname{name}] Create an environment named \argname{name}. Please choose the name wisely, as you can't rename environments without deleting and recreating the environment.
-\item[/env\_setup \argname{name}] Edit the initialization code for the environment named \argname{name}. You can also delete the environment from the editor or re-run the init code.
-\item[/env\_subscribe \argname{name}] Subscribe to the environment named \argname{name}.
-\item[/env\_unsubscribe \argname{name}] Unsubscribe from the environment named \argname{name}.
-\item[/env\_subscriptions \optargname{name}] List your subscriptions or, if \argname{name} is provided, list the players subscribed to the environment named \argname{name}.
-\end{ttdescription}
+\begin{apidoc}
+\item \apicmd{/env\_create \var{name}} Create an environment named \var{name}. Please choose the name wisely, as you can't rename environments without deleting and recreating the environment.
+\item \apicmd{/env\_setup \var{name}} Edit the initialization code for the environment named \var{name}. You can also delete the environment from the editor or re-run the init code.
+\item \apicmd{/env\_subscribe \var{name}} Subscribe to the environment named \var{name}.
+\item \apicmd{/env\_unsubscribe \var{name}} Unsubscribe from the environment named \var{name}.
+\item \apicmd{/env\_subscriptions \ovar{name}} List your subscriptions or, if \var{name} is provided, list the players subscribed to the environment named \var{name}.
+\end{apidoc}
-After subscribing to an environment, you will recieve messages related to the environment.
+After subscribing to an environment, you will receive messages related to the environment.
Each environment can contain some \textit{initialization code} (called \textit{init code} for short). The initialization code is run every time the server starts or when the ``Run InitCode'' button in the init code editor is clicked. Please note that you need to click the button to apply the changes to the init code.
The init code is typically used to add functions shared among LuaATC components.
\subsection{LuaATC components}
-\begin{description}
-\item[LuaATC track] Tracks that can execute LuaATC code.
-\item[LuaATC operator panel] Simple node that can execute LuaATC code (similar to Luacontrollers in the mesecons modpack).
-\end{description}
+\begin{apidoc}
+\item \apiitem{LuaATC track} Tracks that can execute LuaATC code.
+\item \apiitem{LuaATC operator panel} Simple node that can execute LuaATC code (similar to Luacontrollers in the mesecons modpack).
+\end{apidoc}
\subsection{Standard Lua variables}
The following standard Lua libraries are available:
@@ -917,118 +923,128 @@ The following standard Lua functions are available:
It is an error to globally override the provided Lua library functions.
\subsection{Environment-specific variables}
-\begin{ttdescription}
-\item[F] Global table shared between all components of the environment. The content of this table is discarded on server shutdown or execution of the init code. Functions are allowed in the table.
-\item[S] Global table persistently shared between all components of the environment. This variable may not contain functions. The existence of certain patterns in this table may violate implementation restrictions.
-\end{ttdescription}
+\begin{apidoc}
+\item \apivar{F} Global table shared between all components of the environment. The content of this table is discarded on server shutdown or execution of the init code. Functions are allowed in the table.
+\item \apivar{S} Global table persistently shared between all components of the environment. This variable may not contain functions. The existence of certain patterns in this table may violate implementation restrictions.
+\end{apidoc}
\subsection{LuaATC helpers}
-\begin{ttdescription}
-\item[POS(\argname{x},\argname{y},\argname{z})] Returns a position vector of the form \texttt{\{x=\argname{x}, y=\argname{y}, z=\argname{z}\}}.
-\end{ttdescription}
+\begin{apidoc}
+\item \apifunc{POS(\var{x},\var{y},\var{z})} Returns a position vector of the form \texttt{\{x=\var{x}, y=\var{y}, z=\var{z}\}}.
+\end{apidoc}
\subsection{Passive components}
-The \argname{pos} arguments in this section accept a position vector or the name of a passive component.
-\begin{ttdescription}
-\item[getstate(\argname{pos})] Returns the state of the passive component at \argname{pos}.
-\item[setstate(\argname{pos},\argname{state})] Sets the state of the passive component at \argname{pos} to \argname{state}.
-\item[is\_passive(\argname{pos})] Returns a boolean indicating whether a passive component exists at \argname{pos} and whether \argname{pos} is a name of an existing passive component.
-\end{ttdescription}
-
-The primitive red/green light signals can be accessed with this API. The values \texttt{red} and \texttt{green} correspond to the status when the signal shows a red or green light, respectively.
-
-Two-way turnouts with one straight direction can have the \texttt{st} status for the straight direction or the \texttt{cr} direction for the other direction that is not straight.
-
-The Y-shaped and three-way turnouts can have a few states, looking from the convergence point:
-\begin{ttdescription}
-\item[l] The turnout points to the left.
-\item[c] The turnout is straight (three-way turnouts only).
-\item[r] The turnout points to the right.
-\end{ttdescription}
-
-Unprotected full-node mesecon switches can have the states \texttt{on} or \texttt{off}, corresponding to the status of being switched on and off, respectively.
-
-Andrew's crosses are similar to the mesecon switches mentioned above, except the status controls whether the light blinks or is off.
+The \var{pos} arguments in this section accept a position vector or the name of a passive component.
+\begin{apidoc}
+\item \apifunc{getstate(\var{pos})} Returns the state of the passive component at \var{pos}.
+\item \apifunc{setstate(\var{pos},\var{state})} Sets the state of the passive component at \var{pos} to \var{state}.
+\item \apifunc{is\_passive(\var{pos})} Returns a boolean indicating whether a passive component exists at \var{pos} and whether \var{pos} is a name of an existing passive component.
+\end{apidoc}
+
+The basic light signals provided by \advtrains{} (the ones that can only show red or green) can be accessed with this API. The following \var{state}s are accepted:
+\begin{apidoc}
+\item \apienum{green} The signal shows a green light.
+\item \apienum{red} The signal shows a red light.
+\end{apidoc}
+
+Two-way turnouts with one straight direction accept the following \var{state}s:
+\begin{apidoc}
+\item \apienum{st} The turnout lets the train continue in the direction that can be reached with a straight track.
+\item \apienum{cr} The turnout lets the train continue in the direction that needs to be reached with a curve.
+\end{apidoc}
+
+The Y-shaped and three-way turnouts can have a few \var{state}s, looking from the convergence point:
+\begin{apidoc}
+\item \apienum{l} The turnout points to the left.
+\item \apienum{c} The turnout is straight (three-way turnouts only).
+\item \apienum{r} The turnout points to the right.
+\end{apidoc}
+
+Unprotected full-node mesecon switches and Andrew's crosses can have one of the following \var{state}s:
+\begin{apidoc}
+\item \apienum{off} The item is turned off.
+\item \apienum{on} The item is turned on.
+\end{apidoc}
Passive components can be named using the passive component naming tool. Passive component names (as strings) can be used as coordinates, provided that the passive component with the name exists. Please note that the ``Signal Name'' field in the signal formspec is unrelated to the passive component name of the signal.
\subsection{Interrupts}
-\begin{ttdescription}
-\item[interrupt(\argname{time},\argname{message})] Triggers an \texttt{int} event on this component after \argname{time} seconds with \argname{message} as the message. \argname{Message} can be any Lua data type. This function is not available for the init code.
-\item[interrupt\_safe(\argname{time},\argname{message})] Like \texttt{interrupt}, but does not add an interrupt and when an interrupt of any type is present for this component. The return value is a boolean indicating whether the interrupt was successfully added.
-\item[interrupt\_pos(\argname{pos},\argname{message})] Immediately triggers an \texttt{ext\_int} event on the active component at \argname{pos} with \argname{message} passed like with \texttt{interrupt}. Please keep in mind that this function can be a source of a fork bomb.
-\item[clear\_interrupts()] Removes any pending interrupts of this node.
-\end{ttdescription}
+\begin{apidoc}
+\item \apifunc{interrupt(\var{time},\var{message})} Triggers an \texttt{int} event on this component after \var{time} seconds with \var{message} as the message. \var{Message} can be any Lua data type. This function is not available for the init code.
+\item \apifunc{interrupt\_safe(\var{time},\var{message})} Like \texttt{interrupt}, but does not add an interrupt and when an interrupt of any type is present for this component. The return value is a boolean indicating whether the interrupt was successfully added.
+\item \apifunc{interrupt\_pos(\var{pos},\var{message})} Immediately triggers an \texttt{ext\_int} event on the active component at \var{pos} with \var{message} passed like with \texttt{interrupt}. Please keep in mind that this function can be a source of a fork bomb.
+\item \apifunc{clear\_interrupts()} Removes any pending interrupts of this node.
+\end{apidoc}
\subsection{External communication}
-\begin{ttdescription}
-\item[digiline\_send(\argname{channel},\argname{message})] Sends \argname{message} to the digiline channel named \argname{channel}. This function is only available for active components.
-\end{ttdescription}
+\begin{apidoc}
+\item \apifunc{digiline\_send(\var{channel},\var{message})} Sends \var{message} to the digiline channel named \var{channel}. This function is only available for active components.
+\end{apidoc}
\subsection{Interlocking}
The following are available if \texttt{advtrains\_interlocking} is enabled.
-\begin{ttdescription}
-\item[can\_set\_route(\argname{pos},\argname{name})] Returns a boolean indicating whether the route named \argname{name} of the signal at \argname{pos} can be set.
-\item[set\_route(\argname{pos},\argname{name})] Sets the route named \argname{name} of the signal at \argname{pos}.
-\item[cancel\_route(\argname{pos})] Cancels the route that is set from the signal at \argname{pos}.
-\item[get\_aspect(\argname{pos})] Returns the signal aspect of the signal at \argname{pos}. Please refer to section \ref{s:sigasp} for the structure of signal aspect tables.
-\end{ttdescription}
+\begin{apidoc}
+\item \apifunc{can\_set\_route(\var{pos},\var{name})} Returns a boolean indicating whether the route named \var{name} of the signal at \var{pos} can be set.
+\item \apifunc{set\_route(\var{pos},\var{name})} Sets the route named \var{name} of the signal at \var{pos}.
+\item \apifunc{cancel\_route(\var{pos})} Cancels the route that is set from the signal at \var{pos}.
+\item \apifunc{get\_aspect(\var{pos})} Returns the signal aspect of the signal at \var{pos}. Please refer to section \ref{s:sigasp} for the structure of signal aspect tables.
+\end{apidoc}
\subsection{Railway time}
the railway time API described in section \ref{s:tilrwt} is available in the \texttt{rwt} table.
-\begin{ttdescription}
-\item[schedule(\argname{time},\argname{message})] Triggers a \texttt{schedule} event at \argname{time} with the message \argname{message}. Only one event can be scheduled this way.
-\item[schedule\_in(\argname{time},\argname{message})] Like \texttt{schedule}, but \argname{time} is given as the time until the event is triggered.
-\end{ttdescription}
+\begin{apidoc}
+\item \apifunc{schedule(\var{time},\var{message})} Triggers a \texttt{schedule} event at \var{time} with the message \var{message}. Only one event can be scheduled this way.
+\item \apifunc{schedule\_in(\var{time},\var{message})} Like \texttt{schedule}, but \var{time} is given as the time until the event is triggered.
+\end{apidoc}
\subsection{Train control}
These functions and variables described in this section are only available to LuaATC tracks. Exceptions are explicitly stated. These functions, except \texttt{atc\_send\_to\_train}, require that a reference to the train can be made, i.e. when a train is on (or passing) the track or when execution of the code takes place as part of the approach callback.
-\begin{ttdescription}
-\item[atc\_arrow] A boolean indicating whether the train is driving in the direction of the arrow indicated on the ATC track, or \luanil{} when there is no train.
-\item[atc\_id] A string containing the ID of the train, or \luanil{} if there is no train.
-\item[atc\_reset()] Resets the ATC command of the train or returns \luafalse{} if there is no train.
-\item[atc\_send(\argname{command})] Sends the ATC command \argname{command} to the train and returns a boolean indicating whether the ATC command is successfully set for the train.
-\item[atc\_send\_to\_train(\argname{id},\argname{command})] Sends the ATC command \argname{command} to the train with the ID \argname{id}. This function is not limited to LuaATC tracks.
-\item[atc\_set\_ars\_disable(\argname{bool})] Disables ARS for the train when \argname{bool} is \luatrue{}; enables ARS for the train when \argname{bool} is \luafalse{}.
-\item[atc\_set\_text\_inside(\argname{text})] Sets \argname{text} as the text shown on the inside of the train.
-\item[atc\_set\_text\_outside(\argname{text})] Sets \argname{text} as the text shown on the outside of the train.
-\item[get\_line()] Returns the line name of the train.
-\item[get\_rc()] Returns the routing code of the train.
-\item[set\_line(\argname{text})] Sets \argname{text} as the line name of the train.
-\item[set\_rc(\argname{text})] Sets \argname{text} as the routing code of the train.
-\item[train\_length()] Returns the number of wagons in the train.
-\end{ttdescription}
+\begin{apidoc}
+\item \apivar{atc\_arrow} A boolean indicating whether the train is driving in the direction of the arrow indicated on the ATC track, or \luanil{} when there is no train.
+\item \apivar{atc\_id} A string containing the ID of the train, or \luanil{} if there is no train.
+\item \apifunc{atc\_reset()} Resets the ATC command of the train or returns \luafalse{} if there is no train.
+\item \apifunc{atc\_send(\var{command})} Sends the ATC command \var{command} to the train and returns a boolean indicating whether the ATC command is successfully set for the train.
+\item \apifunc{atc\_send\_to\_train(\var{id},\var{command})} Sends the ATC command \var{command} to the train with the ID \var{id}. This function is not limited to LuaATC tracks.
+\item \apifunc{atc\_set\_ars\_disable(\var{bool})} Disables ARS for the train when \var{bool} is \luatrue{}; enables ARS for the train when \var{bool} is \luafalse{}.
+\item \apifunc{atc\_set\_text\_inside(\var{text})} Sets \var{text} as the text shown on the inside of the train.
+\item \apifunc{atc\_set\_text\_outside(\var{text})} Sets \var{text} as the text shown on the outside of the train.
+\item \apifunc{get\_line()} Returns the line name of the train.
+\item \apifunc{get\_rc()} Returns the routing code of the train.
+\item \apifunc{set\_line(\var{text})} Sets \var{text} as the line name of the train.
+\item \apifunc{set\_rc(\var{text})} Sets \var{text} as the routing code of the train.
+\item \apifunc{train\_length()} Returns the number of wagons in the train.
+\end{apidoc}
\subsubsection{Shunting and freight code}
Freight codes are delimited with exclamation marks (\texttt{!}).
-\begin{ttdescription}
-\item[set\_autocouple()] Enables autocouple mode for the train.
-\item[unset\_autocouple()] Disables autocouple mode for the train.
-\item[split\_at\_fc(\argname{command},\argname{len})] Like \texttt{split\_at\_index}, but the train is split in a way that all wagons in the first part of the train have an empty freight code or the same freight code. \argname{Len} specifies the maximum length of the first part of the train. The freight code of the wagons of the first part is returned.
-\item[split\_at\_index(\argname{index},\argname{command})] Splits the train at \argname{index}, where all wagons with an index greater than or equal to \argname{index} are in the second train, and sends the ATC command \argname{command} to the second train.
-\item[split\_off\_locomotive(\argname{command},\argname{len})] Like \texttt{split\_at\_fc}, but the train is split in a way that the locomotives at the beginning of the train make up the first part of the train.
-\item[step\_fc()] Steps the freight codes of all wagos forward. The first code is selected if the end of the freight code string is reached, unless the string ends with a question mark (\texttt{?}), in which case the order of the freight code is reversed.
-\end{ttdescription}
+\begin{apidoc}
+\item \apifunc{set\_autocouple()} Enables autocouple mode for the train.
+\item \apifunc{unset\_autocouple()} Disables autocouple mode for the train.
+\item \apifunc{split\_at\_fc(\var{command},\var{len})} Like \texttt{split\_at\_index}, but the train is split in a way that all wagons in the first part of the train have an empty freight code or the same freight code. \var{Len} specifies the maximum length of the first part of the train. The freight code of the wagons of the first part is returned.
+\item \apifunc{split\_at\_index(\var{index},\var{command})} Splits the train at \var{index}, where all wagons with an index greater than or equal to \var{index} are in the second train, and sends the ATC command \var{command} to the second train.
+\item \apifunc{split\_off\_locomotive(\var{command},\var{len})} Like \texttt{split\_at\_fc}, but the train is split in a way that the locomotives at the beginning of the train make up the first part of the train.
+\item \apifunc{step\_fc()} Steps the freight codes of all wagos forward. The first code is selected if the end of the freight code string is reached, unless the string ends with a question mark (\texttt{?}), in which case the order of the freight code is reversed.
+\end{apidoc}
\subsection{Events}
The event table is passed as the \texttt{event} global variable when an event is triggered. The \texttt{type} field of the event is a string indicating the type of the event, and the field indexed by the event type string includes the \luatrue{} constant. Additional fields may be provided, depending on the event type.
The following events are available in LuaATC:
-\begin{ttdescription}
-\item[approach] Triggered when a train approaches the track. This event can be triggered multiple times for the same train.
-\item[digiline] Like \texttt{int} (see below), but triggered with digiline. The channel and message are included in the \texttt{channel} and \texttt{message} fields, respectively.
-\item[ext\_int] Like \texttt{int} (see below), but triggered when the interrupt is called by a different active component. The message is only included in the \texttt{message} field.
-\item[int] Triggered by a call to \texttt{interrupt}. The message is included in the \texttt{msg} and (supposedly for backward compatibility) \texttt{message} fields.
-\item[punch] Triggered when the LuaATC operator panel is punched.
-\item[schedule] Like \texttt{int}, but triggered by the scheduler instead. The message is included in the \texttt{msg} field.
-\item[train] Triggered when a train drives pass the LuaATC track. The event table contains an \texttt{id} field, which holds the train ID. This event is only available to LuaATC tracks.
-\end{ttdescription}
+\begin{apidoc}
+\item \apienum{approach} Triggered when a train approaches the track. This event can be triggered multiple times for the same train.
+\item \apienum{digiline} Like \texttt{int} (see below), but triggered with digiline. The channel and message are included in the \texttt{channel} and \texttt{message} fields, respectively.
+\item \apienum{ext\_int} Like \texttt{int} (see below), but triggered when the interrupt is called by a different active component. The message is only included in the \texttt{message} field.
+\item \apienum{int} Triggered by a call to \texttt{interrupt}. The message is included in the \texttt{msg} and (supposedly for backward compatibility) \texttt{message} fields.
+\item \apienum{punch} Triggered when the LuaATC operator panel is punched.
+\item \apienum{schedule} Like \texttt{int}, but triggered by the scheduler instead. The message is included in the \texttt{msg} field.
+\item \apienum{train} Triggered when a train drives pass the LuaATC track. The event table contains an \texttt{id} field, which holds the train ID. This event is only available to LuaATC tracks.
+\end{apidoc}
\subsubsection{Approach callback}
This subsection is relevant to the \texttt{approach} event.
-\begin{ttdescription}
-\item[atc\_set\_lzb\_tsr(\argname{speed})] Set the temporary speed restriction of the train to \argname{speed} at the position of the track. This needs to be called every time the \texttt{approach} callback is triggered.
-\end{ttdescription}
+\begin{apidoc}
+\item \apifunc{atc\_set\_lzb\_tsr(\var{speed})} Set the temporary speed restriction of the train to \var{speed} at the position of the track. This needs to be called every time the \texttt{approach} callback is triggered.
+\end{apidoc}
Approach callbacks are executing during the train step. This may be problematic when performing actions with side effects on the environment that the train is in, such as switching turnouts or setting routes. It is encouraged to only run things that are necessary and defer everything else to an interrupt or a schedule.
The following operations are safe in the approach callback:
@@ -1068,11 +1084,11 @@ This chapter shows some example setups that you can use on your rail lines. Thes
\subsection{Railway time}\label{s:tilrwt}
\advtrains{} depends on Minetest's ``dtime'' for most operations, and may slow itself down when necessary (e.g. in a situation with a lot of lag) to prevent unexpected behavior. As a result, the internal time used by \advtrains{} is not synchronized to real-life time due to lag and server restarts. Railway time was therefore introduced as a method of accurately measuring internal time, as well as to provide a scheduling system. It can, however, be set up to keep in sync with real-life time, depending on the real-life time adaptation mode (\texttt{advtrains\_lines\_rwt\_realtime}):
-\begin{ttdescription}
-\item[independent] Do not adapt to real-life time and instead keep in sync with \advtrains{}' internal dtime.
-\item[follow\_real] Independent of real-life time, but counts up in real-life time.
-\item[adapt\_real] Use \texttt{os.time} for RWT.
-\end{ttdescription}
+\begin{apidoc}
+\item \apienum{independent} Do not adapt to real-life time and instead keep in sync with \advtrains{}' internal dtime.
+\item \apienum{follow\_real} Independent of real-life time, but counts up in real-life time.
+\item \apienum{adapt\_real} Use \texttt{os.time} for RWT.
+\end{apidoc}
Railway time is counted in cycles, minutes, and seconds, roughly corresponding to their real-life counterparts, with cycles roughly corresponding to hours.
@@ -1083,23 +1099,23 @@ Railway time can be represented in three formats:
\item As a number: the number of seconds since \texttt{0;0;0}.
\end{itemize}
-The following entries are present in \texttt{advtrains.interlocking.rwt}. \argname{Time}, \argname{t}, \argname{interval}, and \argname{offset} refer to a railway time object represented in one of the methods described above. \argname{Interval} and \argname{offset} represent the interval and offset of a repetition, respectively. \argname{Cycles}, \argname{minutes}, and \argname{seconds} should be the value of the \texttt{c}, \texttt{m} and \texttt{s} fields of a railway time table.
-
-\begin{ttdescription}
-\item[add(\vari{t},\varii{t})] Returns the sum of \vari{t} and \varii{t}.
-\item[copy(\var{time})] Returns a copy of \var{time}.
-\item[diff(\vari{t},\varii{t})] Subtracts \vari{t} from \varii{t} and returns the result in seconds.
-\item[last\_rpt(\argname{time},\argname{interval},\argname{offset})] Returns the last occurrence of the repetition before or at \argname{time}.
-\item[new(\argname{cycles},\argname{minutes},\argname{seconds})] Returns a railway time table.
-\item[next\_rpt(\argname{time},\argname{interval},\argname{offset})] Returns the next occurrence of the repetition at or after \argname{time}.
-\item[now()] Returns a table corresponding to the current railway time.
-\item[sub(\vari{t},\varii{t})] Subtracts \varii{t} from \vari{t} and returns the result in seconds.
-\item[time\_from\_last\_rpt(\argname{time},\argname{interval},\argname{offset})] Returns the number of seconds from the last occurrence of the repetition before or at \argname{time} to \argname{time}.
-\item[time\_to\_next\_rpt(\argname{time},\argname{interval},\argname{offset})] Returns the number of seconds from \argname{time} to the next occurrence of the repetition at or after \argname{time}.
-\item[to\_table(\argname{time})] Returns a railway time table corresponding to \argname{time}.
-\item[to\_secs(\argname{time},\optargname{cycles})] Returns the railway time in number representation corresponding to \argname{time}. \argname{Cycles} is used as the number of cycles, if present.
-\item[to\_string(\argname{time}, \optargname{no cycle})] Returns a railway time string corresponding to \argname{time}. If \argname{no cycle} is true, the number of cycles is omitted from the return value.
-\end{ttdescription}
+The following entries are present in \texttt{advtrains.interlocking.rwt}. \var{Time}, \var{t}, \var{interval}, and \var{offset} refer to a railway time object represented in one of the methods described above. \var{Interval} and \var{offset} represent the interval and offset of a repetition, respectively. \var{Cycles}, \var{minutes}, and \var{seconds} should be the value of the \texttt{c}, \texttt{m} and \texttt{s} fields of a railway time table.
+
+\begin{apidoc}
+\item \apifunc{add(\vari{t},\varii{t})} Returns the sum of \vari{t} and \varii{t}.
+\item \apifunc{copy(\var{time})} Returns a copy of \var{time}.
+\item \apifunc{diff(\vari{t},\varii{t})} Subtracts \vari{t} from \varii{t} and returns the result in seconds.
+\item \apifunc{last\_rpt(\var{time},\var{interval},\var{offset})} Returns the last occurrence of the repetition before or at \var{time}.
+\item \apifunc{new(\var{cycles},\var{minutes},\var{seconds})} Returns a railway time table.
+\item \apifunc{next\_rpt(\var{time},\var{interval},\var{offset})} Returns the next occurrence of the repetition at or after \var{time}.
+\item \apifunc{now()} Returns a table corresponding to the current railway time.
+\item \apifunc{sub(\vari{t},\varii{t})} Subtracts \varii{t} from \vari{t} and returns the result in seconds.
+\item \apifunc{time\_from\_last\_rpt(\var{time},\var{interval},\var{offset})} Returns the number of seconds from the last occurrence of the repetition before or at \var{time} to \var{time}.
+\item \apifunc{time\_to\_next\_rpt(\var{time},\var{interval},\var{offset})} Returns the number of seconds from \var{time} to the next occurrence of the repetition at or after \var{time}.
+\item \apifunc{to\_table(\var{time})} Returns a railway time table corresponding to \var{time}.
+\item \apifunc{to\_secs(\var{time},\ovar{cycles})} Returns the railway time in number representation corresponding to \var{time}. \var{Cycles} is used as the number of cycles, if present.
+\item \apifunc{to\_string(\var{time}, \ovar{no cycle})} Returns a railway time string corresponding to \var{time}. If \var{no cycle} is true, the number of cycles is omitted from the return value.
+\end{apidoc}
\subsection{\texttt{advtrains.speed}}\label{s:tspeed}
The \texttt{speed} library allows comparison of speed limits, which can be represented with:
@@ -1112,23 +1128,23 @@ Note that the meaning of \luanil{} here differ from the meaning used in signal a
The following functions are available as indices of \texttt{advtrains.speed}:
-\begin{ttdescription}
-\item[lessp(\argname{a},\argname{b})] True if \argname{a} is more strict than \argname{b}.
-\item[greaterp(\argname{a},\argname{b})] True if \argname{a} is less strict than \argname{b}.
-\item[equalp(\argname{a},\argname{b})] True if \argname{a} is the same speed limit as \argname{b}.
-\item[not\_lessp(\argname{a},\argname{b})] True if \argname{a} is not more strict than \argname{b}.
-\item[not\_greaterp(\argname{a},\argname{b})] True if \argname{a} is not less strict than \argname{b}.
-\item[not\_equalp(\argname{a},\argname{b})] True if \argname{a} and \argname{b} are different speed limits.
-\item[min(\argname{a},\argname{b})] Returns the strictest limit of \argname{a} and \argname{b}.
-\item[max(\argname{a},\argname{b})] Returns the less strict limit of \argname{a} and \argname{b}.
-\end{ttdescription}
+\begin{apidoc}
+\item \apifunc{lessp(\var{a},\var{b})} Returns a boolean indicating whether \var{a} is more strict than \var{b}.
+\item \apifunc{greaterp(\var{a},\var{b})} Returns a boolean indicating whether \var{a} is less strict than \var{b}.
+\item \apifunc{equalp(\var{a},\var{b})} Returns a boolean indicating whether \var{a} is the same speed limit as \var{b}.
+\item \apifunc{not\_lessp(\var{a},\var{b})} Returns a boolean indicating whether \var{a} is not more strict than \var{b}.
+\item \apifunc{not\_greaterp(\var{a},\var{b})} Returns a boolean indicating whether \var{a} is not less strict than \var{b}.
+\item \apifunc{not\_equalp(\var{a},\var{b})} Returns a boolean indicating whether \var{a} and \var{b} are different speed limits.
+\item \apifunc{min(\var{a},\var{b})} Returns the strictest limit of \var{a} and \var{b}.
+\item \apifunc{max(\var{a},\var{b})} Returns the less strict limit of \var{a} and \var{b}.
+\end{apidoc}
For convenience, this manual refers to the functions above as \texttt{speed<}, \texttt{speed>}, \texttt{speed=}, \texttt{speed>=}, \texttt{speed<=}, \texttt{speed/=}, \texttt{speed-min}, and \texttt{speed-max}, respectively. These names are not available in the \texttt{advtrains} table.
-\begin{ttdescription}
-\item[set\_restriction(\argname{train},\argname{type},\argname{val})] Set speed restriction of type \argname{type} of \argname{train} to \argname{val} and update the \texttt{speed\_restriction} field of \argname{train} accordingly. \argname{Type} defaults to \texttt{main}.
-\item[merge\_aspect(\argname{train},\argname{asp})] Merge the signal aspect \argname{asp} into the speed restriction table of \argname{train} and update the \texttt{speed\_restriction} field of \argname{train} accordingly.
-\end{ttdescription}
+\begin{apidoc}
+\item \apifunc{set\_restriction(\var{train},\var{type},\var{val})} Set speed restriction of type \var{type} of \var{train} to \var{val} and update the \texttt{speed\_restriction} field of \var{train} accordingly. \var{Type} defaults to \texttt{main}.
+\item \apifunc{merge\_aspect(\var{train},\var{asp})} Merge the signal aspect \var{asp} into the speed restriction table of \var{train} and update the \texttt{speed\_restriction} field of \var{train} accordingly.
+\end{apidoc}
\section{Definition tables}\label{s:deftables}
@@ -1138,13 +1154,13 @@ This section only documents table structures shared among multiple modules. API-
\subsection{Signal aspect table}\label{s:sigasp}
Signal aspect tables may contain the following members:
-\begin{ttdescription}
-\item[main] The aspect of the main signal.
-\item[type] The type of signal. Please refer to section \ref{s:srtypes} for more information.
-\item[dst] The aspect of the next main signal.
-\item[shunt] Whether shunting is allowed.
-\item[proceed\_as\_main] When shunting is not allowed, whether to let the train continue with shunt mode disabled.
-\end{ttdescription}
+\begin{apidoc}
+\item \apifield{main} The aspect of the main signal.
+\item \apifield{type} The type of signal. Please refer to section \ref{s:srtypes} for more information.
+\item \apifield{dst} The aspect of the next main signal.
+\item \apifield{shunt} Whether shunting is allowed.
+\item \apifield{proceed\_as\_main} When shunting is not allowed, whether to let the train continue with shunt mode disabled.
+\end{apidoc}
The \texttt{main} and \texttt{dst} fields may contain one of the following:
\begin{itemize}