NML - a Newgrf Meta Language

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

Moderator: Graphics Moderators

Post Reply
BarthVader
Engineer
Engineer
Posts: 10
Joined: 02 Oct 2010 18:47

Re: NML - a Newgrf Meta Language

Post by BarthVader »

Hello yet again.

I managed to write some bigger GRF using NML, but yesterday something had gone wrong:

Image

What's wrong?
Last edited by BarthVader on 26 Jan 2011 22:07, 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 »

My guess is that you try to use a too large value in some place, but it's hard to tell without the input. Could you upload the nml file you use? Or in case you don't want to make it public, could you send it to me via pm/email?

To be clear: I think it's an error in your nml file, but you shouldn't get this AssertionError. As such it's also probably also a bug in nml.
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 »

See http://dev.openttdcoop.org/issues/2181 on how to reproduce it. It's at least not as obvious that I see it while having the first coffee of the day.

@BarthVader: the patch file attached there takes only care of the case of the file names. Your grf currently may compile on windows which doesn't care about case, but it does not on linux and some macos which care about the case of filenames. You might want to just apply that patch file :-) Besides: why don't you use png file format? It's much easier viewed. And you might want to replace all pixels with colour 0xFFFFFF by 0xFCFCFC in order to get rid of the white pixel warnings - visually it's no difference except in a few situations where 0xFCFCFC is desirable as it is subject to certain colour translations which pure white is not (newspaper, crash - IIRC).

EDIT: another issue which triggers this error: the use of the cargo translation table. You can only use the first 32 entries of the CTT in the refit mask, (you can use all when it comes to deciding graphics though). Line 1399 defines "SAND" in the refit mask. It seems to me to be the 32nd entry, so it *should* work... but commenting it out solves the issue.

Generally concerning the CTT: I organized it in OpenGFX+ such that the first chunk are those cargos which I reference explicitly and after the gap all others. It might be a good idea to handle it the same way here - or to find some other means so that you make sure that the refit cargos are one of the first 32 CTT entries.
Last edited by planetmaker on 18 Jan 2011 08:24, 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 »

The issue was an off-by-one error that triggered exactly on the case planetmaker found: a numerical value of -0x80000000 (= bitmask with only bit 31 set). It's fixed in nml r1136.
BarthVader
Engineer
Engineer
Posts: 10
Joined: 02 Oct 2010 18:47

Re: NML - a Newgrf Meta Language

Post by BarthVader »

Thanks a lot.
User avatar
YukonRob
Transport Coordinator
Transport Coordinator
Posts: 290
Joined: 31 Jul 2007 00:58
Location: North of 63

Re: NML - a Newgrf Meta Language

Post by YukonRob »

I am making a train engine grf and have a few questions:

How do we set base costs? They don't seem to match the ones on the wiki (http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts)
Also is there any way to set max reliability?

Cheers,
Rob
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 »

YukonRob wrote:I am making a train engine grf and have a few questions:

How do we set base costs? They don't seem to match the ones on the wiki (http://wiki.ttdpatch.net/tiki-index.php?page=BaseCosts)
They're set this way:

Code: Select all

basecost { 
	PR_RUNNING_TRAIN_STEAM:     43;
	PR_RUNNING_TRAIN_DIESEL:    param[3];
	PR_RUNNING_TRAIN_ELECTRIC:  electric_run_cost_param;
	PR_BUILD_VEHICLE_TRAIN:     200;
	PR_BUILD_VEHICLE_WAGON:     200;
}
See http://hg.openttdcoop.org/nml/raw-file/ ... cost-table for allowed entries.
Also is there any way to set max reliability?
There is generally not for newgrfs. Only the speed with which the reliability (randomly chosen upon map creation) decays. See http://wiki.ttdpatch.net/tiki-index.php ... Model_life for an explanation.

Have a look at http://hg.openttdcoop.org/nml/raw-file/ ... index.html
User avatar
YukonRob
Transport Coordinator
Transport Coordinator
Posts: 290
Joined: 31 Jul 2007 00:58
Location: North of 63

Re: NML - a Newgrf Meta Language

Post by YukonRob »

Thanks for the links - I hadn't found the base cost section (also what units are those in?).

But if I use the following I get different results (OTTD R21811):

cost_factor: 1;
running_cost_base: RUNNING_COST_DIESEL;
running_cost_factor: 1;

Results:
Cost - $2342
Running Cost - $30/yr

I must be missing something.
User avatar
YukonRob
Transport Coordinator
Transport Coordinator
Posts: 290
Joined: 31 Jul 2007 00:58
Location: North of 63

Re: NML - a Newgrf Meta Language

Post by YukonRob »

In NML if I don't define an engine ID, what does it default to? (ie. I assume that default values for hp etc. would usually be predefined by the vehicle you are replacing unless you explicitly change them).
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 »

YukonRob wrote:Thanks for the links - I hadn't found the base cost section (also what units are those in?).

But if I use the following I get different results (OTTD R21811):

cost_factor: 1;
running_cost_base: RUNNING_COST_DIESEL;
running_cost_factor: 1;

Results:
Cost - $2342
Running Cost - $30/yr
Mind you didn't set a cost base in your example. And what's wrong with your results? The units are... somewhat arbitrary units. One step up doubles the base cost, One step down halfs them.
YukonRob wrote:In NML if I don't define an engine ID, what does it default to? (ie. I assume that default values for hp etc. would usually be predefined by the vehicle you are replacing unless you explicitly change them).
If you don't define an engine ID explicitly, you're NOT replacing a vehicle. You CAN define an engineID and thus you can also replace a vehicle. By default, that is without engineID or an engineID where no default vehicle exists, all vehicle properties and graphics are undefined and need to be defined in order to make the vehicle valid. E.g. in the following example the 20 is the engineID of the default turbotrain and you could just change what you need to change:

Code: Select all

item(FEAT_TRAINS, turbotrain, 20) {
...
}
Please also make use of the examples in NML's regression folder or existing NML projects as examples, there are a number on the DevZone, like SwedishRails, OpenGFX+ [Trains | Vehicles | Industries | Airports | Landscape], Townnames, NARVS...
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: NML - a Newgrf Meta Language

Post by Hirundo »

YukonRob wrote:Thanks for the links - I hadn't found the base cost section (also what units are those in?).
This section of the docs contains some information about the units and general use:
http://hg.openttdcoop.org/nml/raw-file/ ... k-basecost

Mind the difference between base costs and actual costs. There are a number of base costs that can be adjusted with a 'basecost' block. The numbers you set there serve as base for all prices. To determine the actual (running) cost of your engine, the base cost is multiplied by a certain factor that can be set for each vehicle (cost_factor / running_cost_factor). In the game code, there may be other arbitrary multipliers.

To cut a long story short, increase the base cost to increase the cost of all vehicles in your grf (vehicle costs are per-grf), increase the vehicle's cost_factor to increase the price of an individual vehicle. The same applies to running costs, with the added caveat that you can decide yourself which base cost to use, providing some additional freedom.
Create your own NewGRF? Check out this tutorial!
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML - a Newgrf Meta Language

Post by Yexo »

For everyone who has trouble installing nml/python/python-imaging under windows: a windows binary. It's only minimally tested. As long as we don't find an automated way to build those windows binaries I'll upload a new version once in a while or upon special request. Please report any problems you have with this binary.

Download here: http://dev.openttdcoop.org/attachments/ ... -r1243.zip
BillSargent
Engineer
Engineer
Posts: 49
Joined: 09 Oct 2010 13:45
Location: Göteborg, Sweden

Re: NML - a Newgrf Meta Language

Post by BillSargent »

Hi there,

Is there any way to modify the properties of cargo such as the weight of coal or passengers? That cargoes section of the documentation seems to be missing some stuff. It talks about a number for the bitmask 0 to 31.... Is that where I tell this blockof code that I'm modifying the properties of COAL?

I'm building larger capacity coal cars so that I can build shorter trains and keep the game speed high, but adding 255t of coal to a car makes it weigh a lot. I have 2 64,545 HP engines that go up to 3000km/h but they have A LOT of trouble getting up to that speed with so much weight.

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

Re: NML - a Newgrf Meta Language

Post by Yexo »

The documentation about cargoes is indeed not yet complete. You could try the following code, I haven't tested this, but it should work.

Code: Select all

if (climate == CLIMATE_TEMPERATE) {
	// The 0x01 comes from http://wiki.ttdpatch.net/tiki-index.php?page=CargoTypes column "Type B"
	item(FEAT_CARGOS, cargo_coal, 0x01) {
		property {
			weight: 1.0 / 16; // Set weight of coal to 1/16 ton, the smallest amount possible.
		}
	}
}
You could even try setting the weight to 0, but that might give other problems.
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 »

What is unclear about the property "weight"? The only info missing is that the actual quantization is in 1/16 of a ton.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML - a Newgrf Meta Language

Post by Yexo »

planetmaker wrote:What is unclear about the property "weight"? The only info missing is that the actual quantization is in 1/16 of a ton.
Actually in nml the quantization is in ton. Writing "weight: 2;" will result in a weight of 2 ton.
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 »

Yexo wrote:
planetmaker wrote:What is unclear about the property "weight"? The only info missing is that the actual quantization is in 1/16 of a ton.
Actually in nml the quantization is in ton. Writing "weight: 2;" will result in a weight of 2 ton.
Yes, it's a float value in NML. I meant to stress that a value of 0.1 would get rounded, I guess to 1/8 (nearest multiple of 1/16)
BillSargent
Engineer
Engineer
Posts: 49
Joined: 09 Oct 2010 13:45
Location: Göteborg, Sweden

Re: NML - a Newgrf Meta Language

Post by BillSargent »

planetmaker wrote:What is unclear about the property "weight"? The only info missing is that the actual quantization is in 1/16 of a ton.

I was confused about the 0x01 part. I didn't see in the documentation, a list of cargoes. As was mentioned, that part of the documentation wasn't as clear as say, the modification of a wagon.

I must add too, I'm quite impressed with NML so far.

Bill
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 »

BillSargent wrote:I was confused about the 0x01 part.
I'm interested in improving the documentation, but I'm not sure which part thereof you refer to. Could you possibly be more precise or provide a link to what part you looked at?

A list of available cargoes depends on the used newgrfs. The ones used in commonly by default or by NewGRFs are not yet listed in the NML documentation but found on http://wiki.ttdpatch.net/tiki-index.php ... rgo_Labels
BillSargent
Engineer
Engineer
Posts: 49
Joined: 09 Oct 2010 13:45
Location: Göteborg, Sweden

Re: NML - a Newgrf Meta Language

Post by BillSargent »

planetmaker wrote:
BillSargent wrote:I was confused about the 0x01 part.
I'm interested in improving the documentation, but I'm not sure which part thereof you refer to. Could you possibly be more precise or provide a link to what part you looked at?

A list of available cargoes depends on the used newgrfs. The ones used in commonly by default or by NewGRFs are not yet listed in the NML documentation but found on http://wiki.ttdpatch.net/tiki-index.php ... rgo_Labels

What I meant was that here http://hg.openttdcoop.org/nml/raw-file/ ... vehicleIDs you have the list of VehicleIDs.... I was expecting a list of cargo IDs as well I didn't know that they were in the ttdpatch wiki...

Instead of 0x01 can we instead put COAL there?
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 2 guests