[Mod] Advanced Trains [advtrains] [2.4.7]

Dmax_05
Member
Posts: 21
Joined: Fri Nov 17, 2023 20:02

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

by Dmax_05 » Post

Mese Train

User avatar
nazalassa
Member
Posts: 45
Joined: Sun May 26, 2024 14:50
In-game: Nazalassa
Contact:

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

by nazalassa » Post

An error happens in Advtrains in the following situation: I have a level crossing between a linetrack road line and a train line. As the train arrives at the crossing, a bus is, well, crossing the tracks. Interlocking makes the train slow down, a susual. However, as soon as the bus is out of the crossing, i.e when the light turns green and the train begins to cross the road, the error gets thrown. It does not seem to be crossing-dependent, and never occurs when it is the bus that is blocked. Quite strange. Upon reloading the world, everything is back as usual.

Maybe it is worth mentioning that after the crossing, the track continues on a 50-ish-node-long section (part of the same route as the crossing sections), at the end of which there is a signal, and then another 50-ish-node-long section. The signal at the beginning of this section has a route set in automatic working, which comprises that section.

Error message:

Code: Select all

AsyncErr: Lua: Runtime error from mod 'advtrains' in callback environment_Step(): ...etest/mods/advtrains/advtrains_interlocking/approach.lua:43: attempt to index local 'lzbdata' (a nil value)
stack traceback:
	...etest/mods/advtrains/advtrains_interlocking/approach.lua:43: in function 'f'
	...DACTED/.minetest/mods/advtrains/advtrains/trainlogic.lua:832: in function 'run_callbacks_approach_node'
	...DACTED/.minetest/mods/advtrains/advtrains/trainlogic.lua:910: in function 'tnc_call_approach_callback'
	/home/REDACTED/.minetest/mods/advtrains/advtrains/lzb.lua:116: in function 'lzb_look_ahead'
	...DACTED/.minetest/mods/advtrains/advtrains/trainlogic.lua:358: in function 'train_step_b'
	...vyroot/.minetest/mods/advtrains/advtrains/trainlogic.lua:109: in function 'mainloop_trainlogic'
	/home/REDACTED/.minetest/mods/advtrains/advtrains/init.lua:624: in function </home/REDACTED/.minetest/mods/advtrains/advtrains/init.lua:586>
	/usr/share/minetest/builtin/common/register.lua:26: in function </usr/share/minetest/builtin/common/register.lua:12>
Spoiler
-- Upd. --

Having inserted a print() in the Advtrains code, it seems the crash occurs when the function is called for the train; maybe it is due to the track ending some distance away? I am not sure but maybe it is because of this.


-- Upd. 2 --

Nay, it's not that. Still crashes.


-- Upd. 3 --

After some investigations, it seems that the function that makes the game crash receives, at some point, some lzbdata, but at the same call of the function train.lzb.trav_lzbdata is nil (whereas it usually is a table). Then, on the next call to this specific function, the lzbdata it receives is nil. I do not know if any function that is registered with advtrains.tnc_register_on_approach() removes train.lzb.trav_lzbdata, so I will look for that.

EDIT: No, it seems the crashing function is the only one to be called on approach callbacks (unless grep is drunk).


-- Upd. 4 --

With more print()s, it seems that train.lzb.trav_lzbdata is modified (or removed) by advtrains.tnc_call_approach_callback(), but before the crashing function (the only one that is registered, thus called) is called.


-- Upd. 5 --

With even more print()s, the results are:
  • In advtrains/lzb.lua, function resolve_latest_lzbdata(): right before calling advtrains.tnc_call_approach_callback(), everything is normal - train.lzb.trav_lzbdata exists.
  • In advtrains/trainlogic.lua, function mknodecallback(), in the function it returns (which is then referred to ads advtrains.tnc_call_approach_callback()): immediately after the function is called, train.lzb.trav_lzbdata no longer exists. However, it seems that, in-between, a LuaATC some distance away got called, which is supposed to set a route at a signal on the train line. Investigations in progress...
-- Upd. 6 --

Turns out I mistook a function for another; I did not realize I was looking at the wrong function. That might explain my problems with finding where the error is.

Investigations now continue in function on_train_approach() r.fire_event() from the LuaATC rail definition, in file advtrains_luaautomation/atc_rail.lua.

It seems the problem is in the code run by the LuaATC. This code simply... Er... Sets a signal? Investigations now continue in function advtrains.interlocking.route.update_route() (large amount of functions skipped) advtrains.interlocking.signal_on_aspect_changed() aaaaand...

Aha! That last function calls advtrains.invalidate_all_paths_ahead()! Which brings us back to advtrains/trainlogic.lua after our grand tour of many different files... Now, I'm pretty sure advtrains.occ.reverse_lookup_sel() does not modify the lzb data, so I guess the problem is in advtrains.path_invalidate_ahead() (advtrains/path.lua), in which lzb is mentioned by a comment right above a call to advtrains.run_callbacks_invahead() (back to trainlogic.lua) which is another function which registers callbacks! So, yay, prints() again... (other suspect function would be advtrains.occ.clear_specific_item(), which I think can not be the culprit)


-- Upd. 7 --

We then look where advtrains.te_register_on_invalidate_ahead() is called, and find lzb.lua in which is registered a function that calls advtrains.lzb_invalidate_ahead(). Looking for that function, we find at line 228 the following:

Code: Select all

      train.lzb.trav_lzbdata = nil
As far as I could understand, I think it should be replaced by:

Code: Select all

      train.lzb.trav_lzbdata = {}
I have tested this change and it seems to work.


P.S: I wonder how many functions and files I had to travel through to find that. I'll say it was a well-spent afternoon. (lil' trip in Advtrains code...)
Last edited by nazalassa on Thu Sep 19, 2024 06:42, edited 14 times in total.
Life is like a multitasking OS: you know you'll eventually get back to anything, but you don't know when. s/luanti/minetest/gi

User avatar
nazalassa
Member
Posts: 45
Joined: Sun May 26, 2024 14:50
In-game: Nazalassa
Contact:

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

by nazalassa » Post

While I am on the subject of fixing stuff in Advtrains, I would like to suggest (again) making it possible to add fields to the table of train fields to be saved. This way, mods that store train data will not need to worry about saving it: Advtrains will do it for them.
Life is like a multitasking OS: you know you'll eventually get back to anything, but you don't know when. s/luanti/minetest/gi

Dmax_05
Member
Posts: 21
Joined: Fri Nov 17, 2023 20:02

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

by Dmax_05 » Post

AsyncErr: Lua: Runtime error from mod 'advtrains' in callback environment_Step(): ...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:1121: attempt to index local 'wagon' (a nil value)
stack traceback:
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:1121: in function 'spawn_wagons'
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:714: in function 'train_step_c'
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:114: in function 'mainloop_trainlogic'
...est-5.9.0-win64\bin\..\mods\advtrains\advtrains\init.lua:618: in function <...est-5.9.0-win64\bin\..\mods\advtrains\advtrains\init.lua:580>
...\minetest-5.9.0-win64\bin\..\builtin\common\register.lua:26: in function <...\minetest-5.9.0-win64\bin\..\builtin\common\register.lua:12>


HELP PLEASE!!!

User avatar
nazalassa
Member
Posts: 45
Joined: Sun May 26, 2024 14:50
In-game: Nazalassa
Contact:

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

by nazalassa » Post

Dmax_05 wrote:
Thu Sep 19, 2024 13:06
AsyncErr: Lua: Runtime error from mod 'advtrains' in callback environment_Step(): ...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:1121: attempt to index local 'wagon' (a nil value)
stack traceback:
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:1121: in function 'spawn_wagons'
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:714: in function 'train_step_c'
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:114: in function 'mainloop_trainlogic'
...est-5.9.0-win64\bin\..\mods\advtrains\advtrains\init.lua:618: in function <...est-5.9.0-win64\bin\..\mods\advtrains\advtrains\init.lua:580>
...\minetest-5.9.0-win64\bin\..\builtin\common\register.lua:26: in function <...\minetest-5.9.0-win64\bin\..\builtin\common\register.lua:12>


HELP PLEASE!!!
It could help if you could provide information about when the crash happened, i.e what you were doing - I assume you were going somewhere where there was a train, and suddenly the game crashed, but that is only an assumption, and I can not know the rest of the situation. It may also help to know the list of mods you use, especially those you recently upgraded or installed (if any).
Life is like a multitasking OS: you know you'll eventually get back to anything, but you don't know when. s/luanti/minetest/gi

yw05
Member
Posts: 402
Joined: Tue May 07, 2019 12:59
GitHub: y5nw
IRC: y5nw
Location: Germany

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

by yw05 » Post

nazalassa wrote:
Sun Sep 15, 2024 13:54
An error happens in Advtrains in the following situation: I have a level crossing between a linetrack road line and a train line. As the train arrives at the crossing, a bus is, well, crossing the tracks. Interlocking makes the train slow down, a susual. However, as soon as the bus is out of the crossing, i.e when the light turns green and the train begins to cross the road, the error gets thrown. It does not seem to be crossing-dependent, and never occurs when it is the bus that is blocked. Quite strange. Upon reloading the world, everything is back as usual.

Maybe it is worth mentioning that after the crossing, the track continues on a 50-ish-node-long section (part of the same route as the crossing sections), at the end of which there is a signal, and then another 50-ish-node-long section. The signal at the beginning of this section has a route set in automatic working, which comprises that section.

Error message:

Code: Select all

AsyncErr: Lua: Runtime error from mod 'advtrains' in callback environment_Step(): ...etest/mods/advtrains/advtrains_interlocking/approach.lua:43: attempt to index local 'lzbdata' (a nil value)
stack traceback:
	...etest/mods/advtrains/advtrains_interlocking/approach.lua:43: in function 'f'
	...DACTED/.minetest/mods/advtrains/advtrains/trainlogic.lua:832: in function 'run_callbacks_approach_node'
	...DACTED/.minetest/mods/advtrains/advtrains/trainlogic.lua:910: in function 'tnc_call_approach_callback'
	/home/REDACTED/.minetest/mods/advtrains/advtrains/lzb.lua:116: in function 'lzb_look_ahead'
	...DACTED/.minetest/mods/advtrains/advtrains/trainlogic.lua:358: in function 'train_step_b'
	...vyroot/.minetest/mods/advtrains/advtrains/trainlogic.lua:109: in function 'mainloop_trainlogic'
	/home/REDACTED/.minetest/mods/advtrains/advtrains/init.lua:624: in function </home/REDACTED/.minetest/mods/advtrains/advtrains/init.lua:586>
	/usr/share/minetest/builtin/common/register.lua:26: in function </usr/share/minetest/builtin/common/register.lua:12>
-- Upd. 7 --

We then look where advtrains.te_register_on_invalidate_ahead() is called, and find lzb.lua in which is registered a function that calls advtrains.lzb_invalidate_ahead(). Looking for that function, we find at line 228 the following:

Code: Select all

      train.lzb.trav_lzbdata = nil
As far as I could understand, I think it should be replaced by:

Code: Select all

      train.lzb.trav_lzbdata = {}
I have tested this change and it seems to work.


P.S: I wonder how many functions and files I had to travel through to find that. I'll say it was a well-spent afternoon. (lil' trip in Advtrains code...)
In hindsight, grep -rn trav_lzbdata would probably be faster.

Anyway, I'm not sure whether setting trav_lzbdata to the empty table is a good idea, considering that the point of invalidating lzbdata is to tell the LZB system to generate it based on updated information. IMO it would be better to move the nil check (which currently is only performed once before the while loop) into the while loop so that the check is performed at the beginning of each iteration.
Dmax_05 wrote:
Sat Sep 14, 2024 18:35
AsyncErr: Lua: Runtime error from mod 'advtrains' in callback environment_Step(): ...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:1121: attempt to index local 'wagon' (a nil value)
stack traceback:
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:1121: in function 'spawn_wagons'
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:714: in function 'train_step_c'
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:114: in function 'mainloop_trainlogic'
...est-5.9.0-win64\bin\..\mods\advtrains\advtrains\init.lua:618: in function <...est-5.9.0-win64\bin\..\mods\advtrains\advtrains\init.lua:580>
...\minetest-5.9.0-win64\bin\..\builtin\common\register.lua:26: in function <...\minetest-5.9.0-win64\bin\..\builtin\common\register.lua:12>

Anyone knows how to solve this error?
Does this patch help?: https://lists.sr.ht/~gpcf/advtrains-devel/patches/55107
Last edited by yw05 on Fri Sep 20, 2024 11:26, edited 1 time in total.

Dmax_05
Member
Posts: 21
Joined: Fri Nov 17, 2023 20:02

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

by Dmax_05 » Post

nazalassa wrote:
Thu Sep 19, 2024 15:58
Dmax_05 wrote:
Thu Sep 19, 2024 13:06
AsyncErr: Lua: Runtime error from mod 'advtrains' in callback environment_Step(): ...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:1121: attempt to index local 'wagon' (a nil value)
stack traceback:
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:1121: in function 'spawn_wagons'
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:714: in function 'train_step_c'
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:114: in function 'mainloop_trainlogic'
...est-5.9.0-win64\bin\..\mods\advtrains\advtrains\init.lua:618: in function <...est-5.9.0-win64\bin\..\mods\advtrains\advtrains\init.lua:580>
...\minetest-5.9.0-win64\bin\..\builtin\common\register.lua:26: in function <...\minetest-5.9.0-win64\bin\..\builtin\common\register.lua:12>


HELP PLEASE!!!
It could help if you could provide information about when the crash happened, i.e what you were doing - I assume you were going somewhere where there was a train, and suddenly the game crashed, but that is only an assumption, and I can not know the rest of the situation. It may also help to know the list of mods you use, especially those you recently upgraded or installed (if any).
I was going near the station were there are some trains and the game suddenly crashed. I don't know how to give you the list of mods.

Dmax_05
Member
Posts: 21
Joined: Fri Nov 17, 2023 20:02

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

by Dmax_05 » Post

yw05 wrote:
Thu Sep 19, 2024 18:49
nazalassa wrote:
Sun Sep 15, 2024 13:54
An error happens in Advtrains in the following situation: I have a level crossing between a linetrack road line and a train line. As the train arrives at the crossing, a bus is, well, crossing the tracks. Interlocking makes the train slow down, a susual. However, as soon as the bus is out of the crossing, i.e when the light turns green and the train begins to cross the road, the error gets thrown. It does not seem to be crossing-dependent, and never occurs when it is the bus that is blocked. Quite strange. Upon reloading the world, everything is back as usual.

Maybe it is worth mentioning that after the crossing, the track continues on a 50-ish-node-long section (part of the same route as the crossing sections), at the end of which there is a signal, and then another 50-ish-node-long section. The signal at the beginning of this section has a route set in automatic working, which comprises that section.

Error message:

Code: Select all

AsyncErr: Lua: Runtime error from mod 'advtrains' in callback environment_Step(): ...etest/mods/advtrains/advtrains_interlocking/approach.lua:43: attempt to index local 'lzbdata' (a nil value)
stack traceback:
	...etest/mods/advtrains/advtrains_interlocking/approach.lua:43: in function 'f'
	...DACTED/.minetest/mods/advtrains/advtrains/trainlogic.lua:832: in function 'run_callbacks_approach_node'
	...DACTED/.minetest/mods/advtrains/advtrains/trainlogic.lua:910: in function 'tnc_call_approach_callback'
	/home/REDACTED/.minetest/mods/advtrains/advtrains/lzb.lua:116: in function 'lzb_look_ahead'
	...DACTED/.minetest/mods/advtrains/advtrains/trainlogic.lua:358: in function 'train_step_b'
	...vyroot/.minetest/mods/advtrains/advtrains/trainlogic.lua:109: in function 'mainloop_trainlogic'
	/home/REDACTED/.minetest/mods/advtrains/advtrains/init.lua:624: in function </home/REDACTED/.minetest/mods/advtrains/advtrains/init.lua:586>
	/usr/share/minetest/builtin/common/register.lua:26: in function </usr/share/minetest/builtin/common/register.lua:12>
-- Upd. 7 --

We then look where advtrains.te_register_on_invalidate_ahead() is called, and find lzb.lua in which is registered a function that calls advtrains.lzb_invalidate_ahead(). Looking for that function, we find at line 228 the following:

Code: Select all

      train.lzb.trav_lzbdata = nil
As far as I could understand, I think it should be replaced by:

Code: Select all

      train.lzb.trav_lzbdata = {}
I have tested this change and it seems to work.


P.S: I wonder how many functions and files I had to travel through to find that. I'll say it was a well-spent afternoon. (lil' trip in Advtrains code...)
In hindsight, grep -rn trav_lzbdata would probably be faster.

Anyway, I'm not sure whether setting trav_lzbdata to the empty table is a good idea, considering that the point of invalidating lzbdata is to tell the LZB system to generate it based on updated information. IMO it would be better to move the nil check (which currently is only performed once before the while loop) into the while loop so that it is run at the beginning of each iteration.
Dmax_05 wrote:
Sat Sep 14, 2024 18:35
AsyncErr: Lua: Runtime error from mod 'advtrains' in callback environment_Step(): ...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:1121: attempt to index local 'wagon' (a nil value)
stack traceback:
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:1121: in function 'spawn_wagons'
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:714: in function 'train_step_c'
...9.0-win64\bin\..\mods\advtrains\advtrains/trainlogic.lua:114: in function 'mainloop_trainlogic'
...est-5.9.0-win64\bin\..\mods\advtrains\advtrains\init.lua:618: in function <...est-5.9.0-win64\bin\..\mods\advtrains\advtrains\init.lua:580>
...\minetest-5.9.0-win64\bin\..\builtin\common\register.lua:26: in function <...\minetest-5.9.0-win64\bin\..\builtin\common\register.lua:12>

Anyone knows how to solve this error?
Does this patch help?: https://lists.sr.ht/~gpcf/advtrains-devel/patches/55107
I don't know how to use the patch you provided. Is there a way to download it?

yw05
Member
Posts: 402
Joined: Tue May 07, 2019 12:59
GitHub: y5nw
IRC: y5nw
Location: Germany

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

by yw05 » Post

nazalassa wrote:
Wed Sep 18, 2024 15:24
While I am on the subject of fixing stuff in Advtrains, I would like to suggest (again) making it possible to add fields to the table of train fields to be saved. This way, mods that store train data will not need to worry about saving it: Advtrains will do it for them.
How about a staticdata field in the train tables?
Dmax_05 wrote:
Fri Sep 20, 2024 07:14
yw05 wrote:
Thu Sep 19, 2024 18:49
Does this patch help?: https://lists.sr.ht/~gpcf/advtrains-devel/patches/55107
I don't know how to use the patch you provided. Is there a way to download it?
You can download the patch with the "Export patchset (mbox)" button. You should by able to apply it by running git am path/to/mbox or (if you do not use git) apply -p1 path/to/mbox in the Advtrains modpack directory; I would assume that Windows provides the tools for downloading patches.

NicoKaiserHello
Member
Posts: 19
Joined: Sat Jul 06, 2024 17:34
In-game: NicoKaiser

Re: [Mod] Fortgeschrittene [Vorzüge] [2.4.3]

by NicoKaiserHello » Post

I have to write:

/grantme atlatc
/set-info-display(event.id, "front", "Line 1")

?

Dmax_05
Member
Posts: 21
Joined: Fri Nov 17, 2023 20:02

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

by Dmax_05 » Post

yw05 wrote:
Fri Sep 20, 2024 11:04
nazalassa wrote:
Wed Sep 18, 2024 15:24
While I am on the subject of fixing stuff in Advtrains, I would like to suggest (again) making it possible to add fields to the table of train fields to be saved. This way, mods that store train data will not need to worry about saving it: Advtrains will do it for them.
How about a staticdata field in the train tables?
Dmax_05 wrote:
Fri Sep 20, 2024 07:14
yw05 wrote:
Thu Sep 19, 2024 18:49
Does this patch help?: https://lists.sr.ht/~gpcf/advtrains-devel/patches/55107
I don't know how to use the patch you provided. Is there a way to download it?
You can download the patch with the "Export patchset (mbox)" button. You should by able to apply it by running git am path/to/mbox or (if you do not use git) apply -p1 path/to/mbox in the Advtrains modpack directory; I would assume that Windows provides the tools for downloading patches.
Both commands are not working on windows

User avatar
nazalassa
Member
Posts: 45
Joined: Sun May 26, 2024 14:50
In-game: Nazalassa
Contact:

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

by nazalassa » Post

yw05 wrote:
Fri Sep 20, 2024 11:04
nazalassa wrote:
Wed Sep 18, 2024 15:24
While I am on the subject of fixing stuff in Advtrains, I would like to suggest (again) making it possible to add fields to the table of train fields to be saved. This way, mods that store train data will not need to worry about saving it: Advtrains will do it for them.
How about a staticdata field in the train tables?
Why not... Actually, this seems better than setting random fields in the train table.
NicoKaiserHello wrote:
Fri Sep 20, 2024 11:19
I have to write:

/grantme atlatc
/set-info-display(event.id, "front", "Line 1")

?
What you have to do is:
  • In your minetest world, press the '/' key, which will open the chat at the top of the screen
  • Enter the following command: /grantme atlatc
    (make sure there is only 1 '/' and not 2 before 'grantme')
    • You should then see in the chat someting like this: "Privileges of <playername>: ..."
  • If you did not create a LuaATC environment yet, you should create one; to do so, repeat the above steps with: /env_create <name> (replace <name> with whatever name you wish, e.g "subway")
  • You can then go to your LuaATC rail, and enter code into it. Make sure to assign it to an environment using the drop-down menu in the top-left of the LuaATC rail formspec.
  • set_info_display() is a function that can be used in LuaATC code. So, in your LuaATC rail, you should enter the following code:

    Code: Select all

    if event.train then
       set_info_display(event.id, "front", "Line 1")
    end
    
Life is like a multitasking OS: you know you'll eventually get back to anything, but you don't know when. s/luanti/minetest/gi

yw05
Member
Posts: 402
Joined: Tue May 07, 2019 12:59
GitHub: y5nw
IRC: y5nw
Location: Germany

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

by yw05 » Post

Dmax_05 wrote:
Fri Sep 20, 2024 11:34
yw05 wrote:
Fri Sep 20, 2024 11:04
You can download the patch with the "Export patchset (mbox)" button. You should by able to apply it by running git am path/to/mbox or (if you do not use git) apply -p1 path/to/mbox in the Advtrains modpack directory; I would assume that Windows provides the tools for downloading patches.
Both commands are not working on windows
I guess we'll have to go with a hotfix then. Does line 1121 of advtrains/trainlogic.lua look something like the following on your local copy? (You can ignore the whitespaces)

Code: Select all

wagon:set_id(id)
If yes, please replace it with

Code: Select all

if wagon then wagon:set_id(id) end
Unfortunately this only prevents Advtrains from crashing and does not resolve the underlying issues.
nazalassa wrote:
Fri Sep 20, 2024 13:04
yw05 wrote:
Fri Sep 20, 2024 11:04
nazalassa wrote:
Wed Sep 18, 2024 15:24
While I am on the subject of fixing stuff in Advtrains, I would like to suggest (again) making it possible to add fields to the table of train fields to be saved. This way, mods that store train data will not need to worry about saving it: Advtrains will do it for them.
How about a staticdata field in the train tables?
Why not... Actually, this seems better than setting random fields in the train table.
I have finished the patch in the meantime; could you see if it helps?: https://lists.sr.ht/~gpcf/advtrains-devel/patches/55116

Basically it exposes a staticdata table field in the train table. It is shared with other mods though (but not with Advtrains core), so I would suggest adding at least a prefix to field names.

Note that there are certain limitations imposed by serialize_lib, but that should not be relevant in most cases.

Side note: reformatting advtrains/api_doc.txt (into Markdown perhaps?) would be a good idea as well.

User avatar
nazalassa
Member
Posts: 45
Joined: Sun May 26, 2024 14:50
In-game: Nazalassa
Contact:

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

by nazalassa » Post

yw05 wrote:
Fri Sep 20, 2024 13:27
nazalassa wrote:
Fri Sep 20, 2024 13:04
yw05 wrote:
Fri Sep 20, 2024 11:04


How about a staticdata field in the train tables?
Why not... Actually, this seems better than setting random fields in the train table.
I have finished the patch in the meantime; could you see if it helps?: https://lists.sr.ht/~gpcf/advtrains-devel/patches/55116

Basically it exposes a staticdata table field in the train table. It is shared with other mods though (but not with Advtrains core), so I would suggest adding at least a prefix to field names.

Note that there are certain limitations imposed by serialize_lib, but that should not be relevant in most cases.

Side note: reformatting advtrains/api_doc.txt (into Markdown perhaps?) would be a good idea as well.
Since the patch (obviously) seems to work, I have adapted advtrains_info_displays so that it works with staticdata. Not much to change...
Life is like a multitasking OS: you know you'll eventually get back to anything, but you don't know when. s/luanti/minetest/gi

User avatar
nazalassa
Member
Posts: 45
Joined: Sun May 26, 2024 14:50
In-game: Nazalassa
Contact:

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

by nazalassa » Post

Where are the selection/collision boxes of the default sloped tracks defined? I couldn't find it, and I'd like to understand why only the default slopes (and not any custom slopes I register from my mods, for example) have selection boxes that correspond to their model.

Also, setmetatable() might be useful in LuaATCs in some occasions, such as storing data for stations, as it may remove the need for code like this:

Code: Select all

if not S.stn[name] then
   S.stn[name] = {}
end
by having a metatable like

Code: Select all

{__index = function (t,i)
   t[i] = {}
   return t[i]
end
}
Life is like a multitasking OS: you know you'll eventually get back to anything, but you don't know when. s/luanti/minetest/gi

User avatar
apercy
Member
Posts: 666
Joined: Wed Mar 25, 2020 16:31
GitHub: APercy
In-game: APercy
Location: Pinheiral - RJ - Brazil

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

by apercy » Post

After I did the update of my server to the version 5.9.1, I got this error:

Code: Select all

2024-10-22 00:50:50: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'advtrains' in callback environment_Step(): ...bin/../mods/advtrains-release-2.4.6/advtrains/nodedb.lua:205: attempt to call field 'get_node_or_nil' (a nil value)
2024-10-22 00:50:50: ERROR[Main]: stack traceback:
2024-10-22 00:50:50: ERROR[Main]:       ...bin/../mods/advtrains-release-2.4.6/advtrains/nodedb.lua:205: in function 'get_node_or_nil'
2024-10-22 00:50:50: ERROR[Main]:       ...bin/../mods/advtrains-release-2.4.6/advtrains/nodedb.lua:274: in function 'get_rail_info_at'
2024-10-22 00:50:50: ERROR[Main]:       ...in/../mods/advtrains-release-2.4.6/advtrains/helpers.lua:320: in function 'get_adjacent_rail'
2024-10-22 00:50:50: ERROR[Main]:       ...t/bin/../mods/advtrains-release-2.4.6/advtrains/path.lua:253: in function 'advtrains_path_get'
2024-10-22 00:50:50: ERROR[Main]:       ...t/bin/../mods/advtrains-release-2.4.6/advtrains/path.lua:338: in function 'path_get_index_by_offset'
2024-10-22 00:50:50: ERROR[Main]:       ...../mods/advtrains-release-2.4.6/advtrains/trainlogic.lua:230: in function 'recalc_end_index'
2024-10-22 00:50:50: ERROR[Main]:       ...../mods/advtrains-release-2.4.6/advtrains/trainlogic.lua:333: in function 'train_ensure_init'
2024-10-22 00:50:50: ERROR[Main]:       ...../mods/advtrains-release-2.4.6/advtrains/trainlogic.lua:102: in function 'mainloop_trainlogic'
2024-10-22 00:50:50: ERROR[Main]:       ...t/bin/../mods/advtrains-release-2.4.6/advtrains/init.lua:618: in function <...t/bin/../mods/advtrains-release-2.4.6/advtrains/init.lua:580>

yw05
Member
Posts: 402
Joined: Tue May 07, 2019 12:59
GitHub: y5nw
IRC: y5nw
Location: Germany

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

by yw05 » Post

nazalassa wrote:
Sat Sep 21, 2024 10:02
Where are the selection/collision boxes of the default sloped tracks defined? I couldn't find it, and I'd like to understand why only the default slopes (and not any custom slopes I register from my mods, for example) have selection boxes that correspond to their model.
advtrains/tracks.lua seems to define a default selectionbox for tracks in advtrains.register_tracks. The default track set defines its own selectionboxes in advtrains_train_track/init.lua.
Also, setmetatable() might be useful in LuaATCs in some occasions
Agreed. Be careful though: the metatables for tables inside F and S may need to be updated when the init code is (re)run.
apercy wrote:
Tue Oct 22, 2024 00:53

Code: Select all

2024-10-22 00:50:50: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'advtrains' in callback environment_Step(): ...bin/../mods/advtrains-release-2.4.6/advtrains/nodedb.lua:205: attempt to call field 'get_node_or_nil' (a nil value)
2024-10-22 00:50:50: ERROR[Main]: stack traceback:
2024-10-22 00:50:50: ERROR[Main]:       ...bin/../mods/advtrains-release-2.4.6/advtrains/nodedb.lua:205: in function 'get_node_or_nil'
2024-10-22 00:50:50: ERROR[Main]:       ...bin/../mods/advtrains-release-2.4.6/advtrains/nodedb.lua:274: in function 'get_rail_info_at'
2024-10-22 00:50:50: ERROR[Main]:       ...in/../mods/advtrains-release-2.4.6/advtrains/helpers.lua:320: in function 'get_adjacent_rail'
2024-10-22 00:50:50: ERROR[Main]:       ...t/bin/../mods/advtrains-release-2.4.6/advtrains/path.lua:253: in function 'advtrains_path_get'
2024-10-22 00:50:50: ERROR[Main]:       ...t/bin/../mods/advtrains-release-2.4.6/advtrains/path.lua:338: in function 'path_get_index_by_offset'
2024-10-22 00:50:50: ERROR[Main]:       ...../mods/advtrains-release-2.4.6/advtrains/trainlogic.lua:230: in function 'recalc_end_index'
2024-10-22 00:50:50: ERROR[Main]:       ...../mods/advtrains-release-2.4.6/advtrains/trainlogic.lua:333: in function 'train_ensure_init'
2024-10-22 00:50:50: ERROR[Main]:       ...../mods/advtrains-release-2.4.6/advtrains/trainlogic.lua:102: in function 'mainloop_trainlogic'
2024-10-22 00:50:50: ERROR[Main]:       ...t/bin/../mods/advtrains-release-2.4.6/advtrains/init.lua:618: in function <...t/bin/../mods/advtrains-release-2.4.6/advtrains/init.lua:580>
This is weird. minetest.get_node_or_nil is clearly defined by the engine, so it should not be nil.

User avatar
nazalassa
Member
Posts: 45
Joined: Sun May 26, 2024 14:50
In-game: Nazalassa
Contact:

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

by nazalassa » Post

yw05 wrote:
Wed Oct 23, 2024 18:43
nazalassa wrote:
Sat Sep 21, 2024 10:02
Where are the selection/collision boxes of the default sloped tracks defined? I couldn't find it, and I'd like to understand why only the default slopes (and not any custom slopes I register from my mods, for example) have selection boxes that correspond to their model.
advtrains/tracks.lua seems to define a default selectionbox for tracks in advtrains.register_tracks. The default track set defines its own selectionboxes in advtrains_train_track/init.lua.
Yes, but I could not find any selection/collision boxes related to sloped tracks in advtrains_train_track/init.lua, nor in advtrains/tracks.lua; weirdly enough, copying the 'normal' sloped track definition does not 'copy' the sloped collision boxes.
Life is like a multitasking OS: you know you'll eventually get back to anything, but you don't know when. s/luanti/minetest/gi

yw05
Member
Posts: 402
Joined: Tue May 07, 2019 12:59
GitHub: y5nw
IRC: y5nw
Location: Germany

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

by yw05 » Post

nazalassa wrote:
Thu Oct 24, 2024 15:12
Yes, but I could not find any selection/collision boxes related to sloped tracks in advtrains_train_track/init.lua, nor in advtrains/tracks.lua; weirdly enough, copying the 'normal' sloped track definition does not 'copy' the sloped collision boxes.
It seems like the sloped tracks use the default selection and collision boxes. This also appears to be the case in-game, where it is possible to visually walk into the sloped tracks.

---

WIP: New HUD:
Image

User avatar
nazalassa
Member
Posts: 45
Joined: Sun May 26, 2024 14:50
In-game: Nazalassa
Contact:

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

by nazalassa » Post

yw05 wrote:
Mon Oct 28, 2024 15:35
nazalassa wrote:
Thu Oct 24, 2024 15:12
Yes, but I could not find any selection/collision boxes related to sloped tracks in advtrains_train_track/init.lua, nor in advtrains/tracks.lua; weirdly enough, copying the 'normal' sloped track definition does not 'copy' the sloped collision boxes.
It seems like the sloped tracks use the default selection and collision boxes. This also appears to be the case in-game, where it is possible to visually walk into the sloped tracks.
Whoops. I guess my eyes bugged then.
yw05 wrote:
Mon Oct 28, 2024 15:35
WIP: New HUD:
Image
Ooh, nice HUD! Is that Unifont on the Cpl, ARS, ATC and LZB indicators?
Life is like a multitasking OS: you know you'll eventually get back to anything, but you don't know when. s/luanti/minetest/gi

yw05
Member
Posts: 402
Joined: Tue May 07, 2019 12:59
GitHub: y5nw
IRC: y5nw
Location: Germany

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

by yw05 » Post

nazalassa wrote:
Tue Oct 29, 2024 07:25
yw05 wrote:
Mon Oct 28, 2024 15:35
WIP: New HUD:
Image
Ooh, nice HUD! Is that Unifont on the Cpl, ARS, ATC and LZB indicators?
Yes, it is Unifont.

Also a minor adjustment to the speed bar (the design is still close to the one we currently use):
Attachments
screenshot_20241029_190428.png
screenshot_20241029_190428.png (820 Bytes) Viewed 1648 times

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

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

by orwell » Post

Advtrains 2.4.7

Hello all,
after welcoming my second child (IRL) end of September and having some sleepless nights, I got back to advtrains and found a myriad of patches submitted to the mailing list. Special thanks to 1F616EMO/nazalassa and Maverick for the contributions, to Tanavit for the french translation, and for ywang for keeping an eye out in the forum and on the mailing list.

2.4.7 brings a couple of improvements, fixing some bugs and adding convenience features to the interlocking. My overhaul of the signalling system (branch route_prog_rework) is still not finished though, so no distant signalling yet.

Regards, orwell
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

Singularis
Member
Posts: 11
Joined: Fri Jun 17, 2022 07:36
GitHub: singularis-mzf

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

by Singularis » Post

Hello,

it seems to me that I found a compatibility issue that causes misbehaviour od advtrains in new versions of Luanti. It is in function advtrains.is_node_loaded(). This function is not working properly on new engine versions (I found it in Minetest 5.8.0), so nodes (especially signals) are sometimes not updated, especially when the mapblock is forceloaded (which means that it is loaded and active, but no player is around). This function should use core.compare_block_status() function when it is available.

porcupiney
New member
Posts: 3
Joined: Mon Nov 25, 2024 08:48

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

by porcupiney » Post

Hi,
I have a fairly complex layout of tracks etc. I am trying to modify it, but now I find I cannot delete TCBs, neither can I delete the piece of track connected to the TCB.

What can I do to remove all unused TCBs and sections without starting over?

Thanks, Dave

User avatar
Blockhead
Moderator
Posts: 2171
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

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

by Blockhead » Post

Singularis wrote:
Sun Nov 24, 2024 13:10
Hello,

it seems to me that I found a compatibility issue that causes misbehaviour od advtrains in new versions of Luanti. It is in function advtrains.is_node_loaded(). This function is not working properly on new engine versions (I found it in Minetest 5.8.0), so nodes (especially signals) are sometimes not updated, especially when the mapblock is forceloaded (which means that it is loaded and active, but no player is around). This function should use core.compare_block_status() function when it is available.
Hi Singularis,

Is there an engine regression that you're aware of, or was Advtrains maybe relying on undefined behaviour? If you know if an an engine regression, please report it. If you have a reproducible way to make Advtrains crash with that function, that would also be very helpful. Even better, though not expected, would be if you could send a fix to the mailing list.

porcupiney wrote:
Mon Nov 25, 2024 08:52
Hi,
I have a fairly complex layout of tracks etc. I am trying to modify it, but now I find I cannot delete TCBs, neither can I delete the piece of track connected to the TCB.

What can I do to remove all unused TCBs and sections without starting over?

Thanks, Dave
Hi porcupiney/Dave,

Ordinarily you need to delete both sections to remove the TCB. This is done from the TCB's right click menu by clicking through to each section and removing the TCB, or dissolving the entire section (probably you want the latter if you are taking sections apart). Is this working for you?
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

Post Reply