NML: 16-cargo industry support

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

Moderator: Graphics Moderators

User avatar
andythenorth
Tycoon
Tycoon
Posts: 5152
Joined: 31 Mar 2007 14:23
Location: Lost in Music

NML: 16-cargo industry support

Post by andythenorth »

Planetmaker merged the PR for NML 16-cargo industry support https://github.com/OpenTTD/nml/pull/15

1. There are no docs for this feature. Someone needs to write them, per the pull request.
2. This feature breaks backwards compatibility in NML.
3. The feature is relatively untested.

NML remains unmaintained, if you use it, and you want to see it continue to be developed, you need to help. Find us in #openttd irc https://wiki.openttd.org/Irc

cheers,

Andy

User avatar
GarryG
Tycoon
Tycoon
Posts: 3440
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML: 16-cargo industry support

Post by GarryG »

Hi all,

In the NML update dated April 10, tried to follow the sample for the Industry to try add extra cargos to my Industries, but unfortunately have trouble understanding it and also some of the code it comes up with some error messages.

For instance when I add this:

Code: Select all

               cargo_types: [
            produce_cargo("LVST", 8),
            produce_cargo("GRAI", 12),
            produce_cargo("WOOD", 4),
        ];
Get a message
Unknown property name: cargo types
I added other files from the sample trying to work out why it keep giving me that error message, but I was unsuccessful.

So I made up a AuzIndTest with just one Industry to test with.

The Industry is called "Commercials" I extracted it from my main AuzInd files.

I've zipped up all the files associated with AuzIndTest for anyone who would like to play around with it and see if they can add extra cargos to it.

The nml file I zipped up has 6332 lines. The first 2038 is all references to 56 different cargo types and some Parameter settings.

Majority of my coding is extracted from FIRS 1.4.3.

Hoping those who understand coding better than me might be able to work with this one Industry and get it to work with many cargos.

Hope it will help other coders too.

Cheers all
Attachments
AuzIndTest.rar
(239.49 KiB) Downloaded 52 times
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
AuzProjectReleases: viewtopic.php?f=67&t=84725
AuzTrains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
AuzObjects: viewtopic.php?f=26&t=75657
AuzBridges: viewtopic.php?f=26&t=75248
AuzStations: viewtopic.php?f=26&t=76390
AuzTracks: viewtopic.php?f=26&t=82691
AuzSubwayStations: viewtopic.php?f=26&t=85335

User avatar
andythenorth
Tycoon
Tycoon
Posts: 5152
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: NML: 16-cargo industry support

Post by andythenorth »

Nielsm wrote an example for new production callback format here: https://0x0.st/zHBc.txt

I've attached a couple of files from FIRS v4 development.

Hope this helps.
Attachments
quarry.nml
(216.52 KiB) Downloaded 57 times
factory.nml
(58.62 KiB) Downloaded 60 times

User avatar
GarryG
Tycoon
Tycoon
Posts: 3440
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML: 16-cargo industry support

Post by GarryG »

Thanks kindly for the examples.

Will experiment with those and see what I can do.

Cheers
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
AuzProjectReleases: viewtopic.php?f=67&t=84725
AuzTrains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
AuzObjects: viewtopic.php?f=26&t=75657
AuzBridges: viewtopic.php?f=26&t=75248
AuzStations: viewtopic.php?f=26&t=76390
AuzTracks: viewtopic.php?f=26&t=82691
AuzSubwayStations: viewtopic.php?f=26&t=85335

User avatar
GarryG
Tycoon
Tycoon
Posts: 3440
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML: 16-cargo industry support

Post by GarryG »

First I like to thank and congratulate the ones who managed to change the coding in NML so Industries can accept all the extra cargoes. Well done.

The problem now is me trying to understanding it all :roll:

A few things in the coding of those samples I like to get a bit more information on and if I on the right track.

Code: Select all

cargo_types: [accept_cargo("GLAS"),accept_cargo("PLAS"),accept_cargo("STAL"),accept_cargo("POWR"),produce_cargo("VPTS",0)];
It shows that the Factory accepts the GLAS, PLAS, STAL and POWR and produces VPTS? Does the VPTS represent the MNSP and GOOD mentioned earlier in the code?

Code: Select all

    produce (factory_produce_0,
        [
                MNSP: incoming_cargo_waiting("MNSP");
        ],
        [
                GOOD: (LOAD_PERM(2) * 8) / 8;
        ],
    0)
    switch (FEAT_INDUSTRIES, SELF, factory_produce_calculation_0,
            [
                STORE_PERM(0, 1),
                STORE_PERM(0, 2),
                    STORE_PERM(
                        max(LOAD_PERM(3), (incoming_cargo_waiting("MNSP") > 0) * current_date),
                        3
                    ),
                    STORE_PERM(
                        LOAD_PERM(1)
                        + (
                            (current_date - LOAD_PERM(3)) <= 90
                            ? 8 : 0
                        ),
                        1
                    ),
                    STORE_PERM(
                        LOAD_PERM(2)
                        + ((incoming_cargo_waiting("MNSP") * LOAD_PERM(1)) / 8),
                        2
                    ),
                STORE_PERM(
                    (LOAD_PERM(2) == 0)
                    ? LOAD_PERM(0) : 0,
                    0
                ),
            ]) {
        factory_produce_0;
    }
You have " produce (factory_produce_0 to produce (factory_produce_5 ". Are all 5 necessary and what the reason for them.

Also notice with some of the Cargo coding " current_date " .. will we be able to set a date for some cargos to become available?

That should do for starters.

Cheers
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
AuzProjectReleases: viewtopic.php?f=67&t=84725
AuzTrains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
AuzObjects: viewtopic.php?f=26&t=75657
AuzBridges: viewtopic.php?f=26&t=75248
AuzStations: viewtopic.php?f=26&t=76390
AuzTracks: viewtopic.php?f=26&t=82691
AuzSubwayStations: viewtopic.php?f=26&t=85335

User avatar
jfs
Tycoon
Tycoon
Posts: 1174
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: NML: 16-cargo industry support

Post by jfs »

The six different factory_produce_(calculation_) seem to be selected by the economy variable, i.e. which FIRS economy is selected. For an industry set with just a single economy configuration you could probably make do with a single of them.

I think the current_date things are the check for when the relevant "supplies" cargo was last delivered. The day of last supplies delivery gets stored in one of the permanent slots in the industry.

Also notice that the FEAT_INDUSTRIES item itself is protected by if (economy == 5), and only the "mode 5" produce callback touches the cargo types mentioned in the cargo_types list.

Code: Select all

    produce (factory_produce_5,
        [
                GLAS: incoming_cargo_waiting("GLAS");
                PLAS: incoming_cargo_waiting("PLAS");
                STAL: incoming_cargo_waiting("STAL");
                POWR: incoming_cargo_waiting("POWR");
        ],
        [
                VPTS: (LOAD_PERM(2) * 8) / 8;
        ],
    0)
    switch (FEAT_INDUSTRIES, SELF, factory_produce_calculation_5,
            [
                STORE_PERM(0, 1),
                STORE_PERM(0, 2),
                    STORE_PERM(
                        max(LOAD_PERM(3), (incoming_cargo_waiting("GLAS") > 0) * current_date),
                        3
                    ),
                    STORE_PERM(
                        LOAD_PERM(1)
                        + (
                            (current_date - LOAD_PERM(3)) <= 90
                            ? 2 : 0
                        ),
                        1
                    ),
                    STORE_PERM(
                        max(LOAD_PERM(4), (incoming_cargo_waiting("PLAS") > 0) * current_date),
                        4
                    ),
                    STORE_PERM(
                        LOAD_PERM(1)
                        + (
                            (current_date - LOAD_PERM(4)) <= 90
                            ? 2 : 0
                        ),
                        1
                    ),
                    STORE_PERM(
                        max(LOAD_PERM(5), (incoming_cargo_waiting("STAL") > 0) * current_date),
                        5
                    ),
                    STORE_PERM(
                        LOAD_PERM(1)
                        + (
                            (current_date - LOAD_PERM(5)) <= 90
                            ? 2 : 0
                        ),
                        1
                    ),
                    STORE_PERM(
                        max(LOAD_PERM(6), (incoming_cargo_waiting("POWR") > 0) * current_date),
                        6
                    ),
                    STORE_PERM(
                        LOAD_PERM(1)
                        + (
                            (current_date - LOAD_PERM(6)) <= 90
                            ? 2 : 0
                        ),
                        1
                    ),
                    STORE_PERM(
                        LOAD_PERM(2)
                        + ((incoming_cargo_waiting("GLAS") * LOAD_PERM(1)) / 8),
                        2
                    ),
                    STORE_PERM(
                        LOAD_PERM(2)
                        + ((incoming_cargo_waiting("PLAS") * LOAD_PERM(1)) / 8),
                        2
                    ),
                    STORE_PERM(
                        LOAD_PERM(2)
                        + ((incoming_cargo_waiting("STAL") * LOAD_PERM(1)) / 8),
                        2
                    ),
                    STORE_PERM(
                        LOAD_PERM(2)
                        + ((incoming_cargo_waiting("POWR") * LOAD_PERM(1)) / 8),
                        2
                    ),
                STORE_PERM(
                    (LOAD_PERM(2) == 0)
                    ? LOAD_PERM(0) : 0,
                    0
                ),
            ]) {
        factory_produce_5;
    }

User avatar
GarryG
Tycoon
Tycoon
Posts: 3440
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML: 16-cargo industry support

Post by GarryG »

Probable all I need to use is the produce (factory_produce_0, for cargoes produced and produce (factory_produce_05, for cargoes accepted.

And

cargo_types: [accept_cargo("GLAS"),accept_cargo("PLAS"),accept_cargo("STAL"),accept_cargo("POWR"),produce_cargo("MNSP",0),produce_cargo("GOOD",0)];

Unfortunately it be several days before I get chance to experiment properly with these.

I hoping with the sample of my test file is to add as many cargos as I can to that one Industry to test it and when all working well remove what cargos I don't really need with that one and start adding more Industries.
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
AuzProjectReleases: viewtopic.php?f=67&t=84725
AuzTrains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
AuzObjects: viewtopic.php?f=26&t=75657
AuzBridges: viewtopic.php?f=26&t=75248
AuzStations: viewtopic.php?f=26&t=76390
AuzTracks: viewtopic.php?f=26&t=82691
AuzSubwayStations: viewtopic.php?f=26&t=85335

User avatar
GarryG
Tycoon
Tycoon
Posts: 3440
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML: 16-cargo industry support

Post by GarryG »

Just had a try making cargo changes to my test set ..

not matter how I try to change it keep getting a Syntax error, unexpected token ":"

Code: Select all

   produce (Commercials_clear_incoming_cargo_waiting_0,
        [
                ENSP: incoming_cargo_waiting("ENSP");
        ],
        [],
    0)
It is the ":" after ENSP

No matter if I try bring codes over to my test set from Quarry.nml, Factory.nml or from "Nielsm wrote an example for new production callback format here"

Just wondering if some one can look at my test file AuzIndTest (up above) and maybe change what coding is needed just for the cargoes I have in the test. That just might help me see where I going wrong.

Plenty time to check as be busy for a few days or more with home life. Cheers
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
AuzProjectReleases: viewtopic.php?f=67&t=84725
AuzTrains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
AuzObjects: viewtopic.php?f=26&t=75657
AuzBridges: viewtopic.php?f=26&t=75248
AuzStations: viewtopic.php?f=26&t=76390
AuzTracks: viewtopic.php?f=26&t=82691
AuzSubwayStations: viewtopic.php?f=26&t=85335

User avatar
jfs
Tycoon
Tycoon
Posts: 1174
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: NML: 16-cargo industry support

Post by jfs »

Just to be sure, you are running the updated NML version with the new syntax, right?

User avatar
GarryG
Tycoon
Tycoon
Posts: 3440
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML: 16-cargo industry support

Post by GarryG »

I have the nlmc.exe version dated 21st March 2019
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
AuzProjectReleases: viewtopic.php?f=67&t=84725
AuzTrains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
AuzObjects: viewtopic.php?f=26&t=75657
AuzBridges: viewtopic.php?f=26&t=75248
AuzStations: viewtopic.php?f=26&t=76390
AuzTracks: viewtopic.php?f=26&t=82691
AuzSubwayStations: viewtopic.php?f=26&t=85335

User avatar
GarryG
Tycoon
Tycoon
Posts: 3440
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML: 16-cargo industry support

Post by GarryG »

Just to let you know I been unsuccessful it coding extra cargos to my Industry .. even got that error message with the Industry sample that comes with NML updates.

Not been able to find the reason why as not been well past few weeks and not able to concentrate on any of my coding work. Could be out of action for a while.

Cheers all
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
AuzProjectReleases: viewtopic.php?f=67&t=84725
AuzTrains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
AuzObjects: viewtopic.php?f=26&t=75657
AuzBridges: viewtopic.php?f=26&t=75248
AuzStations: viewtopic.php?f=26&t=76390
AuzTracks: viewtopic.php?f=26&t=82691
AuzSubwayStations: viewtopic.php?f=26&t=85335


User avatar
3iff
Tycoon
Tycoon
Posts: 1012
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: NML: 16-cargo industry support

Post by 3iff »

Has anyone had any success in coding for 16 cargos? I'm getting nowhere fast and would appreciate a small bit of working code to use as a starter.

User avatar
jfs
Tycoon
Tycoon
Posts: 1174
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: NML: 16-cargo industry support

Post by jfs »

3iff wrote:
21 Jan 2020 10:31
Has anyone had any success in coding for 16 cargos? I'm getting nowhere fast and would appreciate a small bit of working code to use as a starter.
There are some examples out, also on the NewGRF wiki for NML. They should work.
If they don't, which errors do you get?

User avatar
andythenorth
Tycoon
Tycoon
Posts: 5152
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: NML: 16-cargo industry support

Post by andythenorth »

3iff wrote:
21 Jan 2020 10:31
Has anyone had any success in coding for 16 cargos? I'm getting nowhere fast and would appreciate a small bit of working code to use as a starter.
FIRS v4 uses quite a lot of the spec, you'll find most of the cargo handling in src/templates: https://github.com/andythenorth/firs/tr ... ease-track

I'm not sure how useful the whole FIRS nml is, but here you go anyway ;)
Attachments
firs.nml
(10.16 MiB) Downloaded 90 times

Sunmannus
Engineer
Engineer
Posts: 21
Joined: 09 Aug 2013 06:31

Re: NML: 16-cargo industry support

Post by Sunmannus »

andythenorth wrote:
21 Jan 2020 19:20
I'm not sure how useful the whole FIRS nml is, but here you go anyway ;)
Very useful indeed, for all us who don't understand templates and python.
Truly thankful for sharing it with us.

User avatar
3iff
Tycoon
Tycoon
Posts: 1012
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: NML: 16-cargo industry support

Post by 3iff »

I concur. I'm very sure it'll be very useful.

Thank you. Hopefully some results soon...(and probably a lot of frustration along the way...)

User avatar
andythenorth
Tycoon
Tycoon
Posts: 5152
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: NML: 16-cargo industry support

Post by andythenorth »

The nml docs for 16-cargo industry are now entirely complete :arrow: https://newgrf-specs.tt-wiki.net/wiki/NML:Industries

Thanks to all those who helped :D

Note that NML 0.5 will remove support for some deprecated industry properties. That's noted in the NML docs.

16-cargo house support is also now done (will be in NML 0.5) and documented :arrow: https://newgrf-specs.tt-wiki.net/wiki/NML:Houses

NML 0.5 is not yet released, progress on that can be tracked here https://github.com/OpenTTD/nml/issues/43

Generally there has been a lot of change in the NewGRF spec as some big features have been added. That has required a lot of work in the tools and docs, which fortunately is now nearly complete :) Keep track here: https://wiki.openttd.org/NewGRF_Specification_Status

User avatar
GarryG
Tycoon
Tycoon
Posts: 3440
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML: 16-cargo industry support

Post by GarryG »

andythenorth wrote:
20 Feb 2020 08:18
The nml docs for 16-cargo industry are now entirely complete
Great news .. well done to those involved with this project.
andythenorth wrote:
20 Feb 2020 08:18
NML 0.5 is not yet released
I'll wait for it to be released before I start working on my Industries again.

Cheers all
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
AuzProjectReleases: viewtopic.php?f=67&t=84725
AuzTrains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
AuzObjects: viewtopic.php?f=26&t=75657
AuzBridges: viewtopic.php?f=26&t=75248
AuzStations: viewtopic.php?f=26&t=76390
AuzTracks: viewtopic.php?f=26&t=82691
AuzSubwayStations: viewtopic.php?f=26&t=85335

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9407
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NML: 16-cargo industry support

Post by planetmaker »

andythenorth wrote:
20 Feb 2020 08:18
The nml docs for 16-cargo industry are now entirely complete
Thanks a lot, andy!
andythenorth wrote:
20 Feb 2020 08:18
NML 0.5 is not yet released
GarryG wrote:
20 Feb 2020 12:02
I'll wait for it to be released before I start working on my Industries again.

Cheers all

There's nothing wrong with using the current development version to get going :)

Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 0 guests