Some questions on limits of industry NewGRF

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

ebla71
Transport Coordinator
Transport Coordinator
Posts: 346
Joined: 14 Apr 2021 21:48
Location: Earth

Some questions on limits of industry NewGRF

Post by ebla71 »

After mostly playing OTTD and a scenario released, I recently went on to explore some ideas I have about an industry NewGRF and was pleased to find that nmlc works as a stand-alone tool on Windows without the need for any further compiler or development environment.

I mostly analyzed OTIS version 5 for inspiration, since I like the idea to have only one tile for each industry and then build the rest around it based on another graphics-only NewGRF.

However, there are some questions I did not manage to answer from looking at the above *.nml file and the available documentation:

:arrow: Industry IDs can be in the range of 0 to 127 but do the IDs have to be continuous, or can there be "gaps"?
:arrow: Cargo IDs can be in the range of 0 to 63 but it is mentioned that IDs 0 to 11 are for "standard cargos"
- Can I still re-define these without detrimental effects?
- Is there a list of what these IDs are normally assigned?
:arrow: As far as I understand, industries can somehow "sense" the environment in which they are supposed to be built, like only on water.
- Is it also possible to "sense" if there is a certain type of station or "track" tile nearby?
- For example, I want a certain industry to be only built close to an airport or a railway track - is this possible?
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Some questions on limits of industry NewGRF

Post by PikkaBird »

You can use any ID you want, as the spec says. Gaps are fine.

The default cargo properties are here. Getting rid of (or substantially modifying) passengers, mail, food or goods is probably not a good idea.

Yes, it's possible to an extent - you can check the class of nearby tiles with a location_check callback. Although obviously an industry which requires nearby player-built infrastructure will be ungeneratable at game start.
ebla71
Transport Coordinator
Transport Coordinator
Posts: 346
Joined: 14 Apr 2021 21:48
Location: Earth

Re: Some questions on limits of industry NewGRF

Post by ebla71 »

PikkaBird wrote: 15 Sep 2023 05:24 You can use any ID you want, as the spec says. Gaps are fine.

The default cargo properties are here. Getting rid of (or substantially modifying) passengers, mail, food or goods is probably not a good idea.
Thank you very much for your very valuable comments.

Two more questions:

:arrow: You mentioned that one should best not modify the PASS, MAIL, FOOD, and GOOD cargos. Does that statement also apply to the cargo IDs (PASS 00, MAIL 02, GOOD 05, and FOOD 0B)? Asking because I would like to arrange (and group) the cargoes either by alphabet on name or label for easier finding in long tables. Would it be ok to change MAIL ID to 01 and GOOD to 02, for example?

:arrow: Is there a way to split a *.nml file and load parts of it from another one "at compile time" as it is done with the include <file> statement in C or import <module> in Python? As I plan to use all of the cargo IDs and have about 70-80 industries, it would be nice if one could put all of the industry definitions into separate files, one for each industry, and then only "merge" when running nmlc. If not, no worries, then I will write a Python script to read in separate files and automatically generate one final *.nml
I have a very vague memory that somebody reported a similar organization for their NewGRF source code but really cannot figure out anymore who, when, or where :roll:
Argus
Tycoon
Tycoon
Posts: 1204
Joined: 16 Oct 2018 08:31
Location: Heart of the Highlands. Not Scottish. Czech.

Re: Some questions on limits of industry NewGRF

Post by Argus »

Pikkabird wrote that he would not even recommend modification. As I understand it, there could also be a problem with what IDs the building sets expect for these cargos.
It could well be that houses in subarctic or tropical climates will not accept food and goods.
I have no doubt that if it were possible, some industry set would already have it alphabetically, but it doesn't. Not even XIS or AXIS.
ebla71
Transport Coordinator
Transport Coordinator
Posts: 346
Joined: 14 Apr 2021 21:48
Location: Earth

Re: Some questions on limits of industry NewGRF

Post by ebla71 »

Argus wrote: 15 Sep 2023 17:51 Pikkabird wrote that he would not even recommend modification. As I understand it, there could also be a problem with what IDs the building sets expect for these cargos.
It could well be that houses in subarctic or tropical climates will not accept food and goods.
I have no doubt that if it were possible, some industry set would already have it alphabetically, but it doesn't. Not even XIS or AXIS.
Do not have the nml code of XIS or AXIS ready, but at least can confirm the latter for OTIS, which has PASS as 0 and the other three standard cargoes also as indicated.

Personally, I'd consider it a bug if a building or other set refers to the cargo ID number instead of the cargo label, since the latter symbolic references are usually meant to make things more independent and easier to clearly assign - but that might be lack of insight or sloppyness of developers 8) Or ID numbers even came before symbolic cargo labels?
Argus
Tycoon
Tycoon
Posts: 1204
Joined: 16 Oct 2018 08:31
Location: Heart of the Highlands. Not Scottish. Czech.

Re: Some questions on limits of industry NewGRF

Post by Argus »

Honestly, I'm no expert, just going by my layman's understanding of newgrf behavior. Maybe I'm wrong.
ebla71
Transport Coordinator
Transport Coordinator
Posts: 346
Joined: 14 Apr 2021 21:48
Location: Earth

Re: Some questions on limits of industry NewGRF

Post by ebla71 »

Argus wrote: 15 Sep 2023 18:52 Honestly, I'm no expert, just going by my layman's understanding of newgrf behavior. Maybe I'm wrong.
Actually, if you have a bit of programming experience, reading and understanding the NML language code isn't that terribly difficult - most of it is close to regular English language plus a few "control statements" close to standard programming languages.

I'd really suggest to take a look at such an *.nml file if you have time and want to dig a bit deeper into the technical aspects 8) Personally, also thought for a long time that it is actually more complicated than it turned out in the end :lol:

My experience is a bit of Python for science applications, so far from an expert developer here.

But regardless of background - may I recruit you as a "beta tester" for the planned industry set, much like with the Hamburg scenario? 8)
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Some questions on limits of industry NewGRF

Post by PikkaBird »

ebla71 wrote: 15 Sep 2023 17:29 Asking because I would like to arrange (and group) the cargoes either by alphabet on name or label for easier finding in long tables. Would it be ok to change MAIL ID to 01 and GOOD to 02, for example?
Before you get too deep in the weeds on this, let me point out that in most (all?) cases, cargos are already listed alphabetically in the game, with the exception of PASS and MAIL being at the top.
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5658
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Some questions on limits of industry NewGRF

Post by andythenorth »

ebla71 wrote: 15 Sep 2023 17:29 :arrow: Is there a way to split a *.nml file and load parts of it from another one "at compile time" as it is done with the include <file> statement in C or import <module> in Python? As I plan to use all of the cargo IDs and have about 70-80 industries, it would be nice if one could put all of the industry definitions into separate files, one for each industry, and then only "merge" when running nmlc. If not, no worries, then I will write a Python script to read in separate files and automatically generate one final *.nml
FIRS packages cargos and industries as python modules. https://github.com/andythenorth/firs

I didn't intend FIRS to be a general purpose framework for industry grf authors, but it has been forked to make 5 or 6 other grfs that I'm aware of.
Eddi
Tycoon
Tycoon
Posts: 8272
Joined: 17 Jan 2007 00:14

Re: Some questions on limits of industry NewGRF

Post by Eddi »

ebla71 wrote: 15 Sep 2023 18:19 Personally, I'd consider it a bug if a building or other set refers to the cargo ID number instead of the cargo label, since the latter symbolic references are usually meant to make things more independent and easier to clearly assign - but that might be lack of insight or sloppyness of developers 8) Or ID numbers even came before symbolic cargo labels?
historically, the cargo labels are a newer addition.

in a game as old as this, you'll find lots of these "heritage" "features"
Argus
Tycoon
Tycoon
Posts: 1204
Joined: 16 Oct 2018 08:31
Location: Heart of the Highlands. Not Scottish. Czech.

Re: Some questions on limits of industry NewGRF

Post by Argus »

PikkaBird wrote: 16 Sep 2023 03:57
ebla71 wrote: 15 Sep 2023 17:29 Asking because I would like to arrange (and group) the cargoes either by alphabet on name or label for easier finding in long tables. Would it be ok to change MAIL ID to 01 and GOOD to 02, for example?
Before you get too deep in the weeds on this, let me point out that in most (all?) cases, cargos are already listed alphabetically in the game, with the exception of PASS and MAIL being at the top.
That's right, I forgot about that.
Passengers and mail are the only ones out of alphabetical order, perhaps for ease of access, in quite a few cases transporting them is the absolute start of the game unless more lucrative shipping routes can be created right away.
ebla71
Transport Coordinator
Transport Coordinator
Posts: 346
Joined: 14 Apr 2021 21:48
Location: Earth

Re: Some questions on limits of industry NewGRF

Post by ebla71 »

PikkaBird wrote: 16 Sep 2023 03:57 Before you get too deep in the weeds on this, let me point out that in most (all?) cases, cargos are already listed alphabetically in the game, with the exception of PASS and MAIL being at the top.
You're right - I meant "order of appearance in the code"
ebla71
Transport Coordinator
Transport Coordinator
Posts: 346
Joined: 14 Apr 2021 21:48
Location: Earth

Re: Some questions on limits of industry NewGRF

Post by ebla71 »

andythenorth wrote: 16 Sep 2023 07:12 FIRS packages cargos and industries as python modules. https://github.com/andythenorth/firs
Thank you very much for pointing this out - I'm pretty sure that was the example I had in mind.
Eddi
Tycoon
Tycoon
Posts: 8272
Joined: 17 Jan 2007 00:14

Re: Some questions on limits of industry NewGRF

Post by Eddi »

ebla71 wrote: 16 Sep 2023 18:51
PikkaBird wrote: 16 Sep 2023 03:57 Before you get too deep in the weeds on this, let me point out that in most (all?) cases, cargos are already listed alphabetically in the game, with the exception of PASS and MAIL being at the top.
You're right - I meant "order of appearance in the code"
there's no reason why appearance in the code needs to be related to the order of the IDs
User avatar
OzTrans
Tycoon
Tycoon
Posts: 1680
Joined: 04 Mar 2005 01:07

Re: Some questions on limits of industry NewGRF

Post by OzTrans »

ebla71 wrote: 15 Sep 2023 17:29 ... Would it be ok to change MAIL ID to 01 and GOOD to 02, for example? ...
Don't do that. Leave MAIL as 0x02, because aircraft do NOT carry MAIL in the mail compartment, they carry cargo ID 0x02, whatever it is. There may be other implications, if you change PASS and MAIL.

I use 00-PASS, 01-TOUR, 02-MAIL ...
ebla71
Transport Coordinator
Transport Coordinator
Posts: 346
Joined: 14 Apr 2021 21:48
Location: Earth

Re: Some questions on limits of industry NewGRF

Post by ebla71 »

OzTrans wrote: 17 Sep 2023 00:30
ebla71 wrote: 15 Sep 2023 17:29 ... Would it be ok to change MAIL ID to 01 and GOOD to 02, for example? ...
Don't do that. Leave MAIL as 0x02, because aircraft do NOT carry MAIL in the mail compartment, they carry cargo ID 0x02, whatever it is. There may be other implications, if you change PASS and MAIL.

I use 00-PASS, 01-TOUR, 02-MAIL ...
"aircraft do NOT carry MAIL in the mail compartment, they carry cargo ID 0x02, whatever it is"

Thank you very much - that's an extremely important hint that most people are not aware off, I guess.

Finally explains why it was reported somewhere that aircraft carry "strange" cargo. Also vaguely remember from one of my own games a plane fit for manganese or something like that.
ebla71
Transport Coordinator
Transport Coordinator
Posts: 346
Joined: 14 Apr 2021 21:48
Location: Earth

Re: Some questions on limits of industry NewGRF

Post by ebla71 »

Eddi wrote: 16 Sep 2023 23:11 there's no reason why appearance in the code needs to be related to the order of the IDs
Well, if you are closely familiar with the inner mode of operation of nmlc, possibly yes.

If not - like me - one could consider the *.nml file as sequential information where - when read into a "classical" array or Python list data structure - order of appearance in the file does indeed matter.

But by further analyzing the *.nml files available to me, I have now learnt that indeed the IDs of the cargos and industries are assigned independent of order by
item(FEAT_CARGOS, mail, 2) {
property {
number: 2;
and
item(FEAT_INDUSTRIES, Shopping_Centres, 106) {
The only thing that still confuses me is why in the cargo definition, the ID number appears twice, once in the item() "instruction" and once as the number "variable"?!?
ebla71
Transport Coordinator
Transport Coordinator
Posts: 346
Joined: 14 Apr 2021 21:48
Location: Earth

Re: Some questions on limits of industry NewGRF

Post by ebla71 »

PikkaBird wrote: 16 Sep 2023 03:57 Before you get too deep in the weeds on this, let me point out that in most (all?) cases, cargos are already listed alphabetically in the game
I actually found one instance where the order is not by alphabet but by industry ID as defined in

item(FEAT_INDUSTRIES, Shopping_Centres, 106)

and this is the graphical display of the industry chain.

In the first picture below the industry IDs are 20 for Sheep Farm, 21 for Cow Farm, and 22 for Arable Farm but for the second picture, I changed the industry ID for the cow farm to 107 which makes it appear last while in the "Fund new industry" window on the left, the alphabetical order is maintained.

Is this the intended behaviour?!?

Image
Image
Attachments
Industry Chain 1.png
(239.05 KiB) Not downloaded yet
Industry Chain 2.png
(241.9 KiB) Not downloaded yet
ebla71
Transport Coordinator
Transport Coordinator
Posts: 346
Joined: 14 Apr 2021 21:48
Location: Earth

Re: Some questions on limits of industry NewGRF

Post by ebla71 »

Just found another example where order is not by alphabet but appearance in code:
cargo_types: [accept_cargo("BOOM"),produce_cargo("COAL",16),produce_cargo("CORE",12),produce_cargo("IORE",8),produce_cargo("ZORE",8),produce_cargo("AORE",8)];
If there were alpahbetical ordering by either cargo name or cargo four-letter "code", AORE = bauxite should be first:

Image
Attachments
Industry Chain 3.png
(365.53 KiB) Not downloaded yet
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Some questions on limits of industry NewGRF

Post by PikkaBird »

ebla71 wrote: 17 Sep 2023 18:46 The only thing that still confuses me is why in the cargo definition, the ID number appears twice, once in the item() "instruction" and once as the number "variable"?!?
The "number" property is an obsolete remnant of an older spec. Just set it to the same value as the ID number and don't worry about it.
Just found another example where order is not by alphabet but appearance in code
By all means report it as a bug.
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 8 guests