News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

Tutorial - code review

Started by Andarix, May 15, 2025, 01:22:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT

#35
Quote from: Andarix on June 06, 2025, 11:13:22 PMadd in 11720

The graphic is a bit deep and a bit smaller.

Screenshot 2025-06-07 005722.png

I was thinking of extending this to show tool icons as well, although this would require some work on the text.




search_tile_in_tiles() is not defined for class_basic_data.nut, this should fix it and hopefully won't break anything else.

https://github.com/simutrans/tutorial_multipak/commit/e0e8b59b3e2852fab4de327c0948912c4eed5744

Yona-TYT

#36

Andarix


Yona-TYT

#38
https://github.com/simutrans/tutorial_multipak/commit/7d5eca682ecffc83be32058d2f409d081a722c80

Fix inconsistent layer values.




In pak128 the text label indicating where to build the tunnel has incorrect coordinates.

It should be (96,172), but it's set to (95,172).

Line 883 "class_chapter_03.nut"

          if ((!tile.find_object(mo_tunnel))){
            label_x.create(way2_fac2_fac3[2], pl_unown, translate("Place a Tunnel here!."))
            r_way.c =  coord3d(tile.x, tile.y, tile.z)
          }

simscr06.png

Andarix

I changed the coordinates. But now the track can no longer be built on the slope.

Yona-TYT

Quote from: Andarix on July 24, 2025, 03:24:12 PMI changed the coordinates. But now the track can no longer be built on the slope.
We've had that problem before, due to how slopes are handled in pak128 vs pak64.

prissi

The tutorial fails in chapter 7, line 113. "Index href does not exist"

Since I am planning to release somthing working, I would be happy for any hints to solve this.

Andarix

#42
Could you please describe it in more detail (chapter and language)?

I'm not getting any error messages.

[EDIT]

Check that you are using the latest sve file. There must be a bus station next to the train station.

[EDIT 2]

pak64, pak64.german or pak128?

Andarix

#43
for testing

  • extract to [pakset]/scenario/
  • start simutrans (latest revision, better latest nightly)
  • open load scenario
  • select scenario tutorial_multipak

Please not click button Tutorial.


translate page
Important: Do not change the text within { } or these brackets.

[EDIT]

new version https://forum.simutrans.com/index.php/topic,23513.msg211829/topicseen.html#msg211829

Yona-TYT

#44
Code_review should be the main branch in GitHub, don't you think?.

My tests (pak64):

  //Step 11 =====================================================================================
  loc3_name_obj = get_veh_ch3(3)
  loc3_tile = calc_station_lenght(get_veh_ch3(3), get_veh_ch3(6), set_train_lenght(3))
  loc3_load = set_loading_capacity(4)
  loc3_wait = set_waiting_time(4)
There are problems getting the maximum locomotive size, the value of loc3_tile = 1, but it should be 4.

Edit: I've noticed that when you load the save game, the problem disappears, and the train does leave the depot this time, which is strange.  :o
tutorial_multipak_2026-CH3_ST_K.sve


Artifacts in Spanish text; I thought I had fixed this in the translations, but it seems to keep coming back.
simscr01.png

Andarix

#45
Quote from: Yona-TYT on January 03, 2026, 06:04:11 AM...
Artifacts in Spanish text; I thought I had fixed this in the translations, but it seems to keep coming back.
...

This may be due to the chosen font in Simutrans.

Or you may have corrected it in the repository but not on the translation page. The texts are taken from the translation website.

Quote from: Yona-TYT on January 03, 2026, 06:04:11 AM....
There are problems getting the maximum locomotive size, the value of loc3_tile = 1, but it should be 4.

Edit: I've noticed that when you load the save game, the problem disappears, and the train does leave the depot this time, which is strange.  :o
...

The function for calculating or returning the result then seems to malfunction.

The question here is, how did you proceed? Did you use the automatic link function or did you complete it manually as a player?

I've noticed that if the automatic link is clicked too quickly in succession, the script malfunctions.

Quote from: Yona-TYT on January 03, 2026, 06:04:11 AMCode_review should be the main branch in GitHub, don't you think?.

...

Either switch branches or merge them into the main branch.

I would recommend merging, as the review isn't complete yet. The `get_fullway` function is too rigidly tied to the direction of railway construction. This currently prevents industries from utilizing each other in different orientations. And the requirement to always build on the designated field is, in my opinion, not a good design choice.

Yona-TYT

QuoteThe question here is, how did you proceed? Did you use the automatic link function or did you complete it manually as a player?
I built almost everything manually; in the case of vehicles, I use the automated script to create and route the train.

Andarix

Automatic and manual processes use different code. Therefore, it is important to specify the procedure used when encountering errors.

I'm working on ensuring the automatic process only moves to the next step once the current step is complete. This isn't currently the case, which is why errors occur when the process jumps too quickly.


Andarix

#49
chapter 6 step B

I can not start the Airplane. Error by create schedule.

[EDIT]

The extension building cannot be selected.

[EDIT 2]

start Airplane fixed
https://github.com/simutrans/tutorial_multipak/commit/584133381838a4eb7fcb8220659e65d6681784c2

Andarix

#50
chapter 2 step F

Bug create schedule

I don't know why, but in the text, the steps are shown as clicked even though the step hasn't started yet.

Please also test the manual process and not just the automatic one.

[EDIT]

fixed https://github.com/simutrans/tutorial_multipak/commit/34e076f23535c25e5064bf2e51b7d87bf1e8ccb3

Andarix

#51
chapter 5 step D

Bug create ship schedule

Error message: Only road schedules allowed

[EDIT]

fixed https://github.com/simutrans/tutorial_multipak/commit/c9c54dbe52ccd947b011b1dad94da3dd294226cf

Andarix

#52
Except for the construction of the airport extension building, all bugs should be fixed. This can be skipped using the automatic step.

I haven't yet fully tested with pak64.german and pak128.

Furthermore, errors can occur if actions are executed incorrectly. These errors can then lead to further problems.



  • extract to simutrans/pak/scenario/
  • start simutrans (latest revision, better latest nightly)
  • open load scenario
  • select scenario tutorial_multipak

Please not click button Tutorial.


translate page
Important: Do not change the text within { } or these brackets.


Yona-TYT

Simutrans 124.3.1 r11671 did not have this problem, so I suspect that something has broken in the Simutrans code recently.
simscr07.png

prissi

Bridges now require two clicks or dragging. I will investigate. But without setting the flag it works most of the time.

prissi

Which branch is the code to test?


Andarix

Quote from: Yona-TYT on Yesterday at 03:01:07 AMSimutrans 124.3.1 r11671 did not have this problem, so I suspect that something has broken in the Simutrans code recently.
simscr07.png

The error occurs when automatic progress is clicked too quickly.

I haven't encountered it while playing normally as a player.

Andarix

#59
Quote from: Yona-TYT on Yesterday at 03:01:07 AMSimutrans 124.3.1 r11671 did not have this problem, so I suspect that something has broken in the Simutrans code recently.
simscr07.png

I believe the error occurs because the bridge construction is being carried out again, even though the bridge has already been built.

Screenshot 2026-01-06 095411.png




[EDIT]

I hope this fix the error
https://github.com/simutrans/tutorial_multipak/commit/99fac8b54c2e9bf694b1b6c58a819ea1cc66953b

Yona-TYT

Quote from: Andarix on Yesterday at 08:04:10 AMThe error occurs when automatic progress is clicked too quickly.

I haven't encountered it while playing normally as a player.
Certainly, but I'm sure this didn't happen in previous versions of Simutrans; I'll have to investigate to find out which revision was the cause.

Andarix

#61
Earlier versions of the tutorial ran much more sluggishly.

Ultimately, my fix should resolve that.

More importantly, the bug with airport construction needs to be fixed. The construction of extensions buildings worked in earlier versions. I have no idea when that stopped working.


[EDIT]
fix the tool error
https://github.com/simutrans/tutorial_multipak/commit/00610fbc6c4a1c089d10a4de08e063272ee2c96a

I have no idea why extensions have waytype 0.
Unfortunately, the fix also activates the extension buildings in the Special menu.


That's the problem with a lot of testing. You don't play manually; instead, you're tempted to only use the automatic functions.

Yona-TYT

#62
Quote from: Andarix on Yesterday at 09:50:20 PMThat's the problem with a lot of testing. You don't play manually; instead, you're tempted to only use the automatic functions.
I didn't get to chapter 6 doing the manual tests, right at that moment a situation arose here and I left the tests at chapter 5 I think.


Edit.
Line 672 , class_chapter_05.nut
                result = translate("Build the transformer here!")+" ("+way5_power[j].tostring()+")."
way5 power is a tile_x, therefore the coordinates are not being processed, you have to convert to coord3d, using "coord3d_to_string(way5_power[j])"