How to display waiting cargo in industry window?
Moderator: Graphics Moderators
How to display waiting cargo in industry window?
I'm working on an industry NewGRF with features related to "stockpiled industries".
In the industry window, I would like to show how much incoming cargo is waiting, as highlighted in red in the attached screenshot, which was taken from a game with BPSI v2.13
Unfortunately, this NewGRF was written in NFO which is something I don't understand and don't have time to dig into.
Does anybody have a good code example in NML how to achieve the same thing to share here, as I looked at a number of other NML-coded NewGRFs and could not find anythig similar to what I have in mind.
The main problem I have is to display more than one "dynamic value" (one that changes)
In the industry window, I would like to show how much incoming cargo is waiting, as highlighted in red in the attached screenshot, which was taken from a game with BPSI v2.13
Unfortunately, this NewGRF was written in NFO which is something I don't understand and don't have time to dig into.
Does anybody have a good code example in NML how to achieve the same thing to share here, as I looked at a number of other NML-coded NewGRFs and could not find anythig similar to what I have in mind.
The main problem I have is to display more than one "dynamic value" (one that changes)
Re: How to display waiting cargo in industry window?
Your industry has to use a produce block to handle cargo processing. The text will automatically appear.
Printing dynamic values in a custom text (eg the "production rate 4%" in the example image) is achieved by using string codes to print values packed into the text stack.
Printing dynamic values in a custom text (eg the "production rate 4%" in the example image) is achieved by using string codes to print values packed into the text stack.
Re: How to display waiting cargo in industry window?
But only and exclusively when using a "produce" block, right?!?PikkaBird wrote: 30 Aug 2024 20:50 Your industry has to use a produce block to handle cargo processing. The text will automatically appear.
Not with a statement like
Code: Select all
cargo_types: [accept_cargo("AORE"), accept_cargo("SCMT"), accept_cargo("ACID"), produce_cargo("ALUM",2), produce_cargo("SLAG",1)];

Any other ways to make the text "disappear" when using "produce" by messing around with some additional code?!?
Re: How to display waiting cargo in industry window?
Additional question: The text stack starts at "storage position" 256 and if you want to display more than one value, you will just go on with 257 and further, putting more than one variable in the string code?!?PikkaBird wrote: 30 Aug 2024 20:50 Printing dynamic values in a custom text (eg the "production rate 4%" in the example image) is achieved by using string codes to print values packed into the text stack.
Re: How to display waiting cargo in industry window?
If you're using that method (which is how the base game industries work), nothing is ever waiting, as incoming cargos are processed immediately. If you want, eg, the industry to not produce anything until all input cargos are present, you need to use a produce block.ebla71 wrote: 30 Aug 2024 21:16 Not with a statement like
That was driving me mad why the second way to produce cargo did not show the expected textCode: Select all
cargo_types: [accept_cargo("AORE"), accept_cargo("SCMT"), accept_cargo("ACID"), produce_cargo("ALUM",2), produce_cargo("SLAG",1)];
![]()
Yes, although it also depends on the size of the "string parameter" you're using. Each storage is 4 bytes, so if you use {COMMA}, {COMMA} it will fill with the values from storage 256 then 257. But if you use {SIGNED_WORD}, {SIGNED_WORD}, it will use the low two, then the high two, bytes from 256, and you have to arithmetically pack the two values into the one storage. There are examples on the spec page.Additional question: The text stack starts at "storage position" 256 and if you want to display more than one value, you will just go on with 257 and further, putting more than one variable in the string code?!?
Re: How to display waiting cargo in industry window?
Yes, I know.PikkaBird wrote: 31 Aug 2024 05:19 If you're using that method (which is how the base game industries work), nothing is ever waiting, as incoming cargos are processed immediately. If you want, eg, the industry to not produce anything until all input cargos are present, you need to use a produce block.
But the decision in the code to display the waiting cargo (or not) is based on the presence of the "produce" block and not whether something is waiting or not, right? That was want confused me so much, as it does not really seem to be documented.
Since when I simply don't deliver anything to an industry in a NewGRF with "produce", waiting cargo is still shown (as zero).
- 2TallTyler
- Director
- Posts: 570
- Joined: 11 Aug 2019 18:15
- Contact:
Re: How to display waiting cargo in industry window?
If either of the production callbacks are used, the stockpile amount is drawn. You can manually hide this text with the 'cargo_subtype_display' callback. Here's an example of how to do that, in the Bank in Improved Town Industries.
I also use procedures (switches which act like functions) to construct the text stack. Take a look at an example function, then see the corresponding string to see how I've aligned the string with the registers. Each register is a word, which is two bytes. The {SKIP} string code skips a single byte.
Here is an example industry that uses this string, as well as custom production code.
Note that I start the text stack at register 257 (I forget why, I wrote this code a while ago!).
I also use procedures (switches which act like functions) to construct the text stack. Take a look at an example function, then see the corresponding string to see how I've aligned the string with the registers. Each register is a word, which is two bytes. The {SKIP} string code skips a single byte.
Here is an example industry that uses this string, as well as custom production code.
Note that I start the text stack at register 257 (I forget why, I wrote this code a while ago!).
Re: How to display waiting cargo in industry window?
Ah, now the mystery slowly clears up2TallTyler wrote: 31 Aug 2024 13:38 If either of the production callbacks are used, the stockpile amount is drawn. You can manually hide this text with the 'cargo_subtype_display' callback.

Yes, there was the "cargo_subtype_display" callback in the example code that I used which explains why there was not text on waiting cargo although "produce" was used.
Thanks to everybody who contributed with explanations, now it is clear to me.
Who is online
Users browsing this forum: No registered users and 0 guests