Page 1 of 2

Changing texts using .GRF

Posted: 19 Jun 2007 12:36
by MarkyParky
Hello,

Before the newindustries come, I would like to change some basic texts in OpenTTD using GRF - for example I want to alter sprites of Oilwells and Rafinery into Limekiln and Cementworks to fit more into my scenario.

There is no proble with the graphics, that is working great so far (including screenshot) but I tried to change generic strings for comodity, industry etc, but my testing grf doesnt work.

So I am asking whenever it is some feature, that is not supported by OpenTTD or if I do have some errors in the GRF.

My code follows:

Code: Select all

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
    0 * 4    06 00 00 00
    1 * 12    08 07 "DF" 02 01 "Test" 00 00
    2 * 11       04 48 FF 01 12 00 "Lime" 00
    3 * 11       04 48 FF 01 32 00 "Lime" 00
    4 * 18       04 48 FF 01 52 00 "ton of lime" 00
    5 * 19       04 48 FF 01 72 00 "tons of lime" 00
    6 * 10       04 48 FF 01 92 00 "\0eLM" 00    
Thank you very much for help.

Posted: 19 Jun 2007 12:53
by PikkaBird
It doesn't appear to work in OTTD, no.

You may be better off waiting for proper newindustry support?

Posted: 19 Jun 2007 13:17
by peter1138
You ought to use the newcargo feature to change cargo strings.

Posted: 19 Jun 2007 15:00
by MarkyParky
Thanks for suggestions, newcargo is worth a look.

Posted: 19 Jun 2007 18:56
by MarkyParky
I checked newcargo (Action 0, feature 0B), but it allows me only to change string pointer to another string. That is working fine, but I dont need to replace Oil by Coal ;) but to create new string. And that leads back to action 4. Any suggestion?

Posted: 19 Jun 2007 18:57
by Leviath.NL
I remember a grf that changed goods to stuff, maybe that will help?

Posted: 19 Jun 2007 19:08
by PikkaBird
MarkyParky wrote:Any suggestion?
Create a DCxx string with action 4, and point property 0B of the cargo to that.

Posted: 19 Jun 2007 20:43
by Dave
Leviath.NL wrote:I remember a grf that changed goods to stuff, maybe that will help?
I do believe its called worley.grf ;)

Posted: 19 Jun 2007 22:42
by MarkyParky
worley.grf is not working in OTTD (or at least at latest nightly). And it uses exactly the same approach as I used in my first attempt.
Create a DCxx string with action 4, and point property 0B of the cargo to that.
I tried to do such a think, but finished up with error that string DC01 is invalid. (I used following code:)

Code: Select all

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
    0 * 4	 03 00 00 00
    1 * 12	 08 07 "DF" 02 01 "Test" 00 00
    2 * 13       04 48 FF 01 01 DC "BLABLA" 00    
    3 * 8        00 0B 01 01 03 0C 01 DC
I have been doing some research and almost all gfrs that uses NewCargos first declare new strings using (undocumented) Action 04 Feature 0B and later on assigns this text to cargo using Action 00 Feature 0B, adressing DCxx string. But it doesnt seem to work in OpenTTD and also the logic of this approach is (due lack of documentation Action 04 Feature 0B ) kind of blackbox to me ;)

Posted: 19 Jun 2007 22:58
by Dave
Heh. FAME! :D

Posted: 20 Jun 2007 06:23
by PikkaBird
MarkyParky wrote:(undocumented) Action 04 Feature 0B
The feature list on the Action 4 page is incomplete, but basically you use the same feature for the action 4 as you will for the action 0 or callback that refers to it. Hence 0B.
But it doesnt seem to work in OpenTTD
It does, I assure you. :) Note that for texts which use special characters (which the prop 0C text does, either \7C or \87) it may throw a wobbler if that special character is not found...

Posted: 20 Jun 2007 09:56
by MarkyParky
Okay,

lets say it is working in OpenTTD. In this case, I do not understand one think.

I use Action 4, feature 0B to create new string. According to documentation, and also accordin to GRF files I have studied so far, it should be byte value, so I use for example 01.

Code: Select all

2 * 12   04 0B 7F 01 01 "BLABLA" 00
Now I want to use Action 0, feature 0B to replace this new string at some existing cargo.

Lets say I want string "... litres of oil" to replace with my newly created BLABLA string.

Code: Select all

3 * 8    00 0B 01 01 03 0C ?? ??
In a place where I placed questionmark, there should be a word value of new textid. As long, as I use any existing TextID already in the game, everything is fine. But I do not know what value to place here to see my newly created string from Action4. So my question is, what adress belongs here? Thank you...

Posted: 20 Jun 2007 10:25
by michael blunck
MarkyParky wrote:2 * 12 04 0B 7F 01 01 "BLABLA" 00
Your sprite is faulty. According to http://wiki.ttdpatch.net/tiki-index.php?page=Action4 the format is as follows:

Code: Select all

<Sprite-number> * <Length> 04 <feature> <language-id> <num-ent> <offset> <text>
i.e.:

Code: Select all

 2 * 13   04 0B 7F 01 00 DC "BLABLA" 00
 2 * 13   04 0B 7F 01 01 DC "BLUBLU" 00
Hence

Code: Select all

 3 * 8    00 0B 01 01 03 0C 01 DC
HTH
Michael

Posted: 20 Jun 2007 11:01
by PikkaBird
MarkyParky wrote:According to documentation, and also accordin to GRF files I have studied so far, it should be byte value, so I use for example 01.
It's a generic text string (regardless of the feature byte), so it's a word (and because it's being used in a property, it needs to be a DCxx word, as michael posted).

Like I said before, you may also be getting problems because your string does not include the special character that OTTD is looking for in the prop 0C string of a cargo.

Posted: 20 Jun 2007 12:44
by MarkyParky
To avoid sideproblems, I tried to test 09 property (name of cargo) that does not include any special characters. Then I created very simple .grf file just using examples Michael gave me here (code follows):

Code: Select all

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 7)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
    0 * 4     03 00 00 00
    1 * 12    08 07 "DF" 02 01 "Test" 00 00
    2 * 13    04 0B 7F 01 01 DC "BLABLA" 00   
    3 * 8     00 0B 01 01 03 09 01 DC 
This code should change Oil to BLABLA. When I put it into OpenTTD and click on the rafinery , I get following error:
"!String 0xDC01 is invalid. Probably because an old version of the .lng file."

If I make the Action0 point to some already existing string, everything is working fine. So problem is probably still with Action4.

Posted: 20 Jun 2007 12:48
by PikkaBird
Okay, silly question time.. what version of OTTD are you using?

Posted: 20 Jun 2007 15:02
by MarkyParky
Yestherdays nightly ;). But I tried older as well. Also latest GRFCodec.

Posted: 20 Jun 2007 15:19
by glx
Set bit 7 of lang-id (DCXX are "generic" strings).

Posted: 20 Jun 2007 15:30
by MarkyParky
I have tried also. Same error. It starts to sound like pretty mystery ;). Can anyone try to make himself simmilar simple file, compile it and try it out?

Posted: 20 Jun 2007 15:38
by PikkaBird
MarkyParky wrote:Can anyone try to make himself simmilar simple file, compile it and try it out?
Okay. Set property 08 before you try to set any other properties.