The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: Andarix on October 09, 2026, 02:24:20 PM

Title: squirrel script - factory_production_x::max_storage
Post by: Andarix on October 09, 2026, 02:24:20 PM
factory_production_x::max_storage (https://doc.simutrans-germany.com/Simutrans-Squirrel-API/classfactory__production__x.html#a691bbd62d08a6c3c5d3a0ba1877579f5)

`max_storage` is supposed to return the storage capacity for the goods. However, it returns 0 after the map loads.

If the AI players are deactivated and then reactivated, the correct values are returned.


    local dest_count_in = []
    local dest_capacity = null
    local j = 0
    foreach(good, islot in f_dest.input) {

      if ( good == freight ) {
        dest_count_in = islot.get_storage()
        dest_capacity = islot.max_storage

        local fs = f_dest.get_tile_list()
        gui.add_message_at(our_player, "### " + f_dest.get_name() + " - " + coord_to_string(fs[0]) + " # " + good + " # dest_capacity " + dest_capacity, fs[0])
      }
    }

    local input_ = abs((dest_capacity/100)*40)
      gui.add_message_at(our_player, "### input_ " + input_ + " # dest_count_in[0] " + dest_count_in[0], world.get_time())

messages (newest at the top)
Quote### input_ 0 # dest_count_in
  • 0
### Papierfabrik - 665,157 # Holz # dest_capacity 0
### Papierfabrik - 665,157 # Holz # src_count_in 11525
### input_ 0 # dest_count_in
  • 164
### Druckerei - 512,55 # Papier # dest_capacity 0
### input_ 0 # dest_count_in
  • 137
### Brauerei - 714,376 # Hopfen # dest_capacity 0
### input_ 0 # dest_count_in
  • 1071
### Chemiewerk - 589,1 # Oel # dest_capacity 0
...

save load
...

### input_ 880 # dest_count_in
  • 1153
### Chemiewerk - 589,1 # Oel # dest_capacity 2222
Der Verkehr in Möglingen nimmt zu: 1202 waren bei der Eröffnung von Kino.
Runk & Strunk Transports erhöht die Fahrzeugzahl der Linie: Straße Erdöl Meckenheim Ölfeld Betriebshof - Cuxhaven Ölkraftwerk Betriebshof
### input_ 520 # dest_count_in
  • 0
### Ölkraftwerk - 597,477 # Oel # dest_capacity 1357
Runk & Strunk Transports reduziert die Fahrzeugzahl der Linie: Straße Flaschenbier Weißenburg Zweig H - Weißenburg Getränkehandel Betriebshof


Title: Re: squirrel script - factory_production_x::max_storage
Post by: victor_18993 on October 12, 2026, 05:58:17 PM
Thanks for the report!

I was able to reproduce it and confirm that it was a real load-order bug.

After loading a savegame, scripted AI data was restored before factories had finished rebuilding their storage capacities, so `max_storage` could stay at 0. Restarting the AI rebuilt those script objects later, which is why the correct values came back.

This has now been fixed in trunk r12338 and is already included in the current Nightly.

Thanks again — the report made the cause much easier to track down.