Solved: Loading or producing cargo problem

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

Moderator: Graphics Moderators

Post Reply
User avatar
adpro
Engineer
Engineer
Posts: 42
Joined: 22 Nov 2005 19:15
Location: Czech Republic
Contact:

Solved: Loading or producing cargo problem

Post by adpro »

Hello,
I'm playing with NML and trying to code a few cargos and industries and ran into a problem producing cargo.
I implemented the produce_256_ticks callback where I produce the same amount from the amount of input cargo, however a single train and a single station is usually loaded between 30-36 items out of 50.
It looks like Pasture will indeed produce 50 units (5 units was produced in 2 months ago), but only a portion is loaded onto the train. Does this affect any game settings?

What is the problem?

Thanks for the tips.
2023-07-10T13-01-41_small.png
2023-07-10T13-01-41_small.png (185.75 KiB) Viewed 1967 times

Code: Select all

produce(empty_prod, [], [])

produce(pasture_prod256_prod,
    [LAMB: LOAD_TEMP(4);],
    [SHEP: LOAD_TEMP(4);],
    0
    )

switch(FEAT_INDUSTRIES, SELF, pasture_256_prod_cb0, [
        STORE_TEMP(min(incoming_cargo_waiting("LAMB"), 5), 4),
        incoming_cargo_waiting("LAMB")
    ]) {
    0: empty_prod;
    pasture_prod256_prod;
}

switch(FEAT_INDUSTRIES, SELF, pasture_extra_text, [
        STORE_TEMP(this_month_production("SHEP") | 
            production_rate("SHEP") << 16, 0x100)
    ]) {
	return string(STR_IND_EXTRA_PASTURE);
}

item(FEAT_INDUSTRIES, pasture, 125) {
    property {
        substitute: INDUSTRYTYPE_TROPICAL_FACTORY;
        layouts: [pasture_industry_layout_tilelayout];
        life_type: IND_LIFE_TYPE_PROCESSING;
        cargo_types: [accept_cargo("LAMB"), produce_cargo("SHEP", 0)];
        min_cargo_distr: 1;
        spec_flags: bitmask(IND_FLAG_LONG_CARGO_TYPE_LISTS,
                            IND_FLAG_BUILT_ONLY_BEFORE_1950);
        name: string(STR_IND_PASTURE);
    }
    graphics {
        produce_256_ticks: pasture_256_prod_cb0;
        extra_text_industry: pasture_extra_text;
    }
}
Last edited by adpro on 11 Jul 2023 07:09, edited 1 time in total.
adpro | NewGRF Military Items project
User avatar
jfs
Tycoon
Tycoon
Posts: 1763
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: [NML] Loading or producing cargo problem

Post by jfs »

The station rating affects how much cargo is transported. If the station picking up the cargo is 75% for that cargo, 75% of the cargo produced will be given to the station for transport, and the remaining 25% of the production is lost.

It's possible to implement a custom station rating calculation for cargo types that e.g. makes the rating fixed at 100% so you always get everything, regardless of the service level. This is also done in the NewGRF.
User avatar
adpro
Engineer
Engineer
Posts: 42
Joined: 22 Nov 2005 19:15
Location: Czech Republic
Contact:

Re: [NML] Loading or producing cargo problem

Post by adpro »

jfs wrote: 10 Jul 2023 13:05 The station rating affects how much cargo is transported. If the station picking up the cargo is 75% for that cargo, 75% of the cargo produced will be given to the station for transport, and the remaining 25% of the production is lost.
Thank you, that is good to know. I think I forgot that over the years.
jfs wrote: 10 Jul 2023 13:05 It's possible to implement a custom station rating calculation for cargo types that e.g. makes the rating fixed at 100% so you always get everything, regardless of the service level. This is also done in the NewGRF.
Can you give me more details about this? In the NML Stations documentation, there is only a cargo_rating variable, but there is no property or callback to modify it. What mechanism for self-calculation of the station cargo rating can be used? Is it in any NewGRF that has open source code?
adpro | NewGRF Military Items project
User avatar
adpro
Engineer
Engineer
Posts: 42
Joined: 22 Nov 2005 19:15
Location: Czech Republic
Contact:

Re: [NML] Loading or producing cargo problem

Post by adpro »

adpro wrote: 11 Jul 2023 04:31 Can you give me more details about this? In the NML Stations documentation, there is only a cargo_rating variable, but there is no property or callback to modify it.
Yeah, I found callback in Cargo documentation page :D , but it is still not clear for me. :( Is it in any NewGRF that has open source code and use this callback?

EDIT
I tried

Code: Select all

item(FEAT_CARGOS, sheep, 62) {
    graphics {
        station_rating: 255;
    }
}
to see what happens with station rating ingame and now I think I understand how it works. :D :idea:
adpro | NewGRF Military Items project
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 18 guests