NML: 16-cargo industry support

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

Moderator: Graphics Moderators

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

NML: 16-cargo industry support

Post by andythenorth » 24 Mar 2019 12:33

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: 3076
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML: 16-cargo industry support

Post by GarryG » 22 Apr 2019 12:21

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 28 times
Soot Happens
All my projects are GPLv2 License unless stated.
Auz Project Releases: 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: 5010
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: NML: 16-cargo industry support

Post by andythenorth » 22 Apr 2019 14:41

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 36 times
factory.nml
(58.62 KiB) Downloaded 36 times

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

Re: NML: 16-cargo industry support

Post by GarryG » 22 Apr 2019 23:23

Thanks kindly for the examples.

Will experiment with those and see what I can do.

Cheers
Soot Happens
All my projects are GPLv2 License unless stated.
Auz Project Releases: 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: 3076
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML: 16-cargo industry support

Post by GarryG » 23 Apr 2019 04:33

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
All my projects are GPLv2 License unless stated.
Auz Project Releases: 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
Director
Director
Posts: 594
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: NML: 16-cargo industry support

Post by jfs » 23 Apr 2019 13:56

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: 3076
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML: 16-cargo industry support

Post by GarryG » 24 Apr 2019 08:04

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
All my projects are GPLv2 License unless stated.
Auz Project Releases: 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: 3076
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML: 16-cargo industry support

Post by GarryG » 24 Apr 2019 23:53

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
All my projects are GPLv2 License unless stated.
Auz Project Releases: 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
Director
Director
Posts: 594
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: NML: 16-cargo industry support

Post by jfs » 25 Apr 2019 05:45

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

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

Re: NML: 16-cargo industry support

Post by GarryG » 25 Apr 2019 07:53

I have the nlmc.exe version dated 21st March 2019
Soot Happens
All my projects are GPLv2 License unless stated.
Auz Project Releases: 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: 3076
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML: 16-cargo industry support

Post by GarryG » 07 May 2019 12:03

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
All my projects are GPLv2 License unless stated.
Auz Project Releases: 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


Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 4 guests