Query - Action 4 (cargoes)

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Query - Action 4 (cargoes)

Post 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 1173 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
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5631
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Query - Action 4 (cargoes)

Post by PikkaBird »

It's not recognising the escape, for whatever reason. Just put the 7C outside the quotes.
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Query - Action 4 (cargoes)

Post 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
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: Query - Action 4 (cargoes)

Post 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
Image
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: Query - Action 4 (cargoes)

Post 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
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Query - Action 4 (cargoes)

Post 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.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: No registered users and 4 guests