Page 1 of 2

NML: 16-cargo industry support

Posted: 24 Mar 2019 12:33
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

Re: NML: 16-cargo industry support

Posted: 22 Apr 2019 12:21
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

Re: NML: 16-cargo industry support

Posted: 22 Apr 2019 14:41
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.

Re: NML: 16-cargo industry support

Posted: 22 Apr 2019 23:23
by GarryG
Thanks kindly for the examples.

Will experiment with those and see what I can do.

Cheers

Re: NML: 16-cargo industry support

Posted: 23 Apr 2019 04:33
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

Re: NML: 16-cargo industry support

Posted: 23 Apr 2019 13:56
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;
    }

Re: NML: 16-cargo industry support

Posted: 24 Apr 2019 08:04
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.

Re: NML: 16-cargo industry support

Posted: 24 Apr 2019 23:53
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

Re: NML: 16-cargo industry support

Posted: 25 Apr 2019 05:45
by jfs
Just to be sure, you are running the updated NML version with the new syntax, right?

Re: NML: 16-cargo industry support

Posted: 25 Apr 2019 07:53
by GarryG
I have the nlmc.exe version dated 21st March 2019

Re: NML: 16-cargo industry support

Posted: 07 May 2019 12:03
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

Re: NML: 16-cargo industry support

Posted: 13 Oct 2019 12:15
by andythenorth
Just to report, the nml docs were updated a little while ago for 16-cargo industry support ;)

https://newgrf-specs.tt-wiki.net/wiki/NML:Industries
https://newgrf-specs.tt-wiki.net/wiki/NML:Produce

Re: NML: 16-cargo industry support

Posted: 21 Jan 2020 10:31
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.

Re: NML: 16-cargo industry support

Posted: 21 Jan 2020 17:16
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?

Re: NML: 16-cargo industry support

Posted: 21 Jan 2020 19:20
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 ;)

Re: NML: 16-cargo industry support

Posted: 22 Jan 2020 06:54
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.

Re: NML: 16-cargo industry support

Posted: 28 Jan 2020 10:06
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...)

Re: NML: 16-cargo industry support

Posted: 20 Feb 2020 08:18
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

Re: NML: 16-cargo industry support

Posted: 20 Feb 2020 12:02
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

Re: NML: 16-cargo industry support

Posted: 20 Feb 2020 12:58
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 :)