NML - a Newgrf Meta Language

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

Moderator: Graphics Moderators

Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: NML - a Newgrf Meta Language

Post by Kogut »

Lord Aro wrote: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:
Yexo wrote:python
python-imaging
ply (from http://www.dabeaz.com/ply/ )

I hope I didn't forget anything.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
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 »

xenon wrote:how to install it??? :oops: :oops:
The documentation has an as comprehensive guide as we could come up with http://hg.openttdcoop.org/nml/raw-file/ ... stallation
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 »

I didn't see that last time i looked! :lol:
When was it added? Or did i just miss it?
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
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 »

i red the docs but still don't get it. i have python,pil, but how to install ply and mnl in windows x64?? i get error messages every time i trying to run setup.py via IDLE
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 install them by fixing the errors.

My answer is as precise as your question.
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 »

ok. i should rephrase my question. where should place the files?? how to properly execute setup?? with which program?? i don't have ANY expireince with python.
iget this when trying to run the setup via python

Code: Select all

Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>> 

Traceback (most recent call last):
  File "C:\Python27\Scripts\setup.py", line 34, in <module>
    scripts=['nmlc'],
  File "C:\Python27\lib\distutils\core.py", line 140, in setup
    raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied
>>> 
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: NML - a Newgrf Meta Language

Post by Alberth »

Open a command window (start->run...-> cmd)

In the command window, go to the directory with setup, and run it with python:

Code: Select all

> cd \path\to\ply-x.y
> python setup.py install
You can do the same with nml, but it is not needed, as you need the terminal window also for running nmlc, and at that time, the directories are set up such that it also works without installing.

To run nml:

Code: Select all

> cd \path\to\nml-x.y
> python nmlc --help
Gives help, I think you need 'nmlc --grf myfile.grf myfile.nml' to convert 'myfile.nml' to .grf. You can also output .nfo files.

Edit: fixed some white spaces, and the \path\to\nml-x.y
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 »

thanks. i think i get now. i'll write if i'll have any other questions.

how to create lang file?? how to create palette to my sprite?? do i need to do this??
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: NML - a Newgrf Meta Language

Post by Kogut »

planetmaker wrote:
xenon wrote:how to install it??? :oops: :oops:
The documentation has an as comprehensive guide as we could come up with http://hg.openttdcoop.org/nml/raw-file/ ... stallation
There is Python Imaging Library 1.1.7 for Python 2.6 but not for 2.7. Is it safe to use python 2.7?

EDIT: Answer:No.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: NML - a Newgrf Meta Language

Post by Kogut »

planetmaker wrote:
xenon wrote:how to install it??? :oops: :oops:
The documentation has an as comprehensive guide as we could come up with http://hg.openttdcoop.org/nml/raw-file/ ... stallation
Binary instalator of PIL is crashing on windows 7. How can I get files installable by:

Code: Select all

python setup.py install
?
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Eddi
Tycoon
Tycoon
Posts: 8254
Joined: 17 Jan 2007 00:14

Re: NML - a Newgrf Meta Language

Post by Eddi »

Kogut wrote:
planetmaker wrote:
xenon wrote:how to install it??? :oops: :oops:
The documentation has an as comprehensive guide as we could come up with http://hg.openttdcoop.org/nml/raw-file/ ... stallation
There is Python Imaging Library 1.1.7 for Python 2.6 but not for 2.7. Is it safe to use python 2.7?

EDIT: Answer:No.
rule of thumb: if the libary interfaces to C/C++/other language code, then not, unless you compile yourself. if it only consists of python code, then it is probably fine (but in rare cases needs updating for some language features)
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: NML - a Newgrf Meta Language

Post by Alberth »

I just checked, PIL does use compiled libraries of its own at my linux system. It is probably the same at Win* systems.

If you want to use 'python setup.py install' (that is, install PIL from source code), you must at least download the PIL source code and install the same compiler as used for building the python.exe . If PIL needs other libraries to be available, you must install those first.

The distutils module (part of the python library, comes with python.exe) used by setup.py will compile the libraries, and install the PIL pytlhon code.


I would be surprised if you are the first with a crashing PIL installer, perhaps you should ask at some PIL group/channel/forum about it?
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 »

There is a binary for 2.7, this doesn't work?
http://effbot.org/downloads/#pil
oberhümer
Tycoon
Tycoon
Posts: 1283
Joined: 23 Oct 2009 19:35
Location: Here and there, sometime or another

Re: NML - a Newgrf Meta Language

Post by oberhümer »

I have two complaints (both with NML r1047):
1. This is probably more serious: a language file was not recognized. I put it in the "lang" folder, set it up according to the documentation, saved it in UTF-8 encoding, but I still got an error message about an undefined string. solved
2. Less important: NML can't handle numbers in railtype names. This makes it hard, if not impossible, to make third rail (3RDR) vehicles.
3. Another thing cropped up: I could not make a road vehicle be introduced in any climate.

Test code can be found in the attachment.

...Well, now it's decided not to work at all (in the very newest version). The error can be seen in the screenshot.
Attachments
mc8.pnml.txt
(1.38 KiB) Downloaded 144 times
screenshot.png
screenshot.png (39.56 KiB) Viewed 4625 times
--- Licenses: GNU LGPL, version 2 or newer, code and graphics. CC-By-SA, graphics, alternatively. If you're using any, I'd like to hear about it --- Call them "track types" ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---

--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
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 »

oberhümer wrote: 2. Less important: NML can't handle numbers in railtype names. This makes it hard, if not impossible, to make third rail (3RDR) vehicles.
Confirmed. That's nasty.
oberhümer wrote: 3. Another thing cropped up: I could not make a road vehicle be introduced in any climate.
Your example fails to use bitmasks in a few places:

Code: Select all

		refittable_cargo_classes: bitmask(CC_PASSENGERS);
		callback_flags: bitmask(VEH_CBF_REFITTED_CAPACITY);
The climates work for me:

Code: Select all

		climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPIC);
or alternatively

Code: Select all

		climates_available: ALL_CLIMATES // note that it's not climates_all and no bitmask there
With these changes, and changing 3RDR to something starting with a letter it compiles for r1072 (db155332df58) and I don't see anything further which is obviously wrong and climate declaration works for me in OpenGFX+Trains; the attached nml works for me. Note that I removed the sprite_id: SPRITE_ID_NEW_ROAD_VEH and re-defined an arbitrary vehicleID as I don't have any graphcis.
Attachments
test.nml
(1.4 KiB) Downloaded 161 times
test.grf
(306 Bytes) Downloaded 134 times
oberhümer
Tycoon
Tycoon
Posts: 1283
Joined: 23 Oct 2009 19:35
Location: Here and there, sometime or another

Re: NML - a Newgrf Meta Language

Post by oberhümer »

Thanks for the help. I'll see if it works now.
(It does. Seems the problem was my Python installation.)

However, I have another small problem: the way language files begin seems to have changed from "lang: XX" to "##grflangid XX", and the documentation doesn't seem to have noticed. E.g.: I have no idea which numbers to use, the IDs seem to be completely different (at least 7F or 127 does not mean "default").
--- Licenses: GNU LGPL, version 2 or newer, code and graphics. CC-By-SA, graphics, alternatively. If you're using any, I'd like to hear about it --- Call them "track types" ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---

--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
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 »

Right, documentation was not yet updated properly. nmlc now expects a file english.lng which starts with

Code: Select all

##grflangid 0x01
but allows now to make use of the full case and gender syntax in the very same way OpenTTD language files allow: http://wiki.openttd.org/FormatOfLangfiles The language codes otherwise did not change: http://hg.openttdcoop.org/nml/raw-file/ ... uage-files
The 7F (any, fallback) is now automatically created from the English language file and need (must?) not be supplied separately.

Thanks for the feedback. Much appreciated.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: NML - a Newgrf Meta Language

Post by Yexo »

Thanks for your reports oberhümer, it's really helpful. I've fixed the documentation for the language files. It's still incomplete but no longer wrong.

3RDR as a railtype label is a tricky case, we're discussing now how to fix that problem.
BarthVader
Engineer
Engineer
Posts: 10
Joined: 02 Oct 2010 18:47

Re: NML - a Newgrf Meta Language

Post by BarthVader »

Hello everybody,
I looked into the documentation but I can't find anything about how to make articulated vehicles. Is it possible?
Greetings,
BarthVader
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: NML - a Newgrf Meta Language

Post by DJ Nekkid »

callback16 :D
Last edited by DJ Nekkid on 09 Dec 2010 20:53, edited 1 time in total.
Member of the
ImageImage
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 3 guests