Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Nov 19, 2018 12:36 pm

All times are UTC




Post new topic  Reply to topic  [ 23 posts ]  Go to page 1 2 Next
Author Message
 Post subject: About NFO
PostPosted: Sat Jul 01, 2017 12:44 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Thu Jun 01, 2017 10:03 am
Posts: 209
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.

_________________
Sent from my Ubuntu 16.04 LTS


Top
   
 Post subject: Re: About NFO
PostPosted: Sat Jul 01, 2017 6:33 pm 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 7200
check https://newgrf-specs.tt-wiki.net/wiki/A ... s_.281C.29

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
 Post subject: Re: About NFO
PostPosted: Sat Jul 01, 2017 7:00 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 290
More specifically, since the link goes to the bottom of the page.

Miscellaneous flags (1C)

This is a bit mask, with the following bits:
Code:
Bit     Value   Meaning
0        1        Vehicle is a tram/light rail vehicle and requires tram tracks to operate
...


Top
   
 Post subject: Re: About NFO
PostPosted: Sat Jul 01, 2017 10:35 pm 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 7200
Cadde wrote:
the link goes to the bottom of the page.


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.

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
 Post subject: Re: About NFO
PostPosted: Sat Jul 01, 2017 10:43 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 290
My "weird browser" has nothing to do with it.

Image

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.


Top
   
 Post subject: Re: About NFO
PostPosted: Sun Jul 02, 2017 12:46 am 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 7200
oh, so your problem is just that your window is huge and your font size is tiny...

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
 Post subject: Re: About NFO
PostPosted: Sun Jul 02, 2017 8:50 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 290
Or, maybe my problem is i am not of < peasant class. ;)


Top
   
 Post subject: Re: About NFO
PostPosted: Mon Jul 03, 2017 7:45 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Thu Jun 01, 2017 10:03 am
Posts: 209
Thank you everyone.
My browser is also Very Poor,so I didn't realize that.

_________________
Sent from my Ubuntu 16.04 LTS


Top
   
 Post subject: Re: About NFO
PostPosted: Tue Jul 04, 2017 9:02 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Thu Jun 01, 2017 10:03 am
Posts: 209
By the way, why everyone says that nml is better than nfo?
Is it easier or more convenient?

_________________
Sent from my Ubuntu 16.04 LTS


Top
   
 Post subject: Re: About NFO
PostPosted: Tue Jul 04, 2017 10:53 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4677
Location: home
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.

_________________
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.


Top
   
 Post subject: Re: About NFO
PostPosted: Tue Jul 04, 2017 1:45 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 290
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.


Top
   
 Post subject: Re: About NFO
PostPosted: Wed Jul 05, 2017 7:52 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Thu Jun 01, 2017 10:03 am
Posts: 209
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.

_________________
Sent from my Ubuntu 16.04 LTS


Top
   
 Post subject: Re: About NFO
PostPosted: Wed Jul 05, 2017 7:55 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Thu Jun 01, 2017 10:03 am
Posts: 209
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


Top
   
 Post subject: Re: About NFO
PostPosted: Wed Jul 05, 2017 9:17 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 290
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.

  • The GRF header. (https://newgrf-specs.tt-wiki.net/wiki/N ... parameters)
    Code:
    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.
    Code:
    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]
    }

    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
    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:
    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
    As you can see, the properties are the same as they are in NFO, they just carry names instead of hexadecimal id's. Thus making it much easier to see what's what and what is being assigned.
  • Fine tuning and possible callbacks etc. (totally optional)

It's that "simple" really. Either way, it's much simpler than using NFO. It's also faster to set up and make future edits for. It compiles into an optimized GRF file to the best of NML's abilities. Thus saving you the hassle of all of the hex editing etc.
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:
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;
    }
}


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:
Code:
##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


And your graphics may... Or may not... Be based on:
Image

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


Top
   
 Post subject: Re: About NFO
PostPosted: Wed Jul 05, 2017 11:26 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4677
Location: home
I agree there could be more or better NML tutorials. Feel free to make some, it's a wiki

_________________
Being a OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.


Top
   
 Post subject: Re: About NFO
PostPosted: Wed Jul 05, 2017 12:00 pm 
Offline
Tycoon
Tycoon

Joined: Wed Apr 27, 2005 7:09 am
Posts: 5237
@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

_________________
Image


Top
   
 Post subject: Re: About NFO
PostPosted: Thu Jul 06, 2017 10:50 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Thu Jun 01, 2017 10:03 am
Posts: 209
Thank you very much.
I think nfo is confusing, and nml is too long.
Maybe m4nfo is the best idea.

_________________
Sent from my Ubuntu 16.04 LTS


Top
   
 Post subject: Re: About NFO
PostPosted: Thu Jul 06, 2017 1:08 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Oct 07, 2004 12:51 pm
Posts: 290
Hey, at least you don't have to code them into the OTTD sources directly.


Top
   
 Post subject: Re: About NFO
PostPosted: Sat Jul 08, 2017 6:23 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Thu Jun 01, 2017 10:03 am
Posts: 209
I downloaded newgrf source from the internet, but how can i edit it with M4NFO?

_________________
Sent from my Ubuntu 16.04 LTS


Top
   
 Post subject: Re: About NFO
PostPosted: Sun Jul 09, 2017 6:12 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4677
Location: home
ir1n1o57 wrote:
I downloaded newgrf source from the internet, but how can i edit it with M4NFO?
Not, unless it was written with m4nfo in the first place (which very few sets are, afaik).

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 OpenTTD developer does not mean I know what I am doing.
Also, other OpenTTD developers may have different opinions.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 23 posts ]  Go to page 1 2 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.