Page 1 of 1

How to start with new grf?

Posted: 05 Jul 2017 19:41
by Rodimax
Hello!

I want to develop newGRF's for OTTD. I searched for tutorials, found a few of them, but nothing that can really help. I want to make an industry, (similar to bank), producing something, what I can transport outside the city. So I begin my GRF like this:
[+] Spoiler
grf {
grfid: "HT\01\01";
name: string(STR_GRF_NAME);
desc: string(STR_GRF_DESCRIPTION);
version: 0;
min_compatible_version: 0;
}

cargotable {
TOYS
}

item (FEAT_INDUSTRIES, garbage_collector) {
property {
substitute: INDUSTRYTYPE_TOWN;
layouts: IND_LIFE_TYPE_PROCESSING;
closure_msg: TTD_STR_NEWS_INDUSTRY_CLOSURE_GENERAL;
prod_increase_msg:TTD_STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_GENERAL;
prod_decrease_msg:TTD_STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_GENERAL;
fund_cost_multiplier: 2;
prod_cargo_types: cargotype(TOYS);
prod_multiplier: 2;
min_cargo_distr: 1;
prob_random: 255;
prob_map_gen: 255;
prob_in_game: 255;
spec_flags: bitmask(IND_FLAG_ONLY_IN_TOWNS);
map_colour: 0;
name: string(STR_GRF_NAME);
nearby_station_name: string(STR_GRF_NAME);
}
}
At compile I get this error: "[Knmlc ERROR: "mygrf.nml", line 21: Cargo list must be an array with no more than 2 values"

Okay, I think I looking for what NML means an array. And I found nothing. But thats not all. There is not a single tutorial for this. How can I do this?

Re: How to start with new grf?

Posted: 05 Jul 2017 20:41
by Cadde
Replace...

Code: Select all

prod_cargo_types: cargotype(TOYS);
with...

Code: Select all

prod_cargo_types: [cargotype(TOYS)];
And later, if you want more cargotypes...

Code: Select all

prod_cargo_types: [cargotype(TOYS), cargotype(BOYS)];

Re: How to start with new grf?

Posted: 06 Jul 2017 05:27
by Rodimax
Cadde wrote:Replace...

Code: Select all

prod_cargo_types: cargotype(TOYS);
with...

Code: Select all

prod_cargo_types: [cargotype(TOYS)];
And later, if you want more cargotypes...

Code: Select all

prod_cargo_types: [cargotype(TOYS), cargotype(BOYS)];

okay, so it must been prod_cargo_types: [TOYS, ...].

Thanks!

I have a second question realated to this. Ia I said I want to create a custom industry. Is there any tutorial for that?

Re: How to start with new grf?

Posted: 06 Jul 2017 10:16
by Cadde
Not that i know of no, but i assume you know what you want your industry to do. Right?
And you already have the necessary properties and sprites set up for that industry?

Then you go over the nml documentation and find stuff that's relevant to your interests. If you can't find an answer on the Wiki or here on the forums then do ask.

I am pretty sure a lot of people have gone through the basics of NML without a tutorial and once they know NML well enough to write a tutorial, they don't feel like writing a tutorial. :P

Re: How to start with new grf?

Posted: 06 Jul 2017 21:08
by rowdog

Code: Select all

layouts: IND_LIFE_TYPE_PROCESSING;
That's incorrect, layouts is used to layout the tiles for graphical display while IND_LIFE_TYPE_xxx is for defining the life_type of the industry.

At some point in my learning I turned from tutorials to looking at how other people have dealt with the topic of concern. For industries, I learned a lot from Yeti and OpenGFX+ Industries. This Yeti page is as close to a tutorial as I have seen:
http://dev.openttdcoop.org/projects/yeti/wiki/Code

To some extent, I view most of the OpenGFX+ code as tutorial: they are examples of how to do it right with minor variations from vanilla.
http://dev.openttdcoop.org/projects/ogfx-industries

A lot of projects use build systems that can make it harder for to a beginner to understand so here's a simplified but functional oil well that I wrote when I was first getting started with industries.