News:

SimuTranslator
Make Simutrans speak your language.

squirrel script - factory_production_x::max_storage

Started by Andarix, October 09, 2026, 02:24:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andarix

factory_production_x::max_storage

`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



victor_18993

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.
En la vida todo son vivencias y cada una de ellas nos hace mas grandes,¿Como de grande eres tu? :)