NML - a Newgrf Meta Language

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

Moderator: Graphics Moderators

Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML - a Newgrf Meta Language

Post by Yexo »

I have some first basic code for that that can decode very simple newgrfs, but I won't commit that before 0.1 is out. For 0.1 we want support for all action0 properties and varaction2 variables first, which is still a lot of work. On the other hand we're getting closer and closer to the 0.1 release, but I can't really give a timeframe.
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: NML - a Newgrf Meta Language

Post by keoz »

Yexo wrote:I have some first basic code for that that can decode very simple newgrfs, but I won't commit that before 0.1 is out. For 0.1 we want support for all action0 properties and varaction2 variables first, which is still a lot of work. On the other hand we're getting closer and closer to the 0.1 release, but I can't really give a timeframe.
Ok, thank you. I never coded grf's until now, but was thinking about making some, in a near future. But obviously, if I can use a "human" language, instead of learning some asm-simili-code, it is really better.
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
User avatar
jvassie
Tycoon
Tycoon
Posts: 3421
Joined: 18 Dec 2002 18:00
Location: High Wycombe, England
Contact:

Re: NML - a Newgrf Meta Language

Post by jvassie »

What scope is there with the language currently in terms of coding stations please?
(British) Modular Stations Set - Thread: | Website:
Swiss Set - Thread: | Website:
Route Map Creator
My Screenshot Thread
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NML - a Newgrf Meta Language

Post by planetmaker »

I fear that stations are a missing feature so far... :-(
Implemented are features so far: 0,1,2,3,9,A,D,10 and 11 (=vehicles,industries and industry tiles, airports and airport tiles and railtypes)
User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: NML - a Newgrf Meta Language

Post by Ammler »

afaik, "they" implement that first, what someone is asking them, so if you "signal" to code stations with nml, they might move the priority for it ;-)

just join #openttdcoop.devzone and speak to one of the devs

BTW. I am no nml dev, so my words are just guesses, no warranty ;-)

Greets
Ammler
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML - a Newgrf Meta Language

Post by Yexo »

That is true to a certain extend, which area is the most interesting also has influence :). For stations I first have to figure out how they work exactly in nfo, especially when dealing with multi-tile stations.
User avatar
Valance
Engineer
Engineer
Posts: 28
Joined: 06 Feb 2007 07:17

Re: NML - a Newgrf Meta Language

Post by Valance »

NML is awesome :)

Code: Select all

grf {
    grfid : "MAF0";
    name : string(STR_GRF_NAME);
    desc : string(STR_GRF_DESCRIPTION);
}

spriteblock(FEAT_INDUSTRYTILES) {
    spritegroup forrest_tree_1_normal {
        ground { ttdsprite: 2077; }
        building {
            ttdsprite: 2072;
        }
    }

    spritegroup forrest_tree_2_normal {
        ground { ttdsprite: 2077; }
        building {
            ttdsprite: 2073;
        }
    }

    spritegroup forrest_tree_3_normal {
        ground { ttdsprite: 2077; }
        building {
            ttdsprite: 2074;
        }
    }

    spritegroup forrest_tree_4_normal {
        ground { ttdsprite: 2077; }
        building {
            ttdsprite: 2075;
        }
    }

    spriteset(forrest_tree_1_snow_set, "sprites/ogfxc_arctic.png") {
        [466, 1832, 51, 39, -24, -13]
    }

    spritegroup forrest_tree_1_snow {
        ground { ttdsprite: GROUNDSPRITE_SNOW; }
        building {
            sprite: forrest_tree_1_snow_set;
        }
    }

    spriteset(forrest_tree_2_snow_set, "sprites/ogfxc_arctic.png") {
        [530, 1832, 56, 52, -28, -24]
    }

    spritegroup forrest_tree_2_snow {
        ground { ttdsprite: GROUNDSPRITE_SNOW; }
        building {
            sprite: forrest_tree_2_snow_set;
        }
    }

    spriteset(forrest_tree_3_snow_set, "sprites/ogfxc_arctic.png") {
        [594, 1832, 62, 61, -30, -33]
    }

    spritegroup forrest_tree_3_snow {
        ground { ttdsprite: GROUNDSPRITE_SNOW; }
        building {
            sprite: forrest_tree_3_snow_set;
        }
    }

    spriteset(forrest_tree_4_snow_set, "sprites/ogfxc_arctic.png") {
        [674, 1832, 60, 72, -28, -44]
    }

    spritegroup forrest_tree_4_snow {
        ground { ttdsprite: GROUNDSPRITE_SNOW; }
        building {
            sprite: forrest_tree_4_snow_set;
        }
    }
}

// No idea how to make original forrest animation (growing trees), so it's just a test xD

random_switch(FEAT_INDUSTRYTILES, SELF, forrest_trees_normal, TRIGGER_INDUSTRYTILE_256_TICKS) {
    1: forrest_tree_1_normal;
    1: forrest_tree_2_normal;
    1: forrest_tree_3_normal;
    6: forrest_tree_4_normal;
}

random_switch(FEAT_INDUSTRYTILES, SELF, forrest_trees_snow, TRIGGER_INDUSTRYTILE_256_TICKS) {
    1: forrest_tree_1_snow;
    1: forrest_tree_2_snow;
    1: forrest_tree_3_snow;
    6: forrest_tree_4_snow;
}

// Decide whether to use normal or snow sprites

switch(FEAT_INDUSTRYTILES, SELF, forrest, terrain_type) {
    0..3: forrest_trees_normal;
    forrest_trees_snow;
}

item(FEAT_INDUSTRYTILES, forrest_tiles, 0x10) {
    property {
        substitute: 16;
        override: 16;
    }

    graphics {
        forrest;
    }
}
Really good work!
User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: NML - a Newgrf Meta Language

Post by Ammler »

maybe people would like to see the result? :-)
User avatar
Valance
Engineer
Engineer
Posts: 28
Joined: 06 Feb 2007 07:17

Re: NML - a Newgrf Meta Language

Post by Valance »

Oki doki^^

Two screens and the .grf should be enough to see it in action ;)

Oh, I had to add these lines to actions/action2var_variables.py:

Code: Select all

varact2vars_industrytiles = {
    'terrain_type' : {'var': 0x41, 'start': 0, 'size': 8},
    'town_radius_group': {'var': 0x42, 'start': 0, 'size': 3},
    'relative_pos': {'var': 0x43, 'start': 0, 'size': 24},
    'animation_frame': {'var': 0x44, 'start': 0, 'size': 8},
}
...
varact2vars[0x09] = varact2vars_industrytiles
Attachments
snowy-forest.grf
(6.52 KiB) Downloaded 183 times
Unbenannt, 7. Apr 1950.png
Unbenannt, 7. Apr 1950.png (133.69 KiB) Viewed 940 times
Unbenannt, 8. Okt 1950.png
Unbenannt, 8. Okt 1950.png (134.46 KiB) Viewed 940 times
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: NML - a Newgrf Meta Language

Post by Lord Aro »

Morning all!

I have decided to see if i can give NewGRF-ing a go, but am struggling to install it properly
Is there a guide or even just a list of packages needed to install?
I'm on ubuntu 10.04 (10.10 coming soon! :mrgreen: )

PS i have read the reference.htm :wink:
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML - a Newgrf Meta Language

Post by Yexo »

python
python-imaging
ply (from http://www.dabeaz.com/ply/ )

I hope I didn't forget anything.
User avatar
Lakie
TTDPatch Developer
TTDPatch Developer
Posts: 1799
Joined: 26 May 2004 16:37
Location: Britain
Contact:

Re: NML - a Newgrf Meta Language

Post by Lakie »

Been looking over nml for objects support, I've noticed two things that stop basic objects compiling:
  • Action2 layouts are not allowed for them,
  • Action0's size property function's return is incorrect, it should be "<< 4" and not "<< 8".
Could I also request the action0 property for object name is changed from "build_window_caption" to either "name" or "objectname" for objects?

~ Lakie
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML - a Newgrf Meta Language

Post by Yexo »

All three done, I hope it works now.
User avatar
Lakie
TTDPatch Developer
TTDPatch Developer
Posts: 1799
Joined: 26 May 2004 16:37
Location: Britain
Contact:

Re: NML - a Newgrf Meta Language

Post by Lakie »

Yup, working quite nicely now, however, I have a few observations about the nfo code it generates;
  • It generates multiple Action14s when surely it only needs one?
  • Similarly it generates multiple Action4's when they could be merged.
  • It outputs an Action1 even though no new sprites are loaded.
  • Is there any particular reason that switch blocks will always use dword action2var sizes (89/8A)?
  • It appears not support the first format of Action2 Tile Layouts, which has the option of no building sprite.
I'm probably being somewhat too critical though,
~ Lakie
TTDpatch Developer 2005 - 2010 ~ It all started because of shortened vehicle not loading correctly, now look where I've gone with it!
Grfs coded ~ Finnish Train Set (Teaser) | Bm73 (Release 3) | Emu 680 (Release 3)| Glass Station (Release 1) | UK Roadset (Version 1.1a) | New Water Coasts (Version 7)
Pikka: "Lakie's a good coder, but before he'll add any feature to TTDP you have to convince him that you're not going to use it to destroy the world as we know it."
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: NML - a Newgrf Meta Language

Post by Hirundo »

Thanks for your comments, it's information like this that helps us build a better compiler.
Lakie wrote:
  • It outputs an Action1 even though no new sprites are loaded.
  • It appears not support the first format of Action2 Tile Layouts, which has the option of no building sprite.
Fixed in r859/859.
Lakie wrote:
  • Is there any particular reason that switch blocks will always use dword action2var sizes (89/8A)?
The main reason is that it required the least amount of thinking / coding. For switch blocks with only single byte/word variable accesses a smaller size would do, but that's currently not implemented. Is there any specific reason to use byte/word sizes for TTDPatch?
Lakie wrote:
  • It generates multiple Action14s when surely it only needs one?
  • Similarly it generates multiple Action4's when they could be merged.
I opened a ticket about this.
Create your own NewGRF? Check out this tutorial!
dandan
Route Supervisor
Route Supervisor
Posts: 414
Joined: 17 Feb 2008 23:01

Re: NML - a Newgrf Meta Language

Post by dandan »

I have started to do a bit of coding in NML a few days ago. I really have to congratulate you guys. Outstanding work, I am very impressed. I have had a lot of fun with NFO, but for new projects I will definitely switch to NML. Well done!

I have only one little question so far, but decided to put that directly on the bug tracker :P
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: NML - a Newgrf Meta Language

Post by planetmaker »

EDIT: removed code which only works for some corner cases. See Yexo's posting below for a proper solution.
Last edited by planetmaker on 27 Oct 2010 09:23, edited 1 time in total.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML - a Newgrf Meta Language

Post by Yexo »

While that works, it's a hack and the proper code also works:

Code: Select all

    graphics {
        0xFF: toyland_passenger_rail_group;
        normal_passenger_switch;
    }
Code from ogfx-trains, modified to always use the toyland graphics in the menu.
dandan
Route Supervisor
Route Supervisor
Posts: 414
Joined: 17 Feb 2008 23:01

Re: NML - a Newgrf Meta Language

Post by dandan »

I would have sworn I tried that and it did not work, but of course it does. :oops:

Thank you both.
User avatar
xenon
Engineer
Engineer
Posts: 89
Joined: 04 Nov 2010 12:28
Location: Russia. moscow region
Contact:

Re: NML - a Newgrf Meta Language

Post by xenon »

how to install it??? :oops: :oops:
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 3 guests