Page 1 of 1

Query - Action 4 (cargoes)

Posted: 03 Dec 2008 08:20
by andythenorth
I am attempting to learn how to correctly use action 4 and text strings.

For my own learning purposes, I am attempting to change the text string for 'Coal' to 'Catfood'. I can accomplish this in part, but industries are not concatenating 'n tonnes of' to the production information.

I have included '\7C' in my string, as per the documentation. This is simply rendered as text (see screenshot). Please ignore that the mine is also producing steel - I am also learning industry coding: this element works and is not connected to the action 4 issue.
catfood_problem.png
catfood_problem.png (22.2 KiB) Viewed 1181 times
Have I missed something obvious?

Code: Select all

    4 * 18	 04 0B FF 01 1E DC "\7C Catfood" 00
    5 * 25	 00 0B 07 01 01
      08 18
      09 1E DC 
      0A 1E DC
      0B 1E DC 
      0C 1E DC // TextID for multiple units of cargo
      0D 1E DC 
      0E D1 10
- language-id FF seemed most appropriate. I have also tried 7F and 9F.
- I am aware that I need different strings for properties 09, 0A, 0B and 0E. One step at a time...

cheers,

Andy

Re: Query - Action 4 (cargoes)

Posted: 03 Dec 2008 08:32
by PikkaBird
It's not recognising the escape, for whatever reason. Just put the 7C outside the quotes.

Re: Query - Action 4 (cargoes)

Posted: 03 Dec 2008 08:44
by andythenorth
PikkaBird wrote:It's not recognising the escape, for whatever reason. Just put the 7C outside the quotes.
That works - thanks Pikka.

Out of interest, what do the first characters in the string do in this code from PBI? (This is output from grfcodec).

Code: Select all

   46 * 25	 04 0B 9F 01 "$‹| tonnes of gravel" 00

Re: Query - Action 4 (cargoes)

Posted: 03 Dec 2008 08:54
by michael blunck
andythenorth wrote: [...]
Out of interest, what do the first characters in the string do in this code from PBI? (This is output from grfcodec).

Code: Select all

   46 * 25	 04 0B 9F 01 "$‹| tonnes of gravel" 00
Should be the text-ID, erroneously added to the text string. Try grfcodec -d -t ...

regards
Michael

Re: Query - Action 4 (cargoes)

Posted: 03 Dec 2008 09:25
by andythenorth
michael blunck wrote:
andythenorth wrote: Out of interest, what do the first characters in the string do in this code from PBI? (This is output from grfcodec).

Code: Select all

   46 * 25	 04 0B 9F 01 "$‹| tonnes of gravel" 00
Should be the text-ID, erroneously added to the text string. Try grfcodec -d -t ...
Thanks Michael - that works, but converts the whole string to hex (which has some readability disadvantages!). I can of course work around that using str2hex or grf2html.

Out of interest, are there any additional options that would preserve the text string, whilst rendering the text-ID correctly? Or is that asking for a moon on a stick?

Incidentally, I should provide some context - I am finding that the best way to learn nfo is from documentation plus reading other people's source (as decompiled by grfcodec / grf2html). However I certainly won't be doing a copy-and-paste on anybody else's code without permission.

cheers,

Andy

Re: Query - Action 4 (cargoes)

Posted: 04 Dec 2008 07:01
by DaleStan
PikkaBird wrote:It's not recognising the escape, for whatever reason.
This is most likely because the NFO header reports "Info version 6" instead of "Info version 7". "\7C" is three bytes (5C 37 43) in the former and one byte (7C) in the latter.
andythenorth wrote:Are there any additional options that would preserve the text string, whilst rendering the text-ID correctly?
Judicious use of NFORenum's -b command-line option and/or @@BEAUTIFY directive (read the --help output and the readme) will solve this problem.