[Mod] Advanced Trains [advtrains] [2.2.1]

User avatar
Blockhead
Member
Posts: 66
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
In-game: Blockhead
Location: Land Down Under

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

by Blockhead » Post

Lol1234 wrote:
Wed Jan 27, 2021 04:16
Hi.

How can use dtrack_atc_st to drive to right with a train by the dtrack_sy_l?

Thanks
That is not possible. ATC only controls trains, not tracks. Your options to change a turnout are
  • The detector rail, which uses mesecons. Not recommended, does not work for trains in unloaded areas.
  • Interlocking - see my video.
  • LuaATC: an advanced topic, see the wiki pages. You want to create an environment with the commands, name the turnout with the passive component naming tool and then add LuaATC tracks with calls to setstate(<pos>, <state>)). States are: y-turnout: l, r ; normal turnout: cr, st.

Bug report: It is possible to assign two TCBs to the same spot.

Code: Select all

Configuring TCB: Please punch the rail you want to assign this TCB to.
Configuring TCB: TCB already exists at this position! It has now been re-assigned
Configuring TCB: Successfully configured TCB
Afterwards, both TCBs show the same info in their formspecs. If I create sections on either one, it shows in either formspec. Any claim of "re-assignment" is false. Unless this is not a bug, like maybe you could make signal boxes like this as well as trackside equipment? No, probably not, doesn't sound well-thought-out.

User avatar
mbb
Member
Posts: 253
Joined: Sat Jan 17, 2015 17:47
GitHub: mbblp
IRC: mBb
In-game: MBB
Location: in front of my pc
Contact:

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

by mbb » Post

uh, nice things happened here:)
If you want to contact me please send me a twitter pm https://twitter.com/mbbdev

W3RQ01
Member
Posts: 17
Joined: Sat Nov 28, 2020 06:33

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

by W3RQ01 » Post

mbb wrote:
Fri Feb 12, 2021 22:35
uh, nice things happened here:)
Wb mbb!
A question: where i can download the steam locomotive that i saw on page 3?

hlqkj
Member
Posts: 24
Joined: Wed Dec 11, 2019 20:10
GitHub: hlqkj
IRC: hlqkj
In-game: hlqkj

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

by hlqkj » Post

Hello, what's your thought and/or feasibility of having a simplified hud displayed to passengers too?

My first concern was for players boarding at terminal stations, where I have the trains standing for a few minutes: they need a way to see the departure count down in my opinion, as already seen by the driver. I tried to have something similar shown on an LCD near the platform, using LUA rails and interrupts, but its laggy and not so precise.

In addition, an hud displaying velocity during the journey wouldn't be too bad either! Perhaps an option could be to replicate the driver's hud but with all the ATC stuff stripped? What do you think?
Quando omni flunkus, moritati.

W3RQ01
Member
Posts: 17
Joined: Sat Nov 28, 2020 06:33

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

by W3RQ01 » Post

hlqkj wrote:
Sat Feb 20, 2021 23:03
Hello, what's your thought and/or feasibility of having a simplified hud displayed to passengers too?

My first concern was for players boarding at terminal stations, where I have the trains standing for a few minutes: they need a way to see the departure count down in my opinion, as already seen by the driver. I tried to have something similar shown on an LCD near the platform, using LUA rails and interrupts, but its laggy and not so precise.

In addition, an hud displaying velocity during the journey wouldn't be too bad either! Perhaps an option could be to replicate the driver's hud but with all the ATC stuff stripped? What do you think?
My advice is to talk at ywang, he made the trainhud.

hlqkj
Member
Posts: 24
Joined: Wed Dec 11, 2019 20:10
GitHub: hlqkj
IRC: hlqkj
In-game: hlqkj

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

by hlqkj » Post

Hello, we just upgraded advtrains --EDIT: we were on commit 48787fc1 (that is release-2.1.4 plus the 69/90 connection fix) and now pulled the latest available db9e4429-- on a server and having some issues, I'd like to ask some help to understand what is not working correctly before posting a bug report, if appropriate.

After the upgrade, all the "normal" signals (i mean simple red/green, non Ks: pole signals and wallmounted signals) doesn't seem to clear the train to full speed anymore on green. Is that the wanted behaviour? If so, this is a breaking thing because we relied on this feature to clear the trains speed limit after station sidings (we limit them to 6 before entering the siding).

Also, all the routes regarding those signals shows the wrong setting when I edit the route and click "Show Aspect" in the signal formspec. The signal shows "1| Halt" where it was (and correctly operates) as green. I notice that in the dropdown menu, the text now specifies that green doesn't clear the speed anymore.

It would be a - very - great mess (but still feasible) if we have to re-configure the signal aspects for all of our routes, but if it turns out that we have to replace all of our signals with Ks to have the speed cleared, we would have to consider to roll back and stuck on the old version, which I really don't want to.

A solution could be to add a 3rd option to the normal signal aspect drop down like - "3| Continue with no speed limit" and default to that during the migration from old data? Or I'm open to suggestions :)

Thanks for any help you could give...
Last edited by hlqkj on Wed Feb 24, 2021 14:04, edited 2 times in total.
Quando omni flunkus, moritati.

hlqkj
Member
Posts: 24
Joined: Wed Dec 11, 2019 20:10
GitHub: hlqkj
IRC: hlqkj
In-game: hlqkj

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

by hlqkj » Post

Looking better into the history, I noticed this: https://git.bananach.space/advtrains.gi ... b099f47f10 - Simplify Signal Aspect Table (H#132) [breaks compatibility with signal API]

Seems then that some breakage with backwards compatibility is intended, talking about the "green" aspect not altering the speed limit. However, all of those signals still shows the wrong setting in the route formspec... So I ask: will the next release include some code to address one or both of these issues? If so I would just checkout the current stable release-2.2.1 now and wait for the next one...
Quando omni flunkus, moritati.

User avatar
Blockhead
Member
Posts: 66
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
In-game: Blockhead
Location: Land Down Under

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

by Blockhead » Post

hlqkj wrote:
Sat Feb 20, 2021 23:03
Hello, what's your thought and/or feasibility of having a simplified hud displayed to passengers too?
The station/stop rail could add extra functionality to update passengers on the departure time.

Another option that already works would be to use the railwaytime functionality, which is regrettably basically undocumented at this stage. For those who know Lua, functions defined in advtrains/advtrains_line_automation/railwaytime.lua are available under rwt.* in LuaATC. e.g. digiline_send("lcd", rwt.to_string(rwt.now()))
hlqkj wrote:
Wed Feb 24, 2021 13:57
...breakage with backwards compatibility...
The breakage with backwards compatibility is for signal mod authors really, not end users I think current setups should keep work as they used to. Here is a patch that addresses the change in behaviour with default signals (wallmounted, lampless and frestanding) no longer de-restricting speed.

Code: Select all

From 92980a2dfb07b266815f8c6bf6a5afa6a9b582b7 Mon Sep 17 00:00:00 2001
From: Blockhead
Date: Fri, 26 Feb 2021 20:34:02 +1100
Subject: [PATCH] Restore old behaviour: default signals allow max speed

---
 advtrains/signals.lua | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/advtrains/signals.lua b/advtrains/signals.lua
index 9df2f99..3a3efc4 100644
--- a/advtrains/signals.lua
+++ b/advtrains/signals.lua
@@ -21,7 +21,7 @@ return {
 end
 
 local suppasp = {
-		main = {0, false},
+		main = {0, -1},
 		dst = {false},
 		shunt = nil,
 		proceed_as_main = true,
@@ -32,6 +32,14 @@ local suppasp = {
 		}
 }
 
+local function gen_get_aspect(r)
+	return function(pos,node)
+		return (aspect(r=="on")
+			and {main=-1, proceed_as_main = true})
+			or {main=0}
+	end
+end
+
 for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", als="green"}}) do
 
 	advtrains.trackplacer.register_tracktype("advtrains:retrosignal", "")
@@ -91,9 +99,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
 						advtrains.ndb.swap_node(pos, {name = "advtrains:retrosignal_off"..rotation, param2 = node.param2}, true)
 					end
 				end,
-				get_aspect = function(pos, node)
-					return aspect(r=="on")
-				end,
+				get_aspect = gen_get_aspect(r),
 				supported_aspects = suppasp,
 			},
 			can_dig = can_dig_func,
@@ -139,7 +145,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
 					advtrains.interlocking.show_ip_form(pos, pname)
 				elseif advtrains.check_turnout_signal_protection(pos, player:get_player_name()) then
 					advtrains.setstate(pos, f.als, node)
-					advtrains.interlocking.signal_on_aspect_changed(pos)
+					if advtrains.interlocking then
+						advtrains.interlocking.signal_on_aspect_changed(pos)
+					end
 				end
 			end,
 			-- new signal API
@@ -151,9 +159,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
 						advtrains.ndb.swap_node(pos, {name = "advtrains:signal_off"..rotation, param2 = node.param2}, true)
 					end
 				end,
-				get_aspect = function(pos, node)
-					return aspect(r=="on")
-				end,
+				get_aspect = gen_get_aspect(r),
 				supported_aspects = suppasp,
 				getstate = f.ls,
 				setstate = function(pos, node, newstate)
@@ -220,9 +226,7 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red",
 						advtrains.ndb.swap_node(pos, {name = "advtrains:signal_wall_"..loc.."_off", param2 = node.param2}, true)
 					end
 				end,
-				get_aspect = function(pos, node)
-					return aspect(r=="on")
-				end,
+				get_aspect = gen_get_aspect(r),
 				supported_aspects = suppasp,
 				getstate = f.ls,
 				setstate = function(pos, node, newstate)
-- 
2.30.1.windows.1

drixi
New member
Posts: 4
Joined: Sat Feb 27, 2021 08:58

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

by drixi » Post

Hello,
Is it possible to send ATC commands to trains without them passing through an ATC controller or an ATC rail? while knowing the train ID.

what I would like is that by typing a Lua block, the train of ID X stops or starts according to the ATC command I send to it
(another question, how do you get the ID of a train?)

yw05
Member
Posts: 121
Joined: Tue May 07, 2019 12:59
IRC: yw05
In-game: ywang

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

by yw05 » Post

drixi wrote:
Sat Feb 27, 2021 09:11
Hello,
Is it possible to send ATC commands to trains without them passing through an ATC controller or an ATC rail? while knowing the train ID.

what I would like is that by typing a Lua block, the train of ID X stops or starts according to the ATC command I send to it
Yes, you can use advtrains.atc.train_set_command, but you need to pass it:
  • The train object,
  • The command to send to the train, and
  • Whether the train is driving in the same direction as the (imaginary, in your case) ATC track (used for the I+ conditions)
drixi wrote:
Sat Feb 27, 2021 09:11
(another question, how do you get the ID of a train?)
The easiest way I can think of is to let it pass through a LuaATC track and let it print the train ID (atc_id).

yw05
Member
Posts: 121
Joined: Tue May 07, 2019 12:59
IRC: yw05
In-game: ywang

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

by yw05 » Post

hlqkj wrote:
Sat Feb 20, 2021 23:03
Hello, what's your thought and/or feasibility of having a simplified hud displayed to passengers too?

My first concern was for players boarding at terminal stations, where I have the trains standing for a few minutes: they need a way to see the departure count down in my opinion, as already seen by the driver. I tried to have something similar shown on an LCD near the platform, using LUA rails and interrupts, but its laggy and not so precise.
I did not touch the passenger HUD code, but (as far as I know) it only shows the indoor display. I have heard of some players who want to integrate a PIS system to advtrains, but currently using LCDs or textline with the departure time is probably the best you can do for now, and there is the scheduling system for that. You would need to (ask the admin to, if you aren't the admin) change the RWT setting to sync or catch up with RL time though.
As for the graphical HUD for passengers, I would consider implementing it in advtrains itself instead of in LuaATC, as it would make things easier to handle (e.g. ATC delays, wagon number).
hlqkj wrote:
Sat Feb 20, 2021 23:03
In addition, an hud displaying velocity during the journey wouldn't be too bad either! Perhaps an option could be to replicate the driver's hud but with all the ATC stuff stripped? What do you think?
I have seen speed indicators for passengers on RL buses and trains, so I think it could be possible to include it. However, I am currently still working on the driver HUD, so that has to wait a bit.
W3RQ01 wrote:
Mon Feb 22, 2021 12:06
My advice is to talk at ywang, he made the trainhud.
I only worked on improvements to the driver HUD.

Update: I think the driver HUD is more or less stable now.
Last edited by yw05 on Sat Feb 27, 2021 18:39, edited 1 time in total.

hlqkj
Member
Posts: 24
Joined: Wed Dec 11, 2019 20:10
GitHub: hlqkj
IRC: hlqkj
In-game: hlqkj

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

by hlqkj » Post

Hi, thank you all for your replies, I really appreciate.
Blockhead wrote:
Fri Feb 26, 2021 15:28
The breakage with backwards compatibility is for signal mod authors really, not end users I think current setups should keep work as they used to. Here is a patch that addresses the change in behaviour with default signals (wallmounted, lampless and frestanding) no longer de-restricting speed.
Good to hear, however, in some way it did because of the default signals behaviour with speed limits. I thank you so much for your patch but I'd rather find another way to fix this, like updating/changing our setup in some way that doesn't require me to re-do all the routes: I don't want to break updatability in the future by patching the code.

Also, remember to have a look at the formspec showing the wrong signal aspect configuration in routes. It's a very minor issue but it may lead to some headache if one doesn't realize it...

I know and have been using the RWT API before, but failed to realize how to use it to show the departure time and/or a countdown in an efficient way. What I tried is to grab the train arrival event with a LUA track, and use this info with the schedule_in() to show a countdown on an LCD: is that what you mean?
Quando omni flunkus, moritati.

drixi
New member
Posts: 4
Joined: Sat Feb 27, 2021 08:58

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

by drixi » Post

yw05 wrote:
Sat Feb 27, 2021 10:45
drixi wrote:
Sat Feb 27, 2021 09:11
Hello,
Is it possible to send ATC commands to trains without them passing through an ATC controller or an ATC rail? while knowing the train ID.

what I would like is that by typing a Lua block, the train of ID X stops or starts according to the ATC command I send to it
Yes, you can use advtrains.atc.train_set_command, but you need to pass it:
  • The train object,
  • The command to send to the train, and
  • Whether the train is driving in the same direction as the (imaginary, in your case) ATC track (used for the I+ conditions)
drixi wrote:
Sat Feb 27, 2021 09:11
(another question, how do you get the ID of a train?)
The easiest way I can think of is to let it pass through a LuaATC track and let it print the train ID (atc_id).
I was able to retrieve the train ID,
however I can't send the command to the train
error message: "attempt to index global 'advtrains' (a nil value)"
I put the following command
advtrains.atc.train_set_command(426939, "S0",true)

yw05
Member
Posts: 121
Joined: Tue May 07, 2019 12:59
IRC: yw05
In-game: ywang

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

by yw05 » Post

drixi wrote:
Sat Feb 27, 2021 16:17
I was able to retrieve the train ID,
however I can't send the command to the train
error message: "attempt to index global 'advtrains' (a nil value)"
I put the following command
advtrains.atc.train_set_command(426939, "S0",true)
Three problems:
  • Train IDs are strings, not numbers (although they do look like numbers)
  • The first argument to advtrains.atc.train_set_command() should be the train table itself (i.e. advtrains.trains[id])
  • It appears to me that advtrains is not in the global environment you ran the code in. The advtrains.* table is (as far as I know) not available in luacontrollers or LuaATC blocks.

User avatar
orwell
Member
Posts: 866
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

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

by orwell » Post

drixi:
Sending ATC command to any train anywhere is currently not possible from LuaATC, however it has already been requested on http://bugs.linux-forks.de/advtrains . It wouldn't be very difficult to implement though. I might add it before the next release.
As for retrieving the train ID: one way would be to just print(atc_id) from a LuaATC rail. Or enable the advtrains_show_ids setting, then it's displayed when pointing at the train. ("T:")

hlqkj:
When I changed this behavior of the non-Ks signal, I didn't imagine that it would have such a high impact. My idea behind it was that speed restrictions and clear/blocked should be handled separately by all of the "standard" signals.
As you appear to rely on that behavior, it's probably simplest to just apply Blockhead's fix.
Another possibility would be to place "E" signs to lift the speed restriction.
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
Blockhead
Member
Posts: 66
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
In-game: Blockhead
Location: Land Down Under

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

by Blockhead » Post

hlqkj wrote:
Sat Feb 27, 2021 14:20
What I tried is to grab the train arrival event with a LUA track, and use this info with the schedule_in() to show a countdown on an LCD: is that what you mean?
Yes that is what I meant. It's true this isn't clear enough to passengers on board the train :(. Well, if you wanted the information on board the train you could fire interrupts from LuaATC each second and update the train's internal text display, but it would be less efficient for sure and possibly less safe. interrupt_safe should work in this case.
hlqkj wrote:
Sat Feb 27, 2021 14:20
I don't want to break updatability in the future by patching the code.
That's a good point. I recommend for now that you take orwell's advice and move to using E speed signs ("End" speed restriction) after all your signals. This won't require changing any routes.

If you really would prefer a set of signals that de-restrict speed, what you could do is make your own mod that provides the signals like the default ones but with my patch applied on them. If you take that route I'd modify them so they are visually distinct, with textures if it's possible - UV maps don't always make it so :(. I'm pretty sure (not 100% though) that changing to this new signal type would also not require you to change routes - just un-assign the signal, replace and re-assign and hopefully it works.

drixi
New member
Posts: 4
Joined: Sat Feb 27, 2021 08:58

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

by drixi » Post

yw05 wrote:
Sat Feb 27, 2021 18:44
Three problems:
  • Train IDs are strings, not numbers (although they do look like numbers)
  • The first argument to advtrains.atc.train_set_command() should be the train table itself (i.e. advtrains.trains[id])
  • It appears to me that advtrains is not in the global environment you ran the code in. The advtrains.* table is (as far as I know) not available in luacontrollers or LuaATC blocks.
ok thanks, I see

your second remark is a bit awkward, is that what you want me to do?
"advtrains.atc.train_set_command(advtrains.trains112233,"S0",true) "

well, after even if the command is good I couldn't execute it from the luacontrollers. Thanks for your help

drixi
New member
Posts: 4
Joined: Sat Feb 27, 2021 08:58

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

by drixi » Post

orwell wrote:
Sat Feb 27, 2021 21:37
drixi:
Sending ATC command to any train anywhere is currently not possible from LuaATC, however it has already been requested on http://bugs.linux-forks.de/advtrains . It wouldn't be very difficult to implement though. I might add it before the next release.
As for retrieving the train ID: one way would be to just print(atc_id) from a LuaATC rail. Or enable the advtrains_show_ids setting, then it's displayed when pointing at the train. ("T:")
ok, thanks I'll wait for the update then

hlqkj
Member
Posts: 24
Joined: Wed Dec 11, 2019 20:10
GitHub: hlqkj
IRC: hlqkj
In-game: hlqkj

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

by hlqkj » Post

Blockhead wrote:
Sun Feb 28, 2021 02:29
Yes that is what I meant. It's true this isn't clear enough to passengers on board the train :(. Well, if you wanted the information on board the train you could fire interrupts from LuaATC each second and update the train's internal text display, but it would be less efficient for sure and possibly less safe. interrupt_safe should work in this case.
Uhm... Guess I was on the right track then! :D I didn't think of showing the departure time though, will try that. Would surely be better that fire an interrupt each and every second, for every train in every platform! LOL
Blockhead wrote:
Sun Feb 28, 2021 02:29
That's a good point. I recommend for now that you take orwell's advice and move to using E speed signs ("End" speed restriction) after all your signals. This won't require changing any routes.
This is what I was thinking to do. But... (sorry for the long post, again... please don't hate me LOL)

From orwell's kind reply I am realizing that perhaps I may be doing things the wrong way by principle, in this case it's worth to fix my design flaw. For this I'd like ask your opinion on how to handle my layout, and any advice is welcome!
Besides, forgive me if I still haven't said the server name, that's because I'm not sure if it's allowed/appropriate here? Don't want to do unwanted advertising...

On a train line, I made intermediate stations as sidings from the main line, in other words, the line itself goes straight from end to end and each station along it is a siding track which merges back into the main one after the station. I liked the possibility of using the "line code" to make two services available on the line, that is a regular one that does all the stops and an express one, which only stops at major stations.

To do that, before each station there's a switch along with a Ks signal, with two routes: "straight" and "station". To make things more realistic I thought that trains passing straight (express service) should be left at maximum speed whereas trains entering the station should be slowed down, before taking the switch (cr). For this speed limit I used Ks aspects, that is trains entering the station gets a "yellow" aspect. The issue comes here, because I decided that wall-mounted signals were better-looking (Doh!) in the stations so trains are now leaving those stations with speed limited.

So, is this the correct way to handle the case, I mean to slow down the trains? Initially I wanted to use speed limit signals, but they are static and can't be made part of a route (I want to slow down only trains that will enter the siding).

If this is the correct way (yellow-aspect Ks) I'd rather try to replace all wall-mounted signals with Ks'es. On the contrary, if speed should be totally separated from signals, I'd instead place speed-limit signals all around and stop using the Ks yellow aspect too.

Thanks and sorry again for the post length...
Quando omni flunkus, moritati.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests