The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Andarix on May 15, 2025, 01:22:00 PM

Title: Tutorial - code review
Post by: Andarix on May 15, 2025, 01:22:00 PM
Quote from: Yona-TYT on May 15, 2025, 03:00:20 AMOk, I made the necessary changes to the "code_review" branch, and I also had to add another text file to step 7.

https://github.com/simutrans/tutorial_multipak/commit/5f75194943825323b5a53aba19e4cf5c80d5574c
https://github.com/simutrans/tutorial_multipak/commit/0aba71fec34e234ee67d943a0ec8e4d5a386819a



Additional note: The "cov_sw" flag that indicates whether the number of convoys in circulation is correct or not, seems to not be working in "code_review", as a result, when I delete the vehicle, the info in the scene window is no longer coherent.

        if (!cov_sw){
          text = ttextfile("chapter_02/07_3-4.txt")
          text.tx = ttext("<em>[3/4]</em>")

          local tile = my_tile(city2_halt_1[city2_halt_1.len()-1])
          text.stnam = ""+city2_halt_1.len()+") "+tile.get_halt().get_name()+" ("+coord_to_string(tile)+")"

          text.list = create_halt_list(city2_halt_1)
          text.nr = siz
        }




Are you sure it worked before?

cov_sw is initialized to true in scenario.nut.

It is evaluated once in Chapter 2. It is evaluated four times in Chapter 3.

A search of all files did not yield any further entries.

I haven't actually changed anything about that.
Title: Re: Tutorial - code review
Post by: Yona-TYT on May 16, 2025, 05:49:16 PM
I need to review all of that. I'd also like to change the text labels to unowned, only in places where they can be used, of course.

@Andarix, I hope this doesn't hinder or harm your work. If so, please let me know, and I'll postpone this for another time.

@Prissi, I'm wondering if it's possible to use unowned text labels on player-owned roads/rails? If so, then I'll open an extension request.
Title: Re: Tutorial - code review
Post by: Andarix on May 16, 2025, 08:38:12 PM
Quote from: Yona-TYT on May 16, 2025, 05:49:16 PM...
@Andarix, I hope this doesn't hinder or harm your work. If so, please let me know, and I'll postpone this for another time.
...

I've completed chapters 1 through 3 regarding the changes to the maps.

My tests with pak64 didn't cause any more errors. However, I only tested for correct functionality.
Title: Re: Tutorial - code review
Post by: Yona-TYT on May 21, 2025, 03:38:59 PM
There are several changes regarding moving "Follow Vehicle" to step 7: https://github.com/simutrans/tutorial_multipak/commit/0aba71fec34e234ee67d943a0ec8e4d5a386819a

cov_sw was actually a dead variable; the one that should be used in these cases is called correct_cov.
Fix here: https://github.com/simutrans/tutorial_multipak/commit/d6e0b8f54b3628a8eaae7f6cd6a4e0dab06a5cfe


Prissi did some cleanup on the "Schedule" code, and I've now moved her changes to the "code review" branch. Thanks a lot for your input @Prissi 8)
https://github.com/simutrans/tutorial_multipak/commit/73f960d1a577a2e22028388f2253964273989f7e


Edit.

You need to adjust the info in step 6 so that "text.list = create_schedule_list(city1_halt_2)" is used instead of "st1, st2 ...".

Screenshot 2025-05-21 at 12-02-42 .png
Title: Re: Tutorial - code review
Post by: Andarix on May 27, 2025, 02:46:46 PM
chapter 5

I've revised the substations a bit and removed various tile definitions. However, the automatic tile search isn't complete yet.

I think we should be a bit more flexible with the post office extensions. Several sets also include post office stops. Therefore, I would rather allow both the extension with a post office building and the extension with a post stop.

The check has been changed so that the stop accepts mail.
Title: Re: Tutorial - code review
Post by: Yona-TYT on May 27, 2025, 05:08:03 PM
Quote from: Andarix on May 27, 2025, 02:46:46 PMI think we should be a bit more flexible with the post office extensions. Several sets also include post office stops. Therefore, I would rather allow both the extension with a post office building and the extension with a post stop.


In fact, in pak192.comic's tutorial, the mechanics are a bit different, as it uses a combination of post buildings and post stops. I like the idea of combining both options . 8)
Title: Re: Tutorial - code review
Post by: Andarix on May 27, 2025, 10:40:39 PM
Quote from: Yona-TYT on May 21, 2025, 03:38:59 PM...
Prissi did some cleanup on the "Schedule" code, and I've now moved her changes to the "code review" branch. Thanks a lot for your input @Prissi 8)
https://github.com/simutrans/tutorial_multipak/commit/73f960d1a577a2e22028388f2253964273989f7e
...

I think these changes aren't working correctly.

I can no longer create timetables.

However, it works in the release version of the tutorial.
Title: Re: Tutorial - code review
Post by: Yona-TYT on May 27, 2025, 10:58:54 PM
Quote from: Andarix on May 27, 2025, 10:40:39 PMI think these changes aren't working correctly.

I can no longer create timetables.

However, it works in the release version of the tutorial.
I tried the first bus and it seems to work fine, where exactly is it failing?.
Title: Re: Tutorial - code review
Post by: Andarix on May 28, 2025, 07:02:49 AM
When I buy a vehicle from the depot, the vehicle isn't displayed at the top.

If I switch to the vehicle at the top, I can't access a new route. The timetable window doesn't open, and the field jumps back.

It's time for others to test the new code. Unpack the zip file to [pakset]/scenario and then select "Load Scenario".

errors

Chapter 2 step 4 texts are not correct because this was not changed on the translation page (https://simutrans-germany.com/translator_page/scenarios/scenario_5/index.php?obj_id=88408&lang=en&ref_lang=none&trans_lang=es,de,en).
[edit]
chapter 2 step 6 1/2 text error halt list


[edit]
delete attaches files

new files here (https://forum.simutrans.com/index.php?msg=210644)
Title: Re: Tutorial - code review
Post by: Andarix on May 28, 2025, 03:17:47 PM
Quote from: Yona-TYT on May 27, 2025, 10:58:54 PMI tried the first bus and it seems to work fine, where exactly is it failing?.

It's possible that all the testing has caused some confusion.
Title: Re: Tutorial - code review
Post by: Andarix on May 28, 2025, 05:57:31 PM
bugfix version


[edit]

reupload files


[EDIT 2]

remove files

new files here (https://forum.simutrans.com/index.php?msg=211764)
Title: Re: Tutorial - code review
Post by: Yona-TYT on May 29, 2025, 12:51:44 PM
It seems that this is a bad character, and there may be translation errors because of this.IMG_20250529_084944_251.jpg
Title: Re: Tutorial - code review
Post by: Andarix on May 29, 2025, 06:22:24 PM
Quote from: Yona-TYT on May 29, 2025, 12:51:44 PMIt seems that this is a bad character, and there may be translation errors because of this.
...

Then take a look at Simutrans's es.tab.

Simutrans uses this symbol to mark UTF-8 translation files.
Title: Re: Tutorial - code review
Post by: Andarix on June 07, 2025, 08:38:15 AM
Quote from: Andarix on May 28, 2025, 07:02:49 AM...
It's time for others to test the new code. Unpack the zip file to [pakset]/scenario and then select "Load Scenario".
....


no feedback = no bugs

 :)
Title: Re: Tutorial - code review
Post by: Yona-TYT on June 07, 2025, 09:32:54 AM
Quote from: Andarix on June 07, 2025, 08:38:15 AMno feedback = no bugs

 :)
I haven't had much time to test, I'm afraid 😞
Title: Re: Tutorial - code review
Post by: Isaac Eiland-Hall on June 07, 2025, 11:20:27 PM
Quote from: Andarix on June 07, 2025, 08:38:15 AMno feedback = no bugs

 :)

Soooo, if we shut down the forum, no more bugs! :hunts around for the delete command: ;-)
Title: Re: Tutorial - code review
Post by: Yona-TYT on June 22, 2025, 04:41:28 PM
Quote from: Andarix on May 28, 2025, 03:17:47 PMIt's possible that all the testing has caused some confusion.
I guess everything's fine here, right?.



I've started changing the label texts to unowned, so far only "class_basic_chapter.nut" has been modified, let me know if you don't have any pending changes so I can proceed with changing this in the chapters.

https://github.com/simutrans/tutorial_multipak/commit/9fe7e541ade4d1ed1c5a0e10932f4d3337e11c65
Title: Re: Tutorial - code review
Post by: Andarix on June 22, 2025, 08:12:15 PM
I have no changes at the moment.


Therefore my call to test, so that errors made by me are found.
Title: Re: Tutorial - code review
Post by: Yona-TYT on June 22, 2025, 11:12:05 PM
OK, everything's ready here: https://github.com/simutrans/tutorial_multipak/commit/ab345a29456454786206cbf204f25cfbc554e2e4#diff-f1365b7b928833dabbecebd2a68a1ff1656115951a94c469698109ec34becb0d



Quote from: Andarix on June 22, 2025, 08:12:15 PMTherefore my call to test, so that errors made by me are found.
I actually found a bug when loading a savegame in pak64.

tutorial_multipak-ch3.sve

Captura desde 2025-06-22 18-49-49.png
Title: Re: Tutorial - code review
Post by: Andarix on June 23, 2025, 06:56:29 AM
The problem is the rotation of the map.


factory_data determines the coordinates at the start of the scenario and is therefore only valid in this orientation.

The factories are also indicated in this orientation.
/**
 *  set tiles for factory
 *
 *  coord_fac_1 - ch1, ch4
 *
 *
 */
coord_fac_1 <- coord(123,160) // Timber plantation
coord_fac_2 <- coord(93,153)  // Saw mill
coord_fac_3 <- coord(110,190) // Construction Wholesaler
coord_fac_4 <- coord(168,189) // Oil rig
coord_fac_5 <- coord(149,200) // Oil refinery
coord_fac_6 <- coord(112,192) // Gas station
coord_fac_7 <- coord(131,235) // Coal mine
coord_fac_8 <- coord(130,207) // Coal power station

In this case, an entry would have to be made in all 4 map orientations in order to take the appropriate one for the determined orientation of the map.


Otherwise the error lies with Simutrans or the script environment, because the changes to the map rotation are not applied correctly.
Title: Re: Tutorial - code review
Post by: prissi on June 23, 2025, 01:00:07 PM
Theoretically, the script engine rotates internal coordinates following the rotation. Thus, the same coordinates should apply to rotated maps. It may be that this is lost when reloading.
Title: Re: Tutorial - code review
Post by: Yona-TYT on June 24, 2025, 05:02:28 AM
Quote from: prissi on June 23, 2025, 01:00:07 PMThus, the same coordinates should apply to rotated maps. It may be that this is lost when reloading.
That may be because I did rotate the map at the beginning of the tutorial.
Title: Re: Tutorial - code review
Post by: Andarix on June 25, 2025, 07:53:15 AM
The problem may lie in the sequence.

The function rename_factory_names() is executed very early and accesses the coords of the factories (coord_fac_1 ....). And these coords are only specified for the start rotation.

This means that the map would have to be rotated to the appropriate rotation when saving and then back to the rotation that was displayed when saving after loading.

Alternatively, the coords of the factories (coord_fac_1 ...) would have to be overwritten and saved.

[EDIT]

I may have a solution.
Title: Re: Tutorial - code review
Post by: Yona-TYT on June 25, 2025, 11:25:56 AM
Just like there is a "start_game()" function, maybe a function that is called every time a save is made could help?, although I don't know if this already exists (I don't think so).
Title: Re: Tutorial - code review
Post by: prissi on June 25, 2025, 11:45:43 AM
Since the map rotation is saved, and the coordinates in the script are rotated according to this, the only way to mess this up, is when the rotation indicator is manipulated or there is an error in the program.

So how to reproduce the error?
Title: Re: Tutorial - code review
Post by: Andarix on June 25, 2025, 11:51:59 AM
Quote from: Yona-TYT on June 25, 2025, 11:25:56 AMJust like there is a "start_game()" function, maybe a function that is called every time a save is made could help?, although I don't know if this already exists (I don't think so).

The question is rather what is saved from the parameters and what is not.

The coordinates are adjusted at runtime. But when loading, the initial coordinates are loaded and then not replaced by the valid ones on the map.

I currently don't know whether it is even possible to query the map orientation via script.

I also noticed now that the 0,0 coordinates of the factories are not in the dialogues but the coordinates of field 0,1. I was of the opinion that field 0,0 was in the dialogues until now.

Quote from: prissi on June 25, 2025, 11:45:43 AM...
So how to reproduce the error?

start the scenario tutorial
rotate map
save
load the save

run to chapter 3

Only the coordinates of the industries seem to be affected.
Title: Re: Tutorial - code review
Post by: Yona-TYT on June 25, 2025, 01:15:11 PM
A while ago I made a "rudimentary" function that allows you to know the current rotation, maybe this will help you?.

Note: This is already used in the tutorial


0 = North
1 = West
2 = South
3 = East
  function my_compass()
  {
    local c_max = {x = map_siz.x-1, y = map_siz.y-1}
    local c = coord(0,0)
    local text = c.tostring()

    local res_c = {x = 0, y = 0}
    local ttx = ""
    local siz = text.len()
    for(local j=0;j<siz;j++){
      local tx = format("%c",text[j])
      try {
        tx.tointeger()
      }
      catch(ev) {
        if(tx==","){
          res_c.x = ttx.tointeger()
          ttx = ""
          continue
        }
        continue
      }
      ttx+=tx
      if(j == siz-1){
        res_c.y = ttx.tointeger()
      }
    }
    //gui.add_message("Res: "+ res_c.x +" -- "+res_c.y)
    //gui.add_message("MAX: "+ c_max.x +" -- "+c_max.y)
    if(res_c.x == 0 && res_c.y == 0){
      //gui.add_message("N")
      return 0
    }
    else if(res_c.x == c_max.y && res_c.y == 0){
      //gui.add_message("W")
      return 1
    }
    else if(res_c.x == c_max.x && res_c.y == c_max.y){
      //gui.add_message("S")
      return 2
    }
    else if(res_c.x == 0 && res_c.y == c_max.x){
      //gui.add_message("E")
      return 3
    }
    return null
  }
Title: Re: Tutorial - code review
Post by: prissi on June 26, 2025, 03:35:18 AM
There is a property of the map which gets you the current rotation.

But see api_params.cc!!! Dwachs made it that all corrdinate before calls to the simutrans API will be converted to rotated coordinates.

AGAIN: The coordinates in scripts will be rotated before map access. Hence, there should be no need to rotate the parameters, unless you have managed to somehow overwrite the rotations parameter in your savegame. Which should not happen and is an error. (But can be easily restored in a debugger and then saving again.)

Rotating a map should not affect the coordinates at which an object is referred from a script, they should  stay at the same corrdinate. If not, report an error, please.
Title: Re: Tutorial - code review
Post by: Andarix on June 26, 2025, 05:29:55 AM


The function rename_factory_names() (https://github.com/simutrans/tutorial_multipak/blob/ab345a29456454786206cbf204f25cfbc554e2e4/class/class_basic_data.nut#L40) assembles the array factory_data by going through the factory list of the map and comparing the coordinates with the stored ones (coord_fac_1 - coord_fac_7).

If the map is saved rotated, the coordinates do not match at this point and the factory_data array remains empty. If, on the other hand, the map is rotated 4 times (i.e. back to the original orientation), there are no problems.


What I don't know, however, is whether the current orientation of the map is the same as when it was created.


So there is a error, but I can't localise it.
Title: Re: Tutorial - code review
Post by: prissi on June 26, 2025, 01:06:55 PM
In api_factory.cc, the factory constructor will rotate the coordinates
koord pos(x,y);
coordinate_transform_t::koord_sq2w(pos);
fabrik_t *fab =  fabrik_t::get_fab(pos);
if (!fab) {
So even after rotation, the factory coordinates would be the same. The easiest way to fix, would to load the map into simutrans running in a debugger, change the rotation field in the settings to match the coordinates and save it again. I can do that, if you tell me exactly which map needs to be rotated match what.
Title: Re: Tutorial - code review
Post by: Andarix on June 26, 2025, 04:32:44 PM
Quote from: prissi on June 26, 2025, 01:06:55 PM...
So even after rotation, the factory coordinates would be the same. The easiest way to fix, would to load the map into simutrans running in a debugger, change the rotation field in the settings to match the coordinates and save it again. I can do that, if you tell me exactly which map needs to be rotated match what.

That won't help.

This is a logic error in the script, i.e. on my part.

The coordinates are adjusted when the map is rotated. However, they do not refer to field 0.0, but move from one corner to the next.

As a result, field 0.0 becomes field 2.0. And then field 2.2 and field 0.2 as you continue to rotate.

However, as the coordinates are always compared with field 0.0, it must go wrong after rotating the map.
Title: Re: Tutorial - code review
Post by: Andarix on June 26, 2025, 06:10:41 PM
fixed

https://github.com/simutrans/tutorial_multipak/commit/378e805db6aa76a511373158a48a9c23787ebda1 (https://github.com/simutrans/tutorial_multipak/commit/378e805db6aa76a511373158a48a9c23787ebda1)
Title: Re: Tutorial - code review
Post by: Yona-TYT on June 26, 2025, 11:43:01 PM
st4_list and st3_list , they are no longer defined.
Captura desde 2025-06-26 19-41-28.png
Title: Re: Tutorial - code review
Post by: Yona-TYT on June 27, 2025, 12:38:57 AM
Electrified rails were not displaying a text label in some cases, this is fixed here: https://github.com/simutrans/tutorial_multipak/commit/4d5f8ef27f895ccf81b500847a64ab0f332fec6b
Title: Re: Tutorial - code review
Post by: Andarix on June 27, 2025, 04:58:25 AM
Quote from: Yona-TYT on June 26, 2025, 11:43:01 PMst4_list and st3_list , they are no longer defined.
...

fixed
Title: Re: Tutorial - code review
Post by: Yona-TYT on July 01, 2025, 01:45:34 PM
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
Title: Re: Tutorial - code review
Post by: Yona-TYT on July 01, 2025, 02:49:53 PM
Other undefined variables here:

Fix here: https://github.com/simutrans/tutorial_multipak/commit/3b4e74fb305d798dd17b81fd4b8edc18bb0c1233

Captura desde 2025-06-26 19-41-28.png
Title: Re: Tutorial - code review
Post by: Andarix on July 03, 2025, 09:55:31 PM
fixed
Title: Re: Tutorial - code review
Post by: Yona-TYT on July 24, 2025, 12:49:57 AM
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
Title: Re: Tutorial - code review
Post by: Andarix on July 24, 2025, 03:24:12 PM
I changed the coordinates. But now the track can no longer be built on the slope.
Title: Re: Tutorial - code review
Post by: Yona-TYT on July 24, 2025, 06:00:50 PM
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.
Title: Re: Tutorial - code review
Post by: prissi on January 02, 2026, 08:38:47 AM
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.
Title: Re: Tutorial - code review
Post by: Andarix on January 02, 2026, 10:07:46 AM
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?
Title: Re: Tutorial - code review
Post by: Andarix on January 02, 2026, 01:04:43 PM
for testing


Please not click button Tutorial.


translate page (https://simutrans-germany.com/translator_page/scenarios/scenario_5/)
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 (https://forum.simutrans.com/index.php/topic,23513.msg211829/topicseen.html#msg211829)
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 03, 2026, 06:04:11 AM
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
Title: Re: Tutorial - code review
Post by: Andarix on January 03, 2026, 09:36:38 AM
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.
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 03, 2026, 11:52:22 AM
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.
Title: Re: Tutorial - code review
Post by: Andarix on January 03, 2026, 11:56:27 AM
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.
Title: Re: Tutorial - code review
Post by: Andarix on January 03, 2026, 01:38:57 PM
change the automatic step jump

https://github.com/simutrans/tutorial_multipak/commit/d4c3d02703c8d1c4bc70111b9ac83ee7f9fc3881 (https://github.com/simutrans/tutorial_multipak/commit/d4c3d02703c8d1c4bc70111b9ac83ee7f9fc3881)
Title: Re: Tutorial - code review
Post by: Andarix on January 03, 2026, 02:25:56 PM
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 (https://github.com/simutrans/tutorial_multipak/commit/584133381838a4eb7fcb8220659e65d6681784c2)
Title: Re: Tutorial - code review
Post by: Andarix on January 03, 2026, 05:41:57 PM
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 (https://github.com/simutrans/tutorial_multipak/commit/34e076f23535c25e5064bf2e51b7d87bf1e8ccb3)
Title: Re: Tutorial - code review
Post by: Andarix on January 03, 2026, 08:39:10 PM
chapter 5 step D

Bug create ship schedule

Error message: Only road schedules allowed

[EDIT]

fixed https://github.com/simutrans/tutorial_multipak/commit/c9c54dbe52ccd947b011b1dad94da3dd294226cf
Title: Re: Tutorial - code review v2.0.02 Test
Post by: Andarix on January 04, 2026, 10:36:13 AM
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.




Please not click button Tutorial.


translate page (https://simutrans-germany.com/translator_page/scenarios/scenario_5/)
Important: Do not change the text within { } or these brackets.




new version (https://forum.simutrans.com/index.php?msg=211898)
Title: Re: Tutorial - code review
Post by: Andarix on January 05, 2026, 09:27:05 AM
change text chapter 3 step E

https://github.com/simutrans/tutorial_multipak/commit/f39b5b26c1d15a3a9671a09c91d448dc74f004df (https://github.com/simutrans/tutorial_multipak/commit/f39b5b26c1d15a3a9671a09c91d448dc74f004df)

please check the text (https://simutrans-germany.com/translator_page/scenarios/scenario_5/index.php?obj_id=88412&lang=de&ref_lang=none&trans_lang=de,en,es)



change text chapter 3 step G

https://github.com/simutrans/tutorial_multipak/commit/bdfd1c7f31b9a8c417dbfd390599f4c344f095b9 (https://github.com/simutrans/tutorial_multipak/commit/bdfd1c7f31b9a8c417dbfd390599f4c344f095b9)

please check the text (https://simutrans-germany.com/translator_page/scenarios/scenario_5/index.php?obj_id=88413&lang=de&ref_lang=none&trans_lang=de,en,es)
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 06, 2026, 03:01:07 AM
Simutrans 124.3.1 r11671 did not have this problem, so I suspect that something has broken in the Simutrans code recently.
simscr07.png
Title: Re: Tutorial - code review
Post by: prissi on January 06, 2026, 04:43:34 AM
Bridges now require two clicks or dragging. I will investigate. But without setting the flag it works most of the time.
Title: Re: Tutorial - code review
Post by: prissi on January 06, 2026, 04:44:30 AM
Which branch is the code to test?
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 06, 2026, 06:42:37 AM
Quote from: prissi on January 06, 2026, 04:44:30 AMWhich branch is the code to test?
https://github.com/simutrans/tutorial_multipak/tree/code_review
Title: Re: Tutorial - code review
Post by: Andarix on January 06, 2026, 08:04:10 AM
Quote from: Yona-TYT on January 06, 2026, 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.
Title: Re: Tutorial - code review
Post by: Andarix on January 06, 2026, 08:55:58 AM
Quote from: Yona-TYT on January 06, 2026, 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 (https://github.com/simutrans/tutorial_multipak/commit/99fac8b54c2e9bf694b1b6c58a819ea1cc66953b)
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 06, 2026, 05:25:23 PM
Quote from: Andarix on January 06, 2026, 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.
Title: Re: Tutorial - code review
Post by: Andarix on January 06, 2026, 09:50:20 PM
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 (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.
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 07, 2026, 03:18:21 AM
Quote from: Andarix on January 06, 2026, 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])"
Title: Re: Tutorial - code review v2.0.03 Test
Post by: Andarix on January 08, 2026, 05:40:30 PM
new test version

I changed chapter 4 step F passenger ship schedule. Add the Oil rigg.

Defining the number of convoys for the connections is now possible in the class_basic_coords_xxx.


For pak64.german and pak128 change the data in set_data.nut.




Please not click button Tutorial.


translate page (https://simutrans-germany.com/translator_page/scenarios/scenario_5/)
Important: Do not change the text within { } or these brackets.

[EDIT]

new version in a more recent post
Title: Re: Tutorial - code review
Post by: Andarix on January 10, 2026, 02:38:06 PM
It's strange.

The current code from the repo (tutorial_multipak-code_review.zip) works. If I modify chapter 2 (class_chapter_02.nut), then chapter 2 works correctly. But in chapter 3, the first train (step E) is broken.

As a player, I can't start it.
The train isn't even created using automatic steps.

[EDIT]

remove obsolet files
Title: Re: Tutorial - code review
Post by: Andarix on January 10, 2026, 05:22:53 PM
Chapter 3 has a bug with the timetables.

If the passenger train timetable is changed, it is then saved for the first timber train.

[EDIT]

I think fixed
Title: Re: Tutorial - code review
Post by: Andarix on January 10, 2026, 08:57:56 PM
change chapter 6 step B

https://github.com/simutrans/tutorial_multipak/commit/4e820c5db98c840826a94af8247647bbcde0adc8 (https://github.com/simutrans/tutorial_multipak/commit/4e820c5db98c840826a94af8247647bbcde0adc8)

please check the text (https://simutrans-germany.com/translator_page/scenarios/scenario_5/index.php?obj_id=88465&lang=de&ref_lang=de&trans_lang=de,en,es)

[EDIT]

schedule feedback to text fixed

https://github.com/simutrans/tutorial_multipak/commit/1014074995b80491c9af772e7297dbea1dd5f660 (https://github.com/simutrans/tutorial_multipak/commit/1014074995b80491c9af772e7297dbea1dd5f660)
Title: Re: Tutorial - code review
Post by: Andarix on January 10, 2026, 09:42:35 PM
chapter 2 step D

chapter_02/goal_step_04.txt (https://simutrans-germany.com/translator_page/scenarios/scenario_5/index.php?obj_id=&lang=de&ref_lang=none&trans_lang=de,en,es)


The text about following the convoy is incorrect at this point.

Following vehicles is described again in Chapter 2, Step G 4/4.

chapter_02/07_4-4.txt (https://simutrans-germany.com/translator_page/scenarios/scenario_5/index.php?obj_id=117549&lang=de&ref_lang=none&trans_lang=de,en,es)
Title: Re: Tutorial - code review
Post by: Andarix on January 11, 2026, 12:38:57 PM
new test version

I add img icons to the text files (chapter 1 and 2). Please check this.




For pak64.german and pak128 change the data in set_data.nut.


Please not click button Tutorial.


translate page (https://simutrans-germany.com/translator_page/scenarios/scenario_5/)
Important: Do not change the text within { } or these brackets.


Title: Re: Tutorial - code review
Post by: Yona-TYT on January 11, 2026, 07:27:32 PM
Quote from: Andarix on January 11, 2026, 12:38:57 PMnew test version

I add img icons to the text files (chapter 1 and 2). Please check this.



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

For pak64.german and pak128 change the data in set_data.nut.


Please not click button Tutorial.


translate page (https://simutrans-germany.com/translator_page/scenarios/scenario_5/)
Important: Do not change the text within { } or these brackets.



simscr08.png
Title: Re: Tutorial - code review
Post by: Andarix on January 11, 2026, 07:40:26 PM
https://github.com/simutrans/tutorial_multipak/commit/b338cc55bdfe861957a99e6b3e35a6e850b9c89b (https://github.com/simutrans/tutorial_multipak/commit/b338cc55bdfe861957a99e6b3e35a6e850b9c89b)

reupload

I had actually corrected it and re-uploaded it. Apparently, however, the file wasn't updated in the archive.
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 11, 2026, 08:42:12 PM
Excellent work! The tool and menu icons look great; implementing this was a good idea.  8)
 simscr00.png
Title: Re: Tutorial - code review
Post by: prissi on January 12, 2026, 02:31:06 AM
Some testing (in English):
1) before building depot: When building a road (by pressing 's' in pak64), I cannot proceed as I cannot build anything. Only by selecting from the toolbar I can proceed. (Contrary to the text, any road seems to work, even the 40 km/h gavel road.)
2) The line step does not mention (in English) that one can copy the convoi. Also it is unclear in which window the new line is to be created.
3) Heap buffer overflow (with address sanitizer) when selecting the last stop in the schedule for the connenction. Error originat from a call from is too allowed 4108 with param = "D\td\x1\x1\x4セセ@Kr\x5\b\x5セセ\x2\x3" I guess so output is generated from this function which is forbidden. Same if jumoping to this step and click on the bus and then on its schedule.
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 12, 2026, 12:35:06 PM
Quote2) The line step does not mention (in English) that one can copy the convoi. Also it is unclear in which window the new line is to be created.


For simple vehicles like buses (without trailers, wagons, etc.), I didn't see it as a priority to suggest the copy button at this stage of the tutorial. I thought it was more convenient to use it in Chapter 3, where you have to assemble a passenger train, where this action considerably increases its complexity and using the copy button becomes more indispensable.
Title: Re: Tutorial - code review
Post by: Andarix on January 12, 2026, 02:50:25 PM
Quote from: prissi on January 12, 2026, 02:31:06 AMSome testing (in English):
1) before building depot: When building a road (by pressing 's' in pak64), I cannot proceed as I cannot build anything. Only by selecting from the toolbar I can proceed. (Contrary to the text, any road seems to work, even the 40 km/h gavel road.)
...

Any road has always worked because there's no test for it. The same applies to railway tracks.

If I remember correctly, I already suggested years ago that such information be omitted from the text. That's why there are no speed specifications in the German text.

Include speeds in the text because the tutorial would have to be updated every time the package set was changed. Especially since the text no longer applies to a single package set, it should be as independent of the package set as possible.

I haven't changed the English text because my language skills aren't sufficient.

[EDIT]

The tool ID of the button is checked. If the command is issued via keyboard, the tool ID will differ.

Quote from: prissi on January 12, 2026, 02:31:06 AM...
3) Heap buffer overflow (with address sanitizer) when selecting the last stop in the schedule for the connenction. Error originat from a call from is too allowed 4108 with param = "D\td\x1\x1\x4セセ@Kr\x5\b\x5セセ\x2\x3" I guess so output is generated from this function which is forbidden. Same if jumoping to this step and click on the bus and then on its schedule.

Could you please post a screenshot of the error message?

The text is unreadable here.
Title: Re: Tutorial - code review
Post by: Andarix on January 12, 2026, 04:06:29 PM
Quote from: Andarix on January 12, 2026, 02:50:25 PM...
[EDIT]

The tool ID of the button is checked. If the command is issued via keyboard, the tool ID will differ.
...

The idea is correct, but the value is wrong.

The `tool_id` is correct. Only the object name is passed differently.

The name is passed via the button.
The value 1 is passed via the key "s".

Screenshot 2026-01-12 165907.png


Docu function
is_work_allowed_here() (https://doc.simutrans-germany.com/Simutrans-Squirrel-API/group__quick__return__func.html#ga4e79ca4788f47895ceedbd72d518bd0e)

The description doesn't seem to be entirely correct either. There, "name" is defined as "coord3d".

I think this is a simutrans bug, not a tutorial bug.
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 13, 2026, 12:39:32 AM
Quote from: Andarix on January 12, 2026, 04:06:29 PMThe idea is correct, but the value is wrong.

The `tool_id` is correct. Only the object name is passed differently.

The name is passed via the button.
The value 1 is passed via the key "s".

There is certainly a strange discrepancy here with the id_name, even though the road is exactly the same.


This bug on the bridge leaves the tutorial stuck.
simscr00.png
Title: Re: Tutorial - code review
Post by: prissi on January 13, 2026, 02:19:15 PM
The bridge bug has been fixed.

The heap overflow happened when checking for the schedule tool in _ia_allowed_tool, the string is the corrdinates for the schedule entry. There is not script message, Simutrans itself has an internal memory error during allocation. The normal executable will write garbage at some memory location but does not crash. Anyway, in today's version I could no longer reproduce it.

Now another text error in airport step D: "Connect the city of Pollingville with airport {sch2} with four busses"
Title: Re: Tutorial - code review
Post by: Andarix on January 13, 2026, 03:04:58 PM
Quote from: prissi on January 13, 2026, 02:19:15 PM...
Now another text error in airport step D: "Connect the city of Pollingville with airport {sch2} with four busses"

fixed
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 13, 2026, 06:08:05 PM
QuoteThe idea is correct, but the value is wrong.

The `tool_id` is correct. Only the object name is passed differently.

The name is passed via the button.
The value 1 is passed via the key "s".
Wait a minute, is the value 1 the value of the system type? If this is true, then it's easy to solve this on the script side.
Title: Re: Tutorial - code review
Post by: Andarix on January 13, 2026, 07:13:36 PM
Quote from: Yona-TYT on January 13, 2026, 06:08:05 PMWait a minute, is the value 1 the value of the system type? If this is true, then it's easy to solve this on the script side.

I think is the waytype. Track (key t) is 2.

It's certainly easy to intercept in the tutorial script.

But according to the documentation, the object name is the parameter to be passed, not the waytype.

Then there are also `e` and `l` currently available in pak64.



I'd be more interested in why the first train breaks down in Chapter 3 when I change Chapter 2.
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 13, 2026, 09:02:35 PM
Quote from: Andarix on January 13, 2026, 07:13:36 PMI'd be more interested in why the first train breaks down in Chapter 3 when I change Chapter 2.
Okay, I'm going to review this now.

Edit.
The first train in CH3 works fine here, maybe it's only failing in pak64.german?.
Title: Re: Tutorial - code review
Post by: Andarix on January 13, 2026, 09:47:42 PM
Quote from: Yona-TYT on January 13, 2026, 09:02:35 PMOkay, I'm going to review this now.

Edit.
The first train in CH3 works fine here, maybe it's only failing in pak64.german?.

The current code certainly works. However, since I know the changes will cause errors, I won't be posting such code to the repository.

see this post (https://forum.simutrans.com/index.php?msg=211905)

Title: Re: Tutorial - code review
Post by: Yona-TYT on January 13, 2026, 09:48:26 PM
I'm using the latest night of simutrans, the latest version of pak64.german (the link in the install guide), and the latest changes in the tutorial, but it says the savegame is incompatible.

Screenshot_2026-01-13_17-45-42.png
Title: Re: Tutorial - code review
Post by: Andarix on January 13, 2026, 09:53:45 PM
Changed set_data.nut?

The repository is set to pak64. Consequently, the wrong sve will be loaded if the settings are not changed.
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 13, 2026, 09:57:45 PM
Yeah, This is how it is at the moment.

Screenshot_2026-01-13_17-55-38.png
Title: Re: Tutorial - code review
Post by: Andarix on January 13, 2026, 10:04:18 PM
The only thing is that the sve file tutorial64g.sve is still commented out.
Title: Re: Tutorial - code review
Post by: Andarix on January 13, 2026, 10:07:39 PM
Quote from: Andarix on January 13, 2026, 09:47:42 PMThe current code certainly works. However, since I know the changes will cause errors, I won't be posting such code to the repository.

see this post (https://forum.simutrans.com/index.php?msg=211905)



Oddly enough, these changes have no negative effects from Chapter 3 onwards.

class/class_chapter_02.nut | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/class/class_chapter_02.nut b/class/class_chapter_02.nut
index 821d2e1..f63334d 100644
--- a/class/class_chapter_02.nut
+++ b/class/class_chapter_02.nut
@@ -106,12 +106,12 @@ class tutorial.chapter_02 extends basic_chapter
     if(this.step == 4){
       local c_dep = this.my_tile(city1_road_depot)
       local c_list = city1_halt_1
-      start_sch_tmpsw(pl,c_dep, c_list)
+      start_sch_tmpsw(pl, c_dep, c_list)
     }
     else if(this.step == 6){
       local c_dep = this.my_tile(city1_road_depot)
       local c_list = city1_halt_2
-      start_sch_tmpsw(pl,c_dep, c_list)
+      start_sch_tmpsw(pl, c_dep, c_list)
     }
     else if(this.step == 7){
       local c_dep = this.my_tile(city1_road_depot)
@@ -153,8 +153,9 @@ class tutorial.chapter_02 extends basic_chapter
         break
       case 4:
         //local c = coord(city1_halt_1[0].x, city1_halt_1[0].y)
-        local tile = my_tile(city1_halt_1[0])
-        text.stnam = "1) "+tile.get_halt().get_name()+" ("+city1_halt_1[0].tostring()+")"
+        local halt_to_waiting = get_waiting_halt(1)
+        local tile = my_tile(city1_halt_1[halt_to_waiting])
+        text.stnam = (halt_to_waiting+1) + ") "+tile.get_halt().get_name()+" ("+city1_halt_1[halt_to_waiting].tostring()+")"
 
         text.list = create_schedule_list(city1_halt_1)
         text.nr = city1_halt_1.len()
@@ -180,10 +181,10 @@ class tutorial.chapter_02 extends basic_chapter
         }
         text.list = create_schedule_list(city1_halt_2)
 
-        local tile = my_tile(city1_halt_2[0])
-        text.stnam = ""+tile.get_halt().get_name()+" ("+city1_halt_2[0].tostring()+")"
+        local tile = my_tile(city1_halt_2[get_waiting_halt(2)])
+        text.stnam = ""+tile.get_halt().get_name()+" ("+city1_halt_2[get_waiting_halt(2)].tostring()+")"
 
-        local halt = my_tile(city1_halt_2[0]).get_halt()
+        local halt = my_tile(city1_halt_2[get_waiting_halt(2)]).get_halt()
         text.line = get_line_name(halt)
 
         text.cir = cov_nr
@@ -882,7 +883,7 @@ class tutorial.chapter_02 extends basic_chapter
     local nr = schedule.entries.len()
     switch (this.step) {
       case 4:
-        local selc = 0
+        local selc = get_waiting_halt(1)
         local load = veh1_load
         local time = veh1_wait
         local c_list = city1_halt_1
@@ -895,7 +896,7 @@ class tutorial.chapter_02 extends basic_chapter
         return result
       break
       case 6:
-        local selc = 0
+        local selc = get_waiting_halt(2)
         local load = veh1_load
         local time = veh1_wait
         local c_list = city1_halt_2
@@ -910,7 +911,7 @@ class tutorial.chapter_02 extends basic_chapter
         local load = veh1_load
         local time = veh1_wait
         local c_list = city2_halt_1
-        local selc = c_list.len()-1
+        local selc = get_waiting_halt(3)
         result = compare_schedule(result, pl, schedule, selc, load, time, c_list, true)
         if(result == null){
           local line_name = line3_name //"Test 3"
@@ -939,7 +940,7 @@ class tutorial.chapter_02 extends basic_chapter
             reset_tmpsw()
             return bus_result_message(result, translate(name), veh, cov)
           }
-          local selc = 0
+          local selc = get_waiting_halt(1)
           local load = veh1_load
           local time = veh1_wait
           local c_list = city1_halt_1
@@ -958,13 +959,13 @@ class tutorial.chapter_02 extends basic_chapter
           local good_list = [good_desc_x (good_alias.passa).get_catg_index()]    //Passengers
           local name = veh1_obj
           local st_tile = 1
-          result = is_convoy_correct(depot,cov,veh,good_list,name, st_tile)
+          result = is_convoy_correct(depot, cov, veh, good_list, name, st_tile)
           if (result!=null){
             reset_tmpsw()
             return bus_result_message(result, translate(name), veh, cov)
           }
 
-          local selc = 0
+          local selc = get_waiting_halt(2)
           local load = veh1_load
           local time = veh1_wait
           local c_list = city1_halt_2
@@ -1072,7 +1073,7 @@ class tutorial.chapter_02 extends basic_chapter
           local wait = veh1_wait
           local sch_siz = c_list.len()
           for(local j=0;j<sch_siz;j++){
-            if (j==0)
+            if (j==get_waiting_halt(1))
               sched.entries.append(schedule_entry_x(my_tile(c_list[j]), load, wait))
             else
               sched.entries.append(schedule_entry_x(my_tile(c_list[j]), 0, 0))
@@ -1123,7 +1124,7 @@ class tutorial.chapter_02 extends basic_chapter
           local time = veh1_wait
           local sched = schedule_x(gl_wt, [])
           for(local i=0;i<sch_siz;i++){
-            if (i==0)
+            if (i==get_waiting_halt(2))
               sched.entries.append(schedule_entry_x(my_tile(c_list[i]), load, time))
             else
               sched.entries.append(schedule_entry_x(my_tile(c_list[i]), 0, 0))
@@ -1175,7 +1176,7 @@ class tutorial.chapter_02 extends basic_chapter
           local c_list = city2_halt_1
           local sch_siz = c_list.len()
           for(local j=0;j<sch_siz;j++){
-            if (j==sch_siz-1)
+            if (j==get_waiting_halt(3))
               sched.entries.append(schedule_entry_x(my_tile(c_list[j]), load, wait))
             else
               sched.entries.append(schedule_entry_x(my_tile(c_list[j]), 0, 0))

Title: Re: Tutorial - code review
Post by: Yona-TYT on January 13, 2026, 10:14:46 PM
Quote from: Andarix on January 10, 2026, 02:38:06 PMIt's strange.

The current code from the repo (tutorial_multipak-code_review.zip) works. If I modify chapter 2 (class_chapter_02.nut), then chapter 2 works correctly. But in chapter 3, the first train (step E) is broken.

As a player, I can't start it.
The train isn't even created using automatic steps.
This relates to the logic used to determine the number of vehicles and whether their IDs are valid. If you look at the garage, there's a vehicle that was probably created too many and never started.

I need to investigate this further. Tell me, what exactly did you modify in CH2?.
Screenshot_2026-01-13_18-14-26.png
Title: Re: Tutorial - code review
Post by: Andarix on January 13, 2026, 10:22:39 PM
Quote from: Yona-TYT on January 13, 2026, 10:14:46 PMThis relates to the logic used to determine the number of vehicles and whether their IDs are valid. If you look at the garage, there's a vehicle that was probably created too many and never started.
...

Then, apparently, the wrong depot is queried in Chapter 3.

Quote...
I need to investigate this further. Tell me, what exactly did you modify in CH2?.
...

In the post before her post.
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 13, 2026, 10:27:10 PM
Quote from: Andarix on January 13, 2026, 10:22:39 PMThen, apparently, the wrong depot is queried in Chapter 3.

In the post before her post.

I realized that using the automated script, the last vehicle in chapter 2 is created correctly, but for some reason it doesn't start from the depot, so the problem is in chapter 2, not chapter 3.

Edit.
Confirmed, creating and starting the vehicle manually works fine, the problem is in the automated script logic for the vehicle in chapter 2, step G.
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 13, 2026, 10:38:04 PM
Quote from: Yona-TYT on January 13, 2026, 10:27:10 PMI realized that using the automated script, the last vehicle in chapter 2 is created correctly, but for some reason it doesn't start from the depot, so the problem is in chapter 2, not chapter 3.

Edit.
Confirmed, creating and starting the vehicle manually works fine, the problem is in the automated script logic for the vehicle in chapter 2, step G.
That's why the script advances when starting vehicles are done using conditionals like this
if (cov_valid && current_cov == ch2_cov_lim1.b){ pot2=1 }
, which prevents the script from advancing when a vehicle fails to start.

Edit.
I have an idea: to do a "follow vehicle" using a command. Is this implemented?.

Edit.

          for(local j=0;j<sch_siz;j++){
            if (j==get_waiting_halt(3))
              sched.entries.append(schedule_entry_x(my_tile(c_list[j]), load, wait))
            else
              sched.entries.append(schedule_entry_x(my_tile(c_list[j]), 0, 0))
          }

I can trace the problem so far, the construction of the schedule is wrong, "get_waiting_halt(3)" is 0, but the value of that condition is required to be the total size of the list (len - 1), since the stop to which the values ��are applied is the last stop of the list.


Edit.

Applying the following patch "https://forum.simutrans.com/index.php/topic,23781.msg211954.html#msg211954", everything would look like this: class_chapter_02.nut
Title: Re: Tutorial - code review
Post by: Andarix on January 14, 2026, 08:44:48 AM
Quote from: Yona-TYT on January 13, 2026, 10:38:04 PM...
I can trace the problem so far, the construction of the schedule is wrong, "get_waiting_halt(3)" is 0, but the value of that condition is required to be the total size of the list (len - 1), since the stop to which the values ��are applied is the last stop of the list.

...

Thank you for your help.

I had changed the code to get_waiting_halt(3) in a few places.
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 14, 2026, 01:46:06 PM
Here's a small modification to use the new vehicle tracking method:
https://github.com/simutrans/tutorial_multipak/pull/42

If there are no problems, I can integrate it.
Title: Re: Tutorial - code review
Post by: Andarix on January 14, 2026, 10:52:50 PM
is merged
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 15, 2026, 10:16:39 AM
I'm tempted to update the minimum version of simutrans for the tutorial " simu_version <- "124.2.3""
Title: Re: Tutorial - code review
Post by: Andarix on January 15, 2026, 11:38:48 AM
Quote from: Yona-TYT on January 15, 2026, 10:16:39 AMI'm tempted to update the minimum version of simutrans for the tutorial " simu_version <- "124.2.3""

124.3.2

Since this includes all nightly builds that have been released since the initial release, it makes little sense.

The audit would therefore also have to check the revision number (r11871).
Title: Re: Tutorial - code review
Post by: prissi on January 15, 2026, 12:53:50 PM
I think next version should be 123.4, as many changes (with multitile city buildings, maintenance cost of signals, or the powerline flags) warrant a bump of pakset versions too.
Title: Re: Tutorial - code review
Post by: Yona-TYT on January 16, 2026, 11:38:40 AM
I'm stuck here; it seems the time and load values don't match the ones mentioned.
simscr01.png
Title: Re: Tutorial - code review
Post by: Andarix on January 16, 2026, 12:18:46 PM
What confuses me is that the line is being renamed.

And there is another error. If the stops are built automatically, the stop check for the timetable does not work.
Title: Re: Tutorial - code review
Post by: Andarix on January 16, 2026, 01:07:26 PM
fixed

https://github.com/simutrans/tutorial_multipak/commit/f10988855b91db6b042429261884ff5a21a90711 (https://github.com/simutrans/tutorial_multipak/commit/f10988855b91db6b042429261884ff5a21a90711)

incorrect station defined in the text