Served Industries and production question.

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

Moderator: Graphics Moderators

Post Reply
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Served Industries and production question.

Post by temporal8 »

I'm working on my industries newgrf and something is happening that I want to modify in production mode.

The Ikea supermarket produced crates of Goods without the need to provide Timber, I want it to produce ONLY IF it receives Timber first.

At the service station I have a different error, and it is that it requires Petrol Fuel and Food but the legend "0 liters or items waiting....) appears, that is not supposed to appear since it is the cargo final destination.
Image

Ikea Code (Petrol Station it´s almost similar)

Code: Select all

 item(FEAT_INDUSTRIES, ikea, 118) {
            property {
                substitute: 0;
                life_type: IND_LIFE_TYPE_PROCESSING;
                closure_msg: TTD_STR_NEWS_INDUSTRY_CLOSURE_SUPPLY_PROBLEMS;
                prod_increase_msg: TTD_STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_GENERAL;
                prod_decrease_msg: TTD_STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_GENERAL;
                new_ind_msg: TTD_STR_NEWS_INDUSTRY_CONSTRUCTION;
                min_cargo_distr: 5;
                map_colour: 73;
		spec_flags: bitmask(IND_FLAG_LONG_CARGO_TYPE_LISTS, IND_FLAG_ONLY_IN_LARGE_TOWNS);
                layouts:
[
    ikea_industry_layout_1_tilelayout,
];
                conflicting_ind_types: [];
                name: string(STR_IND_ikea);
                nearby_station_name: string(STR_STATION, string(STR_TOWN));
                prob_random: 12;
                prob_in_game: 4;
                prospect_chance: 0.75;
                fund_cost_multiplier: 1;
                remove_cost_multiplier: 0;
		cargo_types: [accept_cargo("WDPR"),produce_cargo("GOOD",10)];
            }
        }

item(FEAT_INDUSTRIES, ikea, 118) {
 graphics {
 		extra_text_industry: return string(STR_EXTRA_ikea);
		location_check: ikea_check_location;
 }
}
Petrol Cargo code:

Code: Select all

   spriteset(cargoicon_petrol) { [10 + 20 * 12, 10 + 20 * 1, 10, 10, 0, 0, "gfx/other/cargoicons.png"] }

    item(FEAT_CARGOS, petrol, 21) {
        property {
            number: 21;
            type_name: string(TTD_STR_CARGO_PLURAL_PETROL);
            unit_name: string(TTD_STR_CARGO_SINGULAR_PETROL);
            type_abbreviation: string(TTD_STR_ABBREV_PETROL);
            sprite: NEW_CARGO_SPRITE;
            weight: 0.8;
            station_list_colour: 172;
            cargo_payment_list_colour: 172;
            is_freight: 1;
            cargo_classes: bitmask(CC_LIQUID, CC_HAZARDOUS);
            cargo_label: "PETR";
            town_growth_effect: TOWNGROWTH_NONE;
            town_growth_multiplier: 1.0;
            units_of_cargo: TTD_STR_LITERS;
            items_of_cargo: string(STR_CARGO_UNIT_PETROL);
            penalty_lowerbound: 18;
            single_penalty_length: 255;
            price_factor: 043;
            capacity_multiplier: 1;
        }
        graphics {
            //station_rating: switch_station_rating;
            cargoicon_petrol;
        }
    }
Food Code:

Code: Select all

  spriteset(cargoicon_food) { [10 + 20 * 12, 10 + 20 * 0, 10, 10, 0, 0, "gfx/other/cargoicons.png"] }


    item(FEAT_CARGOS, food, 19) {
        property {
            number: 19;
            type_name: string(TTD_STR_CARGO_PLURAL_FOOD);
            unit_name: string(TTD_STR_CARGO_SINGULAR_FOOD);
            type_abbreviation: string(TTD_STR_ABBREV_FOOD);
            sprite: NEW_CARGO_SPRITE;
            weight: 1.0;
            station_list_colour: 48;
            cargo_payment_list_colour: 48;
            is_freight: 1;
            cargo_classes: bitmask(CC_REFRIGERATED, CC_EXPRESS);
            cargo_label: "FOOD";
            town_growth_effect: TOWNGROWTH_NONE;
            town_growth_multiplier: 1.0;
            units_of_cargo: TTD_STR_ITEMS;
            items_of_cargo: string(STR_CARGO_UNIT_FOOD);
            penalty_lowerbound: 0;
            single_penalty_length: 24;
            price_factor: 149.803161621;
            capacity_multiplier: 1;
        }
        graphics {
            //station_rating: switch_station_rating;
            cargoicon_food;
        }
    }
Attachments
Great Maningville Transport, 10th Nov 2040#2.png
(3.59 MiB) Not downloaded yet
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5601
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Served Industries and production question.

Post by PikkaBird »

cargo_types: [accept_cargo("WDPR"),produce_cargo("GOOD",10)];
Try

Code: Select all

cargo_types: [accept_cargo("WDPR", produce_cargo("GOOD",10))];
For the petrol station, "almost similar" does not provide sufficient information to diagnose, but it sounds like you need to turn off the stockpiling mechanic for that industry. Someone who codes industries in NML might be able to help more.
User avatar
jfs
Tycoon
Tycoon
Posts: 1750
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Served Industries and production question.

Post by jfs »

This part:

Code: Select all

cargo_types: [accept_cargo("WDPR"),produce_cargo("GOOD",10)];
In specific this part:

Code: Select all

produce_cargo("GOOD",10)
That says the industry produces 10 units of GOOD every production cycle, regardless of input.

There are two ways to make the industry only produce cargo when something is delivered. The first is default input-output production, the second is via the production callbacks.

If you want the industry to produce 10 items of GOOD every time 1 item of WDPR is delivered, then you'd write it like this:

Code: Select all

cargo_types: [accept_cargo("WDPR", produce_cargo("GOOD", 10))];
Notice that the produce_cargo is inside the parentheses after accept_cargo, that indicates that the cargo is produced when some cargo is accepted.

Production callbacks let you do more advanced things, but in my opinions you shouldn't use them if you don't need them.

Documentation links:
cargo_types array
Produce blocks for production callbacks
User avatar
odisseus
Director
Director
Posts: 552
Joined: 01 Nov 2017 21:19

Re: Served Industries and production question.

Post by odisseus »

Why does your supermarket accept lumber though? This is not how supermarkets work in real life.
User avatar
Quast65
Tycoon
Tycoon
Posts: 2654
Joined: 09 Oct 2011 13:51
Location: The Netherlands

Re: Served Industries and production question.

Post by Quast65 »

odisseus wrote: 11 Jul 2022 07:26 Why does your supermarket accept lumber though? This is not how supermarkets work in real life.
You mean you never have seen Björn and Inga sweating their asses off at the back of the Ikea, sawing wood and putting all of those packs together? ?( :shock: :mrgreen: :tongue:
Projects: http://www.tt-forums.net/viewtopic.php?f=26&t=57266
Screenshots: http://www.tt-forums.net/viewtopic.php?f=47&t=56959
Scenario of The Netherlands: viewtopic.php?f=60&t=87604

Winner of the following screenshot competitions:
sep 2012, jan 2013, apr 2013, aug 2013, mar 2014, mar 2016, oct 2020
All my work is released under GPL-license (either V2 or V3), if not clearly stated otherwise.
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Re: Served Industries and production question.

Post by temporal8 »

Thanks to all for the replys. :bow:
odisseus wrote: 11 Jul 2022 07:26 Why does your supermarket accept lumber though? This is not how supermarkets work in real life.
Ikea manufactures furniture too, in my country there is no ikea but there is "Easy" which is similar and they not only sell furniture but also sell wood or cut the wood for your home project.

Let's say I simplified it and made a sale point / factory all in one.
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Re: Served Industries and production question.

Post by temporal8 »

PikkaBird wrote: 10 Jul 2022 17:51
cargo_types: [accept_cargo("WDPR"),produce_cargo("GOOD",10)];
Try

Code: Select all

cargo_types: [accept_cargo("WDPR", produce_cargo("GOOD",10))];
For the petrol station, "almost similar" does not provide sufficient information to diagnose, but it sounds like you need to turn off the stockpiling mechanic for that industry. Someone who codes industries in NML might be able to help more.
jfs wrote: 10 Jul 2022 17:52 This part:

Code: Select all

cargo_types: [accept_cargo("WDPR"),produce_cargo("GOOD",10)];
In specific this part:

Code: Select all

produce_cargo("GOOD",10)
That says the industry produces 10 units of GOOD every production cycle, regardless of input.

There are two ways to make the industry only produce cargo when something is delivered. The first is default input-output production, the second is via the production callbacks.

If you want the industry to produce 10 items of GOOD every time 1 item of WDPR is delivered, then you'd write it like this:

Code: Select all

cargo_types: [accept_cargo("WDPR", produce_cargo("GOOD", 10))];
Notice that the produce_cargo is inside the parentheses after accept_cargo, that indicates that the cargo is produced when some cargo is accepted.

Production callbacks let you do more advanced things, but in my opinions you shouldn't use them if you don't need them.

Documentation links:
cargo_types array
Produce blocks for production callbacks
Thanks a lot to both guys!

And how would it be in the case that I needed several different cargos to produce only one cargo / material?

In this case IORE produces STEL and SLAG:
accept_cargo("IORE", produce_cargo("STEL", 1), produce_cargo("SLAG", 0.25))

I need to do the opposite.

I have GRAI and LVST and i need to produce FOOD with both of them.

I tried with:

cargo_types: [accept_cargo("GRAI",produce_cargo("FOOD",0.50))];
cargo_types: [accept_cargo("LVST",produce_cargo("FOOD",0.50))];

and it didn't work.
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5656
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Served Industries and production question.

Post by andythenorth »

temporal8 wrote: 13 Jul 2022 00:25 cargo_types: [accept_cargo("GRAI",produce_cargo("FOOD",0.50))];
cargo_types: [accept_cargo("LVST",produce_cargo("FOOD",0.50))];
Try this:

Code: Select all

cargo_types: [
    accept_cargo("GRAI",produce_cargo("FOOD",0.50)), 
    accept_cargo("LVST",produce_cargo("FOOD",0.50))
]; 
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Re: Served Industries and production question.

Post by temporal8 »

andythenorth wrote: 13 Jul 2022 05:40
temporal8 wrote: 13 Jul 2022 00:25 cargo_types: [accept_cargo("GRAI",produce_cargo("FOOD",0.50))];
cargo_types: [accept_cargo("LVST",produce_cargo("FOOD",0.50))];
Try this:

Code: Select all

cargo_types: [
    accept_cargo("GRAI",produce_cargo("FOOD",0.50)), 
    accept_cargo("LVST",produce_cargo("FOOD",0.50))
]; 
Thank you very much, that worked.

And can it be achieved that 2 charges are compulsorily required to produce a single one? because otherwise the player would feed the industry with only one cargo to achieve 0.50 and would avoid supplying the other cargo.

Example, the Coal Mine:

cargo_types: [accept_cargo("WORK",produce_cargo("COAL",0.50)),
accept_cargo("HVEH",produce_cargo("COAL",0.50))];

I want the player to have to provide both cargos, that is qualified workers (WORK) and Heavy Machinery (HVEH) for the mine to produce Coal, and if one of the 2 loads (Hveh or Work) is missing, the mine does not produce.
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
Michpi
Engineer
Engineer
Posts: 62
Joined: 03 Feb 2021 18:51

Re: Served Industries and production question.

Post by Michpi »

temporal8 wrote: 13 Jul 2022 09:25 I want the player to have to provide both cargos, that is qualified workers (WORK) and Heavy Machinery (HVEH) for the mine to produce Coal, and if one of the 2 loads (Hveh or Work) is missing, the mine does not produce.
As far as I know, to achieve this goal you need to use the Produce block.
https://newgrf-specs.tt-wiki.net/wiki/NML:Produce
User avatar
jfs
Tycoon
Tycoon
Posts: 1750
Joined: 08 Jan 2003 23:09
Location: Denmark

Re: Served Industries and production question.

Post by jfs »

Yes, as soon as you want two or more cargo types to be delivered for any production to happen, you need callback-based production.

There's two basic ways to handle it, either timer-based (like FIRS does), or stockpiling. They each have their own points of complexity.
The long example on the above linked page for Produce blocks is for stockpiling, and it's probably more complicated than you need.
User avatar
2TallTyler
Route Supervisor
Route Supervisor
Posts: 495
Joined: 11 Aug 2019 18:15
Contact:

Re: Served Industries and production question.

Post by 2TallTyler »

I use callback production and stockpiling in all my industry sets.

For industries requiring two cargos, you could look at the Hotel in Industries of the Caribbean. Note that NML code blocks can only refer to blocks defined above themselves, so you have to read bottom-to-top.

That said, after building two industry sets (Industries of the Caribbean and Lumberjack Industries) where secondary industries required workers collected from houses, I've moved away from Worker-based economies. CargoDist doesn't know about industry demands so you need manual distribution, which I don't enjoy. My new strategy, which I quite like, is to require passenger service in the industry's parent town. I did this in Improved Town Industries 2.0 (although for my next set I'm going to skip growing primary production towns and use boost cargos delivered to industries instead, and focus on growing secondary production cities) and have some more advanced code using storage registers, procedure switches (essentially functions) and the text stack to provide custom production stats on the industry window.

You might play around with these sets to figure out what game mechanics you like. I'm pretty busy with real-life stuff right now but I'm happy to help when I can with any of this stuff. I'm usually more active on Discord than here, though.
temporal8
Route Supervisor
Route Supervisor
Posts: 429
Joined: 17 May 2019 14:15

Re: Served Industries and production question.

Post by temporal8 »

Thanks a lot guys, i will check it.

I noticed a problem about last's month production statistics, it seems that the values ​​are not saved but are reset to 0 from time to time.
Also note (or at least I think) that one value is tied to the other, that is, if I don't transport the load, 0 always appears in "last month production"
students-0.png
students-0.png (132.1 KiB) Viewed 1429 times

Code: Select all


/* *************************************************
 * Definition of the industry
 * *************************************************/

switch (FEAT_INDUSTRIES, SELF, school_school, industry_distance(school)) { 0 .. 60: return CB_RESULT_LOCATION_DISALLOW; return CB_RESULT_LOCATION_ALLOW; }
switch (FEAT_INDUSTRIES, SELF, school_check_location, ( (extra_callback_info2 == IND_CREATION_FUND) || (extra_callback_info2 == IND_CREATION_PROSPECT) ) ) { 1: return CB_RESULT_LOCATION_ALLOW; school_school; }

        item(FEAT_INDUSTRIES, school, 126) {
            property {
                substitute: 0;
                life_type: IND_LIFE_TYPE_PROCESSING;
                closure_msg: TTD_STR_NEWS_INDUSTRY_CLOSURE_SUPPLY_PROBLEMS;
                prod_increase_msg: TTD_STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_GENERAL;
                prod_decrease_msg: TTD_STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_GENERAL;
                new_ind_msg: TTD_STR_NEWS_INDUSTRY_CONSTRUCTION;
                min_cargo_distr: 5;
                map_colour: 49;
		spec_flags: bitmask(IND_FLAG_LONG_CARGO_TYPE_LISTS,IND_FLAG_ONLY_IN_TOWNS);
                layouts:
[
    school_industry_layout_1_tilelayout,
];
                conflicting_ind_types: []; // set this prop empty, FIRS has it's own better checks for this
                name: string(STR_IND_school);
                nearby_station_name: string(STR_STATION, string(STR_TOWN));
                prob_map_gen:5;
                prob_random: 13;
                prob_in_game: 6;
                prospect_chance: 0.75;
                fund_cost_multiplier: 1;
                remove_cost_multiplier: 0;
		cargo_types: [accept_cargo("FOOD",produce_cargo("TRSH",1)),accept_cargo("PASS",produce_cargo("STUD",0.50))];
            }
        }

item(FEAT_INDUSTRIES, school, 126) {
 graphics {
 		extra_text_industry: return string(STR_EXTRA_school);
		location_check: school_check_location;
 }
}

/***************************
 END school
****************************/
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
User avatar
2TallTyler
Route Supervisor
Route Supervisor
Posts: 495
Joined: 11 Aug 2019 18:15
Contact:

Re: Served Industries and production question.

Post by 2TallTyler »

It's not possible for NewGRFs to change the displayed production stats. Are you sure it's not just the month changing without you having delivered any of the input cargo?
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 3 guests