About NFO
Moderator: Graphics Moderators
- DeletedUser10
- Traffic Manager
- Posts: 204
- Joined: 01 Jun 2017 10:03
About NFO
I'm now learning coding NFO.
I want to code a tram Grf, but how to modify that whether it will be normal rv or be a tram?
I looked up the NFO tutorial but it didn't help.
I want to code a tram Grf, but how to modify that whether it will be normal rv or be a tram?
I looked up the NFO tutorial but it didn't help.
Sent from my Ubuntu 16.04 LTS
Re: About NFO
More specifically, since the link goes to the bottom of the page.
Miscellaneous flags (1C)
This is a bit mask, with the following bits:
Miscellaneous flags (1C)
This is a bit mask, with the following bits:
Code: Select all
Bit Value Meaning
0 1 Vehicle is a tram/light rail vehicle and requires tram tracks to operate
...
Re: About NFO
what are you talking about? you must have a weird browser. i've seen browsers mess up page positioning when they're zoomed. my browser takes me to the exact lines you quoted.Cadde wrote:the link goes to the bottom of the page.
Re: About NFO
My "weird browser" has nothing to do with it.
If one doesn't know what to look for, following that link could make them think it's got something to do with callbacks.
But, i can see how it could have something to do with a weird resolution. If you are using an 800x600 pixel screen then it would kinda end up at the top when following said link.
If one doesn't know what to look for, following that link could make them think it's got something to do with callbacks.
But, i can see how it could have something to do with a weird resolution. If you are using an 800x600 pixel screen then it would kinda end up at the top when following said link.
Re: About NFO
oh, so your problem is just that your window is huge and your font size is tiny...
Re: About NFO
Or, maybe my problem is i am not of < peasant class.
- DeletedUser10
- Traffic Manager
- Posts: 204
- Joined: 01 Jun 2017 10:03
Re: About NFO
Thank you everyone.
My browser is also Very Poor,so I didn't realize that.
My browser is also Very Poor,so I didn't realize that.
Sent from my Ubuntu 16.04 LTS
- DeletedUser10
- Traffic Manager
- Posts: 204
- Joined: 01 Jun 2017 10:03
Re: About NFO
By the way, why everyone says that nml is better than nfo?
Is it easier or more convenient?
Is it easier or more convenient?
Sent from my Ubuntu 16.04 LTS
Re: About NFO
Both I think. Being able to use readable text to know what property you change helps in avoiding mistakes.
nml also handles conversion of normal infix expressions to nfo codes, and does constant folding.
nml also handles conversion of normal infix expressions to nfo codes, and does constant folding.
Being a retired OpenTTD developer does not mean I know what I am doing.
Re: About NFO
Indeed, NML is a "human readable" format whereas NFO is more along the lines of machine code.
The only advantage NFO has over NML is that NFO (or even hex editing the GRF) has some features that NML doesn't have yet. Or that's my understanding of it anyways.
If you are adding trams, then NML is going to be more than enough for your project.
At the end of the day, NML and NFO both turn into the same product. A grf file.
The only advantage NFO has over NML is that NFO (or even hex editing the GRF) has some features that NML doesn't have yet. Or that's my understanding of it anyways.
If you are adding trams, then NML is going to be more than enough for your project.
At the end of the day, NML and NFO both turn into the same product. A grf file.
- DeletedUser10
- Traffic Manager
- Posts: 204
- Joined: 01 Jun 2017 10:03
Re: About NFO
The NML tutorial is too hard to understand, so I chose NFO even it is outdated.
There is no sample code on the nml tutorial.
There is no sample code on the nml tutorial.
Sent from my Ubuntu 16.04 LTS
- DeletedUser10
- Traffic Manager
- Posts: 204
- Joined: 01 Jun 2017 10:03
Re: About NFO
By the way, what will happen if I decompile grf made with nml using grfcodec, what kind of file will be outputed?
Sent from my Ubuntu 16.04 LTS
Re: About NFO
An NFO file, albeit without the formatting. It's a real PITA to read an NFO decoded by grfcodec.
I get it, there's hardly any tutorials on NML. I had problems in the beginning too!
But since you've been learning NFO, NML should be rather simple. You know what's needed, all you need to know now is what to type.
So, you want to add a tram in NML? Here's a list of the things you need.
Compared to NFO, simple really IS simple. Compared to say eating a hamburger, NML still is rather complex but at least it's human readable.
CONCLUSION
Your final NML file may (or may not) look like:
And at that point, all that's left to do is create a "lang" folder with "english.lng" (and other languages as you see fit) and a "gfx" folder with the respective sprite graphics in it.
Your language (english.lng) file may... Or may not... Look like:
And your graphics may... Or may not... Be based on:
As i said, i leave the graphics editing to others.
NB: I reserve the right to be wrong. There may have been a number of mistakes made. This was merely constructed out of my memory and checking a few sources along the way.
EDIT: Oh and the NMLC repository does contain a number of samples.
Here's the repository: https://hg.openttdcoop.org/nml
And here's a sample road vehicle NML file: https://hg.openttdcoop.org/nml/files/af ... ehicle.nml
I get it, there's hardly any tutorials on NML. I had problems in the beginning too!
But since you've been learning NFO, NML should be rather simple. You know what's needed, all you need to know now is what to type.
So, you want to add a tram in NML? Here's a list of the things you need.
- The GRF header. (https://newgrf-specs.tt-wiki.net/wiki/N ... parameters)
Code: Select all
grf { grfid: "ABC\01"; name: string(STR_GRF_NAME); desc: string(STR_GRF_DESCRIPTION); version: 1; min_compatible_version: 0; }
- grfid - The unique 4 character identifier of your GRF. No different from the NFO equivalent. (https://newgrf-specs.tt-wiki.net/wiki/Action8#GRFID)
- name - The text that's supposed to be shown in the newgrf settings window. As well as in some other irrelevant places. The "string(...)" statement here refers to an entry in a language file. (https://newgrf-specs.tt-wiki.net/wiki/N ... uage_files)
- desc - The description as shown in the information panel when you select the grf in the newgrf settings window. Again, using the "string(...)" statement from before.
- version - The GRF file version. Letting the game know which file to use if there's duplicates etc. Or just letting the user see which version he's using and thusly being able to report issues with that version rather than just guessing.
- min_compatible_version - The version of OTTD that this GRF file is compatible against. And so should be beyond. As grf specs have changed in ottd versions past, your grf may be using features that didn't exist before that specific version. Technically speaking, you should set the number to the current OTTD revision you've been testing against.
- The sprites.
spritesets are something i haven't bothered learning about myself yet. You can read about them here: https://newgrf-specs.tt-wiki.net/wiki/NML:Spriteset
Code: Select all
spriteset (spriteset_tram_Le_Tram_Mk1, "gfx/Le_Tram_Mk1.png") { [0, 0, 16, 16, 0, -3] } spriteset (spriteset_tram_Le_Tram_Mk1_purchase, "gfx/Le_Tram_Mk1.png") { [0, 17, 16, 16, 0, -3] }
I would recommend using templates, you can find out more in the link. Templates are another powerful feature of NML that NFO does not provide. - The item(s)
Code: Select all
item(FEAT_ROADVEHS, item_tram_Le_Tram_Mk1) { property { name: string(STR_LE_TRAM_MK1); misc_flags; bitmask(ROADVEH_FLAG_TRAM, ROADVEH_FLAG_2CC); introduction_date: date(1935,1,1); model_life: 35; vehicle_life: 15; cost_factor: 25; running_cost_factor: 22; speed: 32 km/h; power: 15 hp; cargo_capacity: 20; weight: 10 ton; sprite_id: SPRITE_ID_NEW_ROADVEH; ... etc } graphics { purchase: spriteset_tram_Le_Tram_Mk1_purchase; spriteset_tram_Le_Tram_Mk1; } }
- misc_flags - The one you were asking about. Setting this to a bitmask like above is the same as setting it = 3 in NFO (Bit 0 and Bit 1 set)
- graphics block - This can be used to define callbacks, the "complicated ones" are out of the scope of this quick guide.
You have already defined the sprite sets earlier. Here you declare which sprites the vehicle will use.
purchase - The sprite to be used for purchase.
The default callback is the sprite of the vehicle in the world. - OTHERS - I refer you to the documentation: https://newgrf-specs.tt-wiki.net/wiki/N ... properties
- Fine tuning and possible callbacks etc. (totally optional)
Compared to NFO, simple really IS simple. Compared to say eating a hamburger, NML still is rather complex but at least it's human readable.
CONCLUSION
Your final NML file may (or may not) look like:
Code: Select all
grf {
grfid: "ABC\01";
name: string(STR_GRF_NAME);
desc: string(STR_GRF_DESCRIPTION);
version: 1;
min_compatible_version: 0;
}
graphics {
purchase: spriteset_tram_Le_Tram_Mk1_purchase;
spriteset_tram_Le_Tram_Mk1;
}
spriteset (spriteset_tram_Le_Tram_Mk1, "gfx/Le_Tram_Mk1.png")
{
[0, 0, 16, 16, 0, -3]
}
spriteset (spriteset_tram_Le_Tram_Mk1_purchase, "gfx/Le_Tram_Mk1.png")
{
[0, 17, 16, 16, 0, -3]
}
item(FEAT_ROADVEHS, item_tram_Le_Tram_Mk1) {
property {
name: string(STR_LE_TRAM_MK1);
misc_flags; bitmask(ROADVEH_FLAG_TRAM, ROADVEH_FLAG_2CC);
introduction_date: date(1935,1,1);
model_life: 35;
vehicle_life: 15;
cost_factor: 25;
running_cost_factor: 22;
speed: 32 km/h;
power: 15 hp;
cargo_capacity: 20;
weight: 10 ton;
sprite_id: SPRITE_ID_NEW_ROADVEH;
... etc
}
graphics {
purchase: spriteset_tram_Le_Tram_Mk1_purchase;
spriteset_tram_Le_Tram_Mk1;
}
}
Your language (english.lng) file may... Or may not... Look like:
Code: Select all
##grflangid 0x01
# This is the English language file
# GRF name and description definitions
STR_GRF_NAME :Le tram (v0.01)
STR_GRF_DESCRIPTION :Le super awesome Le Tram Mk1 from Le internets.
STR_LE_TRAM_MK1 :Le Tram 'Baguette' Mk. 1
As i said, i leave the graphics editing to others.
NB: I reserve the right to be wrong. There may have been a number of mistakes made. This was merely constructed out of my memory and checking a few sources along the way.
EDIT: Oh and the NMLC repository does contain a number of samples.
Here's the repository: https://hg.openttdcoop.org/nml
And here's a sample road vehicle NML file: https://hg.openttdcoop.org/nml/files/af ... ehicle.nml
Re: About NFO
I agree there could be more or better NML tutorials. Feel free to make some, it's a wiki
Being a retired OpenTTD developer does not mean I know what I am doing.
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: About NFO
@ir1n1o57
There´s also m4nfo a high-level frontend producing efficient nfo code. It is small and fast, user-expandable, and provides full access to the underlying M4 macro processor, thus allows for all types of templating applications. There´s a user guide including a number of tutorials on its home page.
regards
Michael
There´s also m4nfo a high-level frontend producing efficient nfo code. It is small and fast, user-expandable, and provides full access to the underlying M4 macro processor, thus allows for all types of templating applications. There´s a user guide including a number of tutorials on its home page.
regards
Michael
- DeletedUser10
- Traffic Manager
- Posts: 204
- Joined: 01 Jun 2017 10:03
Re: About NFO
Thank you very much.
I think nfo is confusing, and nml is too long.
Maybe m4nfo is the best idea.
I think nfo is confusing, and nml is too long.
Maybe m4nfo is the best idea.
Sent from my Ubuntu 16.04 LTS
Re: About NFO
Hey, at least you don't have to code them into the OTTD sources directly.
- DeletedUser10
- Traffic Manager
- Posts: 204
- Joined: 01 Jun 2017 10:03
Re: About NFO
I downloaded newgrf source from the internet, but how can i edit it with M4NFO?
Sent from my Ubuntu 16.04 LTS
Re: About NFO
Not, unless it was written with m4nfo in the first place (which very few sets are, afaik).ir1n1o57 wrote:I downloaded newgrf source from the internet, but how can i edit it with M4NFO?
If you download source from the net, you do have to be able to understand and work in that source language.
This is not different from needing a Windows system when you download a Windows program, and a Unix system when you download a Unix program.
Being a retired OpenTTD developer does not mean I know what I am doing.
Who is online
Users browsing this forum: No registered users and 31 guests