NML - a Newgrf Meta Language

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

Moderator: Graphics Moderators

User avatar
GarryG
Tycoon
Tycoon
Posts: 5893
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

changing the ground tiles in the gfx to transparent blue?
I tried doing that with not much luck .. the signal boxes etc will build on a normal ground tile, but when move the screen the graphics play up like shown above.

I thought maybe because my images might be to close to the edge of tiles, so I centred them, but still same problem.

Building on a coloured basetile of sand, gravel etc do not have the graphics problem, only those place on a transparent blue causes the problem.
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
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 »

Ground tiles must never be transparent. If you change the default ground tiles to transparent (or part of them), then graphics drawing errors are asked for as updating the screen fails when scrolling due to transparency: there simply is nothing to use to overpaint the previously painted buildings then. The same argument holds true, if you define transparent ground tiles for any objects like industries, objects, rails, airports, houses or such.
User avatar
GarryG
Tycoon
Tycoon
Posts: 5893
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

The question is then what do I need to change in the code so not need back ground tiles? I tried different ideas that I could think off and none of them work.

If I remove the Switches what tells it to use the ground tiles, it still places the buildings on a grey tile.
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
Supercheese
Tycoon
Tycoon
Posts: 1660
Joined: 16 Dec 2007 22:24
Location: Idaho, USA

Re: NML - a Newgrf Meta Language

Post by Supercheese »

You could use: sprite: GROUNDSPRITE_NORMAL in your spritelayouts.

You still might need to deal with slopes, snow, etc., but for just flat groundsprites that should work.
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
User avatar
GarryG
Tycoon
Tycoon
Posts: 5893
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Thank you Supercheese .. I tried that command before, but didn't do it right so thought I was on the wrong track, and got derailed. Many thanks to you I been re-railed. All working great now.

Hope you and everyone else in these forums have a fantastic New Year.
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
User avatar
dirace
Engineer
Engineer
Posts: 27
Joined: 29 Jan 2010 11:39

Re: NML - a Newgrf Meta Language

Post by dirace »

you know, if there are sevral multipule zoom level of different type vehicles in gfx file, although the correnspond sprite size is same, but the align of real vehicles pictures maybe differ serveal pixels, after all, different vehicles has different appearance.
for coding, I have known use the template:

Code: Select all

template <identifier>([<arg1> [, <arg2> [, <arg3>...]]]) {
	<list_of_realsprites>
}
for <list_of_realsprites>, I follow the tutorial in wiki like

Code: Select all

 [left_x, upper_y, width, height, offset_x, offset_y]
but since the offset maybe differ a little pixels for different vehiciles, use this matrix for all vehiciles maybe lead some specific vehicles align problem in game.
so, I notice that the template also can use like

Code: Select all

[offset_x, offset_y]
, could it means that the offset matrix can be used alone, and combine with basic matrix like

Code: Select all

[left_x, upper_y, width, height]
? in this way, coder can only adjust the offset matrix for different vechiles.
what scenario this offset matrix be used in?
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 »

Generally, if you use a vehicle with a different length, you should use a different template.
offset_x and offset_y are used to position the sprite. All sprites have a certain origin, e.g. for (full-length) vehicles this is the center of the vehicle. offset_x and offset_y define the position of the top-left corner of the sprite relative to this origin. Values are often negative.
. Thus they are used to define the coordinates of the top left pixel relative to the centre of the vehicle.

However it's no problem to stack templates, thus making a meta-template and then creating another which is derived from that. In that process you could use a size parameter which is used as some scaling factor in a formula where you derive the size and positions from it. Personally I found it often more visually satisfying to create separate templates for separate sizes instead of creating the jack-of-all-trades template, though.
User avatar
Emperor Jake
Tycoon
Tycoon
Posts: 3427
Joined: 24 Apr 2007 09:37
Skype: Discord: Emperor Jake #4106
Location: Not Actually Japan
Contact:

Re: NML - a Newgrf Meta Language

Post by Emperor Jake »

I tried upgrading my nml to the latest version (0.4.4) but I'm getting these errors. I've updated everything so Python and stuff should be up to date, however the version of nmlc in the repositories is 0.2.4, which is ancient and unable to compile some modern NewGRFs. I'm running Linux Mint 17.2. Any ideas as to what I'm doing wrong?

Code: Select all

jake@JakeMac / $ nmlc --help
Traceback (most recent call last):
  File "/usr/local/bin/nmlc", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2749, in <module>
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 444, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 725, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 628, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: nml==0.4.4
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post by Wahazar »

How exactly define custom sounds for road vehicles?
I added following property:

Code: Select all

sound_effect: sound("path/to.wav"); 
and it works fine, playing it on vehicle start, unless only one grf with custom sounds is loaded.
If two or more grfs are loaded, sounds are randomly 'mixed', trams are honking, cars ringing etc.
Is it my fault, or just a bug?

Ps. wav have correct format.
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Supercheese
Tycoon
Tycoon
Posts: 1660
Joined: 16 Dec 2007 22:24
Location: Idaho, USA

Re: NML - a Newgrf Meta Language

Post by Supercheese »

Maybe try putting a "return" in front of your sound() call? Like:

Code: Select all

sound_effect: return sound("path/to.wav"); 
I'm not entirely certain it will help, but it seems at some point in the past I decided it was a good idea to do in my newgrfs... but I honestly don't remember why!
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: NML - a Newgrf Meta Language

Post by Wahazar »

Supercheese wrote:Maybe try putting a "return" in front of your sound() call? Like:

Code: Select all

sound_effect: return sound("path/to.wav"); 
But I'm not defining callback, just property (return is not allowed here).
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: NML - a Newgrf Meta Language

Post by Transportman »

The specs are a bit unclear about the sound effects, for trains it is not defined as a property (according to the specs), and for the other vehicle types I get the idea that the sound effect should be a default defined sound effect, and that custom sound effects can only be implemented through a callback (and there it is being listed as a callback without an equivalent property)...
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
Supercheese
Tycoon
Tycoon
Posts: 1660
Joined: 16 Dec 2007 22:24
Location: Idaho, USA

Re: NML - a Newgrf Meta Language

Post by Supercheese »

McZapkie wrote:
Supercheese wrote:Maybe try putting a "return" in front of your sound() call? Like:

Code: Select all

sound_effect: return sound("path/to.wav"); 
But I'm not defining callback, just property (return is not allowed here).
Then perhaps you should use the callback.
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: NML - a Newgrf Meta Language

Post by frosch »

That is correct. Custom sound effect are only allowed in the callback.
The property can only be one of the constants listed on https://newgrf-specs.tt-wiki.net/wiki/N ... nd_effects
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: NML - a Newgrf Meta Language

Post by frosch »

Since there was no good reason for that limitation, I removed it.
With OpenTTD r27507 the custom sound effect should also work for properties.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
GarryG
Tycoon
Tycoon
Posts: 5893
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Hi fellas,

Wonder if someone can come to my rescue. I been trying for some time to figure out how to make the creeks in my Auz_Lineside_Objects build on slopes properly. I can get the image to look like it on a slope but the base still flat.

I been practicing with some images from Useless Tracks. Once I get it right .. hope with your help .. I will redraw them as creeks.
These the images I practicing with
These the images I practicing with
Creek Slopes.PNG (2.75 KiB) Viewed 3805 times
These the codes I be trying .. but apparently I wrong somewhere.

File name: Auz_Lineside_Objects.nml

Code: Select all

template template_building_slope(x,y,filename) {
    [x, y, 64, 44, -31, -8, filename]
}

Code: Select all

/* CREEK SLOPES */

# 190 "Auz_Lineside_Objects.pnml" 2
# 1 "src/objects/Creekslope1.pnml" 1

spriteset (spriteset_Creekslope1) {
    template_building_slope(14,2,"gfx/objects/Creekslope1.png")
    template_building_slope(89,2,"gfx/objects/Creekslope1.png")
    template_building_slope(164,2,"gfx/objects/Creekslope1.png")
    template_building_slope(239,2,"gfx/objects/Creekslope1.png")
}

spritelayout spritelayout_Creekslope1 {
    ground {
        sprite: GROUNDSPRITE_NORMAL;
	recolour_mode: RECOLOUR_TRANSPARENT;
      	palette: PALETTE_DEFAULT;
    }
    building {
        sprite: spriteset_Creekslope1(LOAD_TEMP(1));
        xoffset: 0; //from NE edge
        yoffset: 0; //from NW edge
        zoffset: 0;
        xextent: 16;
        yextent: 16;
        zextent: 16;
    }
}

//set building sprite
switch (FEAT_OBJECTS, SELF, switch_Creekslope1_building, [
        //store building sprite
        STORE_TEMP(view == 1 ? 1 : (view == 2 ? 2 : (view == 3 ? 3 : 0)), 1)
        ]) {
 spritelayout_Creekslope1;
}

item (FEAT_OBJECTS, Creekslope1, 167) {
    property {
        class: "CREK";
        classname: string(STR_CREK);
        name: string(STR_Creekslope1);
        climates_available: ALL_CLIMATES;
        size: [1,1];
        build_cost_multiplier: 1;
        remove_cost_multiplier: 10;
        introduction_date: date(1800,1,1);
        end_of_life_date: 0xFFFFFFFF;
        object_flags: bitmask(OBJ_FLAG_NO_FOUNDATIONS, OBJ_FLAG_ALLOW_BRIDGE, OBJ_FLAG_ANIMATED, OBJ_FLAG_RANDOM_ANIMATION, OBJ_FLAG_ANYTHING_REMOVE, OBJ_FLAG_REMOVE_IS_INCOME);
        height: 0;
        num_views: 4;
     }
    graphics {
        default: switch_Creekslope1_building;
        autoslope: return CB_RESULT_AUTOSLOPE;
      }
}

/* END CREEK SLOPES */
Very much appreciated if someone can help.

Regards Garry
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
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 »

you choose GROUNDSPRITE_NORMAL as ground sprite. That is a flat ground sprite. You need to choose the appropriately-sloped ground sprite as well. Have a look at OpenGFX+Landscape's objects - they deal with the ground slope sprite depending on the actual tile slope.
User avatar
GarryG
Tycoon
Tycoon
Posts: 5893
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Thanks for the info planetmaker. I downloaded source for the OpenGFX+Landscape .. but it goes over my head.

I'll keep looking at it and some others .. just maybe something will click eventually.
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
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 »

It probably suffices already if you add to the flat groundsprite slope_to_sprite_offset(nearby_tile_slope(0, 0));:

Code: Select all

    ground {
		// normal ground sprite - always draw
		sprite: GROUNDSPRITE_NORMAL + slope_to_sprite_offset(nearby_tile_slope(0, 0));
	}
This should work for those ground sprites where all slopes are usually present, thus the normal grass, the desert, snow, the rocky and the bare tiles but not for others, like special flat industry or house tiles.
User avatar
GarryG
Tycoon
Tycoon
Posts: 5893
Joined: 14 Feb 2015 00:44
Location: Newcastle, Australia

Re: NML - a Newgrf Meta Language

Post by GarryG »

Thank kindly planetmaker ... that had worked.

Now I can start making some creeks for the Auz_Lineside_Objects that flow up hill. :)

Thinking also to make some dirt roads as objects too that can be used as access roads to railway lines for Per-Way (Fettlers) .. but I get these creeks flowing first.

Thanks you again.
Soot Happens
Screenshot Of The Month Winner March 2020
All my projects are GPLv2 License unless stated.
Auz Road Sets: viewtopic.php?f=29&t=87335
Auz Project Releases: viewtopic.php?f=67&t=84725
Auz Trains: http://www.tt-forums.net/viewtopic.php?f=26&t=74193
Auz Industry Sets: http://www.tt-forums.net/viewtopic.php?f=26&t=74471
Auz Objects: viewtopic.php?f=26&t=75657
Auz Bridges: viewtopic.php?f=26&t=75248
Auz Stations: viewtopic.php?f=26&t=76390
Auz Tracks: viewtopic.php?f=26&t=82691
Auz Subway Stations: viewtopic.php?f=26&t=85335
Auz Eyecandy TramTracks: viewtopic.php?t=89908
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 17 guests