Page 46 of 51

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Wed Dec 12, 2018 17:11
by h-v-smacker
orwell wrote:To add-on/extension developers:
Code: Select all
   get_inventory_formspec = function(self, pname, invname)
      return "size[8,11]"..

What is pname for?

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Wed Dec 12, 2018 17:59
by Stix
h-v-smacker wrote:
orwell wrote:To add-on/extension developers:
Code: Select all
   get_inventory_formspec = function(self, pname, invname)
      return "size[8,11]"..

What is pname for?

It most likely refers to playername, as it needs to find the name of the player who did (im guessing) a specified action so it can then send the proper inventory formspec to the client.

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Wed Dec 12, 2018 18:21
by h-v-smacker
> It most likely refers to playername, as it needs to find the name of the player who did (im guessing) a specified action so it can then send the proper inventory formspec to the client.

This parameter is not used in the function.

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Wed Dec 12, 2018 18:32
by Stix
hmm, seems to me that the code uses the pname parameter of the function to find current_player.

Then again i cant really code anything yet, just make sense out of code i see, so i could be wrong.

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Thu Dec 13, 2018 12:32
by orwell
Yes, pname refers to the player name, and no, it is not used in the function.
But since pname has always been the (documented) second parameter, although never used, I didnt want to break things and just appended the "invname" as the third parameter
Current_player is automatically "found" by minetest

Re: The ominous TSS branch and the interlocking system

PostPosted: Thu Dec 20, 2018 07:33
by pheonixfire
orwell wrote:The ominous TSS branch and the interlocking system
Hello people,

I post this to clean the confusion over terms like "tss branch" and "interlocking system":

About half a year ago, I started reimplementing large parts of some internal logic of advtrains. The version control system (git) allows to create separate branches that do not affect the "stable" main version ("master branch") and can be independently developed. Back then, I created such a branch, named "tss" (short for "track section signalling", see after)
That rewrite was done some months ago, and I started with the original goal of the whole operation, which was implementing an interlocking system (search the internet for what that is, or see on top of this new "tss branch". But I didn't want to "merge" my rewrite back into the stable "master" branch because it was possible that there were bugs I was unaware of, and wanted it to prove working. On the "master" branch, only important bugfixes were still made.

The interlocking system has progressed pretty far in the last months, and during this time it seems like I've eliminated all critical bugs in the core logic that have shown up. Therefore, I will declare the "tss" stable and make it the new "master" branch somewhen around the new year.

However, you can already do this step now if you don't want to wait. But before "upgrade" advtrains to "tss", I recommend you to make a backup of all worlds you use advtrains in and don't wish to be broken, because:
1. Once you switch to "tss", you cannot go back*
2. It might be possible that some things get lost or even the whole world gets corrupt during the upgrade.
3. I should note that the "add-on" mods that are linked in the main post are probably not compatible to TSS

To do this, follow these steps:
If you've installed using git:
1. back up your world(s)
2. $ git checkout tss
If not:
1. back up your world(s)
2. delete old "advtrains" folder
4. Select top entry in list
5. select one of the download formats
6. save, unpack, as you would install any other modpack.

Please report any bugs, inconveniences, data losses or weird behaviors you encounter at (or here)! You will be helping me a lot.

Small note in between: the difference between "safety" and "security"
Safety means a system is secured against failure caused by itself or some component inside the system (for a railway, this would be the tracks, vehicles and the train driver)
Security means a system is secured against external disturbances, components outside of the system (for our mod, this would be malicious players randomly decoupling wagons or throwing sand onto tracks)

What follows is an incomplete list of the most important changes that happened in "tss":
- Completely rewritten path logic:
-- inofficial internal "API" for path update callbacks
-- reverse lookup of positions to train path indices
-> This simplified a lot of code and probably eliminated some minor bugs that existed before, especially the buggy coupling behavior

- Fix yaw/looking direction behavior
-> Trains now finally appear in the direction they were placed

- Reworked security
-> Things now actually work
-> There are no longer "couple locks" because this only confused players.

- Track sections
-> Trains can occupy certain track sections, which can be used in combination with the latter features

- Signals and "LZB"
-- There are some new signals and a unified API for "signal aspects" (things that a signal tells to a train driver)
-- By setting an "Influence Point", the obeyance of those aspects is enforced automatically using a system similar to ETCS, LZB and the like (but without technical equipment, because the whole mod is a simulation and all parameters are known at any time)

- Train (and shunt) routes
-- Trains can be guided along secured paths to prevent collisions or accidents, where all turnouts are locked and cannot be reversed

- Speed restrictions
-- Both signals and special signs can set up speed restrictions for trains
-> all of them work using the Signal API and the aforementioned "Influence Points"

If I forgot something you've noticed, tell me.
I look forward to hear feedback from you.
- orwell

* There is a possibility to downgrade, but this might still result in data loss or might not work at all:
1. revert back to "master" (don't start world)
2. go into world directory, open the file "advtrains" with a text editor
3. Using the "Find" function (Ctrl-F), locate "version"
4. change value there to 1
5. save file, close, start world.

to download the tss branch, am I supposed to put the address in step 3 of the if not instructions into a browser?
if so I can't find the list described in steps 4 and 5

any help is appreciated

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Thu Dec 20, 2018 10:25
by orwell

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Thu Dec 20, 2018 10:41
by orwell
Dan2018 wrote:Just trying out AT on the server. Few questions

On startup we get the message
"Undeclared global variable "id" accessed at ..\advtrains\advtrains\trainlogic.lua:111"

Also normal users dont seem to be able to attach wagons. Given train_operator but they dont attach.

Is there a train_admin priv now? Read in documentation but doesnt seem to exist.

Is there away to stop people loosing their stuff when hit by a train? Have the server setup to keep their items but with trains they loose it all.

Running minetest 0.4.17


Oh, seems like I overlooked your post
1. What version? Can't find mentioned line
2. The wagons they want to couple must be owned by them or whitelisted (wagon properties)
3. Privilege_guide.txt line 15
4. No, not directly. Tell me which advtrains version you are using, so I can tell you which code to change.

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Mon Dec 24, 2018 20:19
by gpcf is currently down. If it does not come up by itself, I will start migrating it to a new server, since the server it is currently on is quite unreliable.

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Wed Dec 26, 2018 15:02
by BuckarooBanzay
Hi there

I wanted to test some automation in the new tss branch.
The gui/objects to compose a route are fantastic :)
I added 4 route segments in my test track. Each with a circuit breaker and signal.
For each segment i made a single route (i hope thats correct).
For the station halt and return on the end i added atc-tracks:

Station halt:
Code: Select all
B0 W OL D5 OC S4

Station halt and return:
Code: Select all
B0 W OL D5 OC R S4

That works quite well for a single train.
After i place another train the following messages appear and the routes get cancelled:
Code: Select all
Train xxx hit route Route 'yyy' from Signal at (x,y,z), semgment #1 !
Route was cancelled.

Am i doing something wrong there??

Overall track:

This is the return route config:

(456.55 KiB) Not downloaded yet

(429.65 KiB) Not downloaded yet

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Thu Dec 27, 2018 21:01
by orwell
The message "train x hit route y" appears when a route is set into a section and suddenly a train not supposed for it suddenly occupies the section (either when it is placed into such a section or it enters the section from a "wrong" TCB.
One thing I noticed is that your layout does not obey a design principle of real-world railways that I implicitly assumed: Routes should not involve changes of the driving direction. This means that after each supposed driving direction change, there should be a signal in the opposite direction from which a new route can be set. The route for the movement up to the reversing location needs to be set as usual: from a signal to the next signal in the same direction.
see also ... erse_train under "Reversing examples"

Also, your layout requires that the train drives on the turnout from the wrong side, which is bad practice.I recommend a layout like this:
Code: Select all
p: left-facing signal, signalling trains coming from the left
q: the opposite
|: TCB without signal

Then, the 2 inner signals lock the turnout straight, and the outer 2 signals lock it reverse (curve)
You need the extra TCBs so another train can enter the terminal section once one has cleared the turnout. Note that the routes of the outer signals have to be programmed over 2 track sections then.

Another question: Have you set the influence points for the signals? If not, automatic trains won't stop at red signals by themself.

A way how you can check whether your interlocking setup works is by trying to set conflicting routes manually. When the system allows it and the signal turns green though it should not (because a section is occupied etc.) you've made a mistake.

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Sat Dec 29, 2018 19:33
by orwell
Since is down, here's the latest TSS branch version:
(this is the newer, unofficial version)

Latest master can be found in the content DB:
(this is the officially supported, but somewhat old version)

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Tue Jan 15, 2019 20:14
by orwell
TSS branch update: ARS (Automatic Routesetting) has been implemented. For explanation see the interlocking manual at

Download TSS ( is still down :( ):

EDIT: Happy new year everyone!

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Tue Jan 15, 2019 20:22
by Mikola
Hooray! New examples and explanations with screenshots! This is what was really needed.

P.S. With past holidays.

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Wed Jan 16, 2019 14:25
by gpcf will be up again soon. @orwell: Please push your mods via ssh to, just the same way as you would do with

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Wed Jan 16, 2019 20:29
by orwell
uh, another server
EDIT: done
EDIT2: cgit does not seem to update

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Thu Jan 17, 2019 16:55
by gpcf
I think the cgit problem should be fixed now, it was a permission problem. I'll see if it returns.

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Sat Jan 19, 2019 15:22
by BuckarooBanzay
Good to see the advtrains repo back online :D
I updated the mod on my server (from the master to the tss branch) and now
i'm getting a bunch of error messages:

(243.44 KiB) Not downloaded yet

What did i do wrong?

Anyways, cool mod and no pressure, this is on a test-copy of the main server :)

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Sun Jan 20, 2019 19:56
by orwell
I guess nothing. Are there any trains missing in your world? Else, you can ignore this.
The message "remove_train failed" should be harmless. However, can you PM me just the file called "advtrains" from the world directory of the pre-update world, so I can check the cause?

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Fri Feb 01, 2019 10:14
by orwell
We have deployed the TSS branch on the LinuxWorks server, which acts as a "public beta" for it. So far, it has proven working and stable. I will officially deprecate the current "master" branch in the next week.

Re: [Mod] Advanced Trains [advtrains] [1.13]

PostPosted: Sun Feb 03, 2019 16:15
by orwell
TSS update - advtrains version 2.0 released!

After over a year of development, I finally announce the official release of what was formerly known as the TSS branch. The old master branch has been deprecated and is further available as "master_old"

If you were using Git to install the "master" branch, delete and re-pull your local repository or rename your local "tss" branch to "master". I renamed the tss branch to "master" and the former "master" branch to "master_old". A merge of both branches was not practical, because they had diverged too much and the things on old master were mostly backported bugfixes.

When you install this update, some trains in your world will probably flip their driving direction and/or "mirror" around one end. This is due to an inevitable change in the save data and will only occur a single time. Also, the brake distance of ATC rails has slightly increased.

I suggest that you make a backup of all advtrains-related files in your world directory before updating.

+ Major changes

I also updated the version in the Content DB and rewrote the main post.

+ Old main post

Re: [Mod] Advanced Trains [advtrains] [2.0 TSS]

PostPosted: Tue Feb 05, 2019 08:01
by h-v-smacker
We found an issue with ATC conditional orders and train's order queue last night.

Suppose you have two ATC tracks looking in different directions (placed close enough though), having conditional orders, and a train approaching:


Each of ATC tracks has some order conditional on the direction of travel, for example "I+ B0W OR D15 OC D1 S16;"

Now in the situation above, the train passes the first ATC track ([>>]), doesn't react, passes to the second, and executes the order. Seemingly everything as it should be. Now imagine the tracks being placed differently (notice the direction of arrows on ATC tracks):


In this case, the train will begin executing the order given by the first ATC track it passes over, the orders will queue to be executed, then it will pass over the next track... and the train's ATC order queue will be purged! In my experiments, it will just roll to stop. Presence of braking order doesn't seem to make an difference, an order of opening and closing doors repeatedly is similarly purged by another such order.

Now, when I see an order like "I+ B0W OR D15 OC D1 S16;" I expect it to mean "If moving in the direction of ATC track, execute this sequence, otherwise perform no action". However, what happens in advanced trains as implemented is "If moving in the direction of ATC track, execute this sequence, otherwise make the train perform no action". So there is an implicit "no operation" passed with such order, as if it was "I+ ... E NOP;"

I don't think this is how it should be. After all, there is a construction with explicit "or else" order set. If a train meets an ATC track with an order which is purely direction-dependent, literally nothing should change for the train.

Re: [Mod] Advanced Trains [advtrains] [2.0 TSS]

PostPosted: Wed Feb 06, 2019 11:02
by orwell
@Smacker: I fixed this problem yesterday. Before "replacing" the train's ATC command, 1 top-level condition is evaluated, and the command is not sent when it would result in an empty command.

Re: [Mod] Advanced Trains [advtrains] [2.0.1 TSS]

PostPosted: Thu Feb 21, 2019 10:31
by orwell
There's now an official Wiki for advtrains, located at
It has to be filled with content. You are invited to contribute!

Re: [Mod] Advanced Trains [advtrains] [2.0.1 TSS]

PostPosted: Sun Feb 24, 2019 19:53
by BuckarooBanzay
Hey there

You might find that useful:

I managed to integrate your trains in my latest mapserver version:

The trains, along with the composition and display text will now be displayed on the map:

(end of shameless self-promotion:)