Page 2 of 2

Re: M4nfo installation problem.

Posted: 11 Jan 2018 13:09
by michael blunck
Tony Pixel wrote: I didn't think what m4 is bad, I have so many problems with it.
What exactly are your problems with M4?

1) Did you download it? Here´s a pre-compiled version -> http://gnuwin32.sourceforge.net/packages/m4.htm

Make sure that the location where you put it is included in your $PATH var.

Does it work for you? -> run "m4 --version" in a command window. What does it tell?

2) Did you download grfcodec? Here it is -> http://www.openttd.org/en/download-grfcodec

Again, make sure that the location where you put it is included in your $PATH var.

Does it work? run "grfcodec -?" in a command window. What does it tell?

3) Now, download the m4nfo module for "trains" -> http://www.ttdpatch.de/grfspecs/m4nfoMa ... trains.zip

Unzip it, it includes two .m4 files:

- "m4nfo_trains.m4"
This is the "trains module", you have to include it in the command which starts M4:

Code: Select all

M4 -R m4nfo_trains.m4 < test.nfx > test.nfo 
where "test.nfx" is your m4nfo source file and "test.nfo" is the resulting NFO output file for grfcodec (instead of "test", you should use your own file names here!)

- "count.m4"
This is a special m4nfo file which adds real sprite numbers to the resulting nfo code, for trouble shooting:

Code: Select all

copy count.m4 + test.nfo test.tt
This (windows!) command writes "count.m4" and "test.nfo" into a new file "test.tt". And in a second step, is handed over to M4 (again!):

Code: Select all

M4 < test.tt > test.nfo
Now, "test.nfo" contains proper sprite numbers which might be used e.g. by the linter program "nforenum".

The resulting file "test.nfo" can now be fed to grfcodec, together with any graphics, included in file "test.png":

Code: Select all

grfcodec -e test.grf
That´s all.


Eventually, all of the previous commands can be easily put into a batch file, e.g. "train.bat":

Code: Select all

M4 -R m4nfo_trains.m4 < $1.nfx > $1.nfo
copy count.m4 + $1.nfo $1.tt
M4 < $1.tt > $1.nfo
grfcodec -e $1.grf
so the command "train mytest" would produce "mytest.grf" from files "mytest.nfx" and "mytest.png".

The only problem is to set up your directory structure and your PATH var in a proper way so that every file can be found.

HTH
Michael

Re: M4nfo installation problem.

Posted: 11 Jan 2018 15:01
by Tony Pixel
How to set PATH variable?

Re: M4nfo installation problem.

Posted: 12 Jan 2018 11:38
by Alberth
Tony Pixel wrote:How to set PATH variable?
Search for "windows set PATH", really the Internet knows the answer to most questions.

Random URL from the collection: https://stackoverflow.com/questions/954 ... in-windows

Re: M4nfo installation problem.

Posted: 14 Aug 2018 08:11
by Tony Pixel
After many time, I return to this thread, and have an old questions. As You said, I downloaded the grfcodec and set up the PATH variable - added to the end:

Code: Select all

;D:\Anton\grfcodec\
Next, I went to the this page, downloaded and unpacked "m4-1.4.18.tar.gz" archive. Then also added to the PATH variable:

Code: Select all

;D:\Anton\m4nfo\
What to do next? I tried "M4 -R m4nfo_trains.m4 < test.nfx > test.nfo" in cmd, but nothing happened.

Re: M4nfo installation problem.

Posted: 14 Aug 2018 10:53
by acs121
Did it send an error or something ?

Re: M4nfo installation problem.

Posted: 14 Aug 2018 10:53
by Tony Pixel
File not found

Re: M4nfo installation problem.

Posted: 14 Aug 2018 10:55
by acs121
What file is it talking about ?

Re: M4nfo installation problem.

Posted: 14 Aug 2018 11:49
by Tony Pixel
It simply says "File not found"

Re: M4nfo installation problem.

Posted: 14 Aug 2018 12:46
by acs121
Did you open m4nfo correctly by a command file ? You have to right-click on the directory, click on modify the adress and type "cmd" instead of the adress.

Re: M4nfo installation problem.

Posted: 15 Aug 2018 06:38
by Alberth
Tony Pixel wrote:After many time, I return to this thread, and have an old questions. As You said, I downloaded the grfcodec and set up the PATH variable - added to the end:

Code: Select all

;D:\Anton\grfcodec\
Next, I went to the this page, downloaded and unpacked "m4-1.4.18.tar.gz" archive. Then also added to the PATH variable:

Code: Select all

;D:\Anton\m4nfo\
What to do next? I tried "M4 -R m4nfo_trains.m4 < test.nfx > test.nfo" in cmd, but nothing happened.
Since you start with "m4", you're trying to run the 'm4' program. Is there an m4 executable either in "D:\Anton\grfcodec\" or in "D:\Anton\m4nfo\" ? (There shouldn't be, since the command failed.)

The next question is then, where did you put the "m4" executable instead?
Given that you donwloaded a GNU package, I would gamble it is in d:\anton\m4-1.4.16\bin\m4 (if you unpacked the m4-1.4.18.tar.gz in d:\anton). If you did, you should also add "d:\anton\m4-1.4.18\bin" to the PATH. (In any case, PATH should contain the directory path of the directory that has the m4 program.)

Note that the PATH is mostly a convenience for you, so you can type "m4" and the computer looks through the directories in the PATH, until it finds an executable with the given name. If you type what to run with a \ in it, the entire PATH resolving is skipped, and it tries to run whatever you typed. ie, if you enter "d:\somewhere\sometime\somehow\bla" at the command-line, it will literally try run the "bla" program at the given path (if it exists), without using the PATH variable.
As such, you can always type the full path of a program to run it (eg "d:\anton\m4-1.4.18\bin\m4 < test.nfx > test.nfo" if d:\anton\m4-1.4.18\bin\m4 exists).