Add field on vehicle window
Moderator: OpenTTD Developers
Add field on vehicle window
I'm trying to add a filed like: "Type: Steam" inside a vehicle window(were are display Cost , weight etc).
I cannot figure out how to do it. Is it possible to add it for only one vehicle, like the name of the bus
Example: 04 01 7F 01 "NAME" 00 ?
I cannot figure out how to do it. Is it possible to add it for only one vehicle, like the name of the bus
Example: 04 01 7F 01 "NAME" 00 ?
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Add field on vehicle window
You would do this by callback 23 (additional text in menu).
regards
Michael
regards
Michael
Re: Add field on vehicle window
Do you have an example how to use callback 23, because it's difficult to understand how to do this in nfo?
Thanks
Thanks
Re: Add field on vehicle window
I saw some grf's that have set this via Action4. Like this one:
3 * 254 04 00 FF 04 00 D0 98 "Manufactuerer: " 8A "Bombardier "
"Transportation " 0D 98 "Model Name: " 8A "Type-S "
"Tram" 00 98 "Manufactuerer: " 8A "Siemens Duewag "
0D 98 "Model Name: " 8A "Type-PT Tram" 00 98 "Manufactuerer: "
8A "Siemens Duewag " 0D 98 "Model Name: " 8A "Type-O "
"Tram" 00 98 "Manufactuerer: " 8A "Siemens Duewag "
0D 98 "Model Name: " 8A "Type-K Tram" 00
But I cannot figure out why is not working in mygrf. I think there is something more that I should write somewhere but I don't know what
For each vehicle I have 3 action2 sprites and one actio3
I'm pretty sure that the last action2 refer to what I want to change
246 * 43 02 01 FB 89 10 00 FF 00 00 00 03 FF 00 09 00 00 00 09 00 00 00 FC 00 0F 00 00 00 0F 00 00 00 00
00 23 00 00 00 23 00 00 00 FE 00
247 * 33 02 01 FF 89 10 00 FF 00 00 00 02 FF 00 09 00 00 00 09 00 00 00 FA 00 0F 00 00 00 0F 00 00 00 FE
00
248 * 43 02 01 FB 89 0C 00 FF FF 00 00 03 FC 00 15 00 00 00 15 00 00 00 FD 00 16 00 00 00 16 00 00 00 FB
00 36 00 00 00 36 00 00 00 FE 00
249 * 53 02 01 FE 89 0C 00 FF FF 00 00 04 FA 00 00 00 00 00 00 00 00 00 FD 00 16 00 00 00 16 00 00 00 03
80 23 00 00 00 23 00 00 00 FF 00 36 00 00 00 36 00 00 00 FE 00
250 * 12 03 01 01 FF 5C 00 01 FF FE 00 FB 00
But when I copy sprites 249 and 250 nothing happens .
P.S. I change the ID in action3 from 5C to my vehicle ID.
I try also deleting last to bytes from Action3 (the FB 00). still nothing
3 * 254 04 00 FF 04 00 D0 98 "Manufactuerer: " 8A "Bombardier "
"Transportation " 0D 98 "Model Name: " 8A "Type-S "
"Tram" 00 98 "Manufactuerer: " 8A "Siemens Duewag "
0D 98 "Model Name: " 8A "Type-PT Tram" 00 98 "Manufactuerer: "
8A "Siemens Duewag " 0D 98 "Model Name: " 8A "Type-O "
"Tram" 00 98 "Manufactuerer: " 8A "Siemens Duewag "
0D 98 "Model Name: " 8A "Type-K Tram" 00
But I cannot figure out why is not working in mygrf. I think there is something more that I should write somewhere but I don't know what
For each vehicle I have 3 action2 sprites and one actio3
I'm pretty sure that the last action2 refer to what I want to change
246 * 43 02 01 FB 89 10 00 FF 00 00 00 03 FF 00 09 00 00 00 09 00 00 00 FC 00 0F 00 00 00 0F 00 00 00 00
00 23 00 00 00 23 00 00 00 FE 00
247 * 33 02 01 FF 89 10 00 FF 00 00 00 02 FF 00 09 00 00 00 09 00 00 00 FA 00 0F 00 00 00 0F 00 00 00 FE
00
248 * 43 02 01 FB 89 0C 00 FF FF 00 00 03 FC 00 15 00 00 00 15 00 00 00 FD 00 16 00 00 00 16 00 00 00 FB
00 36 00 00 00 36 00 00 00 FE 00
249 * 53 02 01 FE 89 0C 00 FF FF 00 00 04 FA 00 00 00 00 00 00 00 00 00 FD 00 16 00 00 00 16 00 00 00 03
80 23 00 00 00 23 00 00 00 FF 00 36 00 00 00 36 00 00 00 FE 00
250 * 12 03 01 01 FF 5C 00 01 FF FE 00 FB 00
But when I copy sprites 249 and 250 nothing happens .
P.S. I change the ID in action3 from 5C to my vehicle ID.
I try also deleting last to bytes from Action3 (the FB 00). still nothing
Last edited by sky81 on 12 Mar 2021 13:34, edited 1 time in total.
Re: Add field on vehicle window
here's an excerpt from my (NML) code, not a particularly simple example (using the "text stack"):
Code: Select all
switch(FEAT_TRAINS, SELF, text_switch_default,
[STORE_TEMP(string(STR_AUTO_10) | string(STR_USAGE_CARGO) << 16, 0x100),
STORE_TEMP(string(STR_TRACK_TYPES_DEFAULT) | string(STR_TRACK_TYPE_N) << 16, 0x101),
0])
{
return string(STR_ENG_DESCRIPTION);
}
item(FEAT_TRAINS, [...]) {
graphics {
additional_text: text_switch_default;
}
Code: Select all
STR_ENG_DESCRIPTION :{BLACK}Axle Scheme: {GOLD}{STRING}{BLACK} Use: {GOLD}{STRING}{BLACK}{}Track Class: {GOLD}{STRING}{BLACK}
STR_AUTO_10 :2'2'
STR_USAGE_CARGO :Freight
STR_TRACK_TYPES_DEFAULT :{STRING}
STR_TRACK_TYPE_N :{GREEN}unelectrified{ORANGE}
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Add field on vehicle window
The action 4 above sets the text strings for IDs following ID "D0 00". You have to simply address those IDs in your callback 23. C'est ça.sky81 wrote: ↑12 Mar 2021 12:22 I saw some grf's that have set this via Action4. Like this one:
3 * 254 04 00 FF 04 00 D0 98 "Manufactuerer: " 8A "Bombardier "
"Transportation " 0D 98 "Model Name: " 8A "Type-S "
"Tram" 00 98 "Manufactuerer: " 8A "Siemens Duewag "
0D 98 "Model Name: " 8A "Type-PT Tram" 00 98 "Manufactuerer: "
8A "Siemens Duewag " 0D 98 "Model Name: " 8A "Type-O "
"Tram" 00 98 "Manufactuerer: " 8A "Siemens Duewag "
0D 98 "Model Name: " 8A "Type-K Tram" 00
But I cannot figure out why is not working in mygrf. I think there is something more that I should write somewhere but I don't know what
regards
Michael
Re: Add field on vehicle window
the NFO code resulting from my code looks something like this:
Code: Select all
[imagine some action4 here]
// Name: text_switch_default
3144 * 109 02 00 B7 89
1A 20 \dx0000D0A2
\2<< 1A 20 \dx00000010
\2sto 1A 20 \dx00000080
\2r 1A 20 \dx0000D00A
\2| 7D 80 20 \dxFFFFFFFF
\2sto 1A 20 \dx00000100
\2r 1A 20 \dx0000D0A0
\2<< 1A 20 \dx00000010
\2sto 1A 20 \dx00000081
\2r 1A 20 \dx0000D0A1
\2| 7D 81 20 \dxFFFFFFFF
\2sto 1A 20 \dx00000101
\2r 1A 00 \dx00000000
\b1
\wx8000 \dx00000001 \dx00000000 // Bogus range to avoid nvar == 0
\wx809E // default: return string(STR_ENG_DESCRIPTION);
// Name: @action3_11
3153 * 43 02 00 B9 89
0C 00 \dx0000FFFF
\b3
\wx00BA \dx00000000 \dx00000000 // gfx_switch_purchase;
\wx00B7 \dx00000023 \dx00000023 // text_switch_default;
\wx00BB \dx00000036 \dx00000036 // @action3_9;
\wx00B9 // gfx_switch;
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Add field on vehicle window
Wow!Eddi wrote: ↑12 Mar 2021 12:52 the NFO code resulting from my code looks something like this:
Code: Select all
[imagine some action4 here] // Name: text_switch_default 3144 * 109 02 00 B7 89 1A 20 \dx0000D0A2 \2<< 1A 20 \dx00000010 \2sto 1A 20 \dx00000080 \2r 1A 20 \dx0000D00A \2| 7D 80 20 \dxFFFFFFFF \2sto 1A 20 \dx00000100 \2r 1A 20 \dx0000D0A0 \2<< 1A 20 \dx00000010 \2sto 1A 20 \dx00000081 \2r 1A 20 \dx0000D0A1 \2| 7D 81 20 \dxFFFFFFFF \2sto 1A 20 \dx00000101 \2r 1A 00 \dx00000000 \b1 \wx8000 \dx00000001 \dx00000000 // Bogus range to avoid nvar == 0 \wx809E // default: return string(STR_ENG_DESCRIPTION); // Name: @action3_11 3153 * 43 02 00 B9 89 0C 00 \dx0000FFFF \b3 \wx00BA \dx00000000 \dx00000000 // gfx_switch_purchase; \wx00B7 \dx00000023 \dx00000023 // text_switch_default; \wx00BB \dx00000036 \dx00000036 // @action3_9; \wx00B9 // gfx_switch;
Re: Add field on vehicle window
well, it's not like i did anything there. that's just the output of NMLC...
the "text stack" is awkward anyway, because it's not actually a "stack" (it has no "push" operation. you have to manually store values at the correct locations)
Re: Add field on vehicle window
Yes. This is what I have to do. The problem is I don't know howmichael blunck wrote: ↑12 Mar 2021 12:51The action 4 above sets the text strings for IDs following ID "D0 00". You have to simply address those IDs in your callback 23. C'est ça.sky81 wrote: ↑12 Mar 2021 12:22 I saw some grf's that have set this via Action4. Like this one:
3 * 254 04 00 FF 04 00 D0 98 "Manufactuerer: " 8A "Bombardier "
"Transportation " 0D 98 "Model Name: " 8A "Type-S "
"Tram" 00 98 "Manufactuerer: " 8A "Siemens Duewag "
0D 98 "Model Name: " 8A "Type-PT Tram" 00 98 "Manufactuerer: "
8A "Siemens Duewag " 0D 98 "Model Name: " 8A "Type-O "
"Tram" 00 98 "Manufactuerer: " 8A "Siemens Duewag "
0D 98 "Model Name: " 8A "Type-K Tram" 00
But I cannot figure out why is not working in mygrf. I think there is something more that I should write somewhere but I don't know what
regards
Michael
Re: Add field on vehicle window
Pff.... Now I'm really lostmichael blunck wrote: ↑12 Mar 2021 12:55Wow!Eddi wrote: ↑12 Mar 2021 12:52 the NFO code resulting from my code looks something like this:
Code: Select all
[imagine some action4 here] // Name: text_switch_default 3144 * 109 02 00 B7 89 1A 20 \dx0000D0A2 \2<< 1A 20 \dx00000010 \2sto 1A 20 \dx00000080 \2r 1A 20 \dx0000D00A \2| 7D 80 20 \dxFFFFFFFF \2sto 1A 20 \dx00000100 \2r 1A 20 \dx0000D0A0 \2<< 1A 20 \dx00000010 \2sto 1A 20 \dx00000081 \2r 1A 20 \dx0000D0A1 \2| 7D 81 20 \dxFFFFFFFF \2sto 1A 20 \dx00000101 \2r 1A 00 \dx00000000 \b1 \wx8000 \dx00000001 \dx00000000 // Bogus range to avoid nvar == 0 \wx809E // default: return string(STR_ENG_DESCRIPTION); // Name: @action3_11 3153 * 43 02 00 B9 89 0C 00 \dx0000FFFF \b3 \wx00BA \dx00000000 \dx00000000 // gfx_switch_purchase; \wx00B7 \dx00000023 \dx00000023 // text_switch_default; \wx00BB \dx00000036 \dx00000036 // @action3_9; \wx00B9 // gfx_switch;
Re: Add field on vehicle window
For each vehicle I have 3 action2 sprites and one actio3
I'm pretty sure that the last action2 refer to what I want to change
246 * 43 02 01 FB 89 10 00 FF 00 00 00 03 FF 00 09 00 00 00 09 00 00 00 FC 00 0F 00 00 00 0F 00 00 00 00
00 23 00 00 00 23 00 00 00 FE 00
247 * 33 02 01 FF 89 10 00 FF 00 00 00 02 FF 00 09 00 00 00 09 00 00 00 FA 00 0F 00 00 00 0F 00 00 00 FE
00
248 * 43 02 01 FB 89 0C 00 FF FF 00 00 03 FC 00 15 00 00 00 15 00 00 00 FD 00 16 00 00 00 16 00 00 00 FB
00 36 00 00 00 36 00 00 00 FE 00
249 * 53 02 01 FE 89 0C 00 FF FF 00 00 04 FA 00 00 00 00 00 00 00 00 00 FD 00 16 00 00 00 16 00 00 00 03
80 23 00 00 00 23 00 00 00 FF 00 36 00 00 00 36 00 00 00 FE 00
250 * 12 03 01 01 FF 5C 00 01 FF FE 00 FB 00
But when I copy sprites 249 and 250 nothing happens .
P.S. I change the ID in action3 from 5C to my vehicle ID.
I try also deleting last to bytes from Action3 (the FB 00). still nothing
I'm pretty sure that the last action2 refer to what I want to change
246 * 43 02 01 FB 89 10 00 FF 00 00 00 03 FF 00 09 00 00 00 09 00 00 00 FC 00 0F 00 00 00 0F 00 00 00 00
00 23 00 00 00 23 00 00 00 FE 00
247 * 33 02 01 FF 89 10 00 FF 00 00 00 02 FF 00 09 00 00 00 09 00 00 00 FA 00 0F 00 00 00 0F 00 00 00 FE
00
248 * 43 02 01 FB 89 0C 00 FF FF 00 00 03 FC 00 15 00 00 00 15 00 00 00 FD 00 16 00 00 00 16 00 00 00 FB
00 36 00 00 00 36 00 00 00 FE 00
249 * 53 02 01 FE 89 0C 00 FF FF 00 00 04 FA 00 00 00 00 00 00 00 00 00 FD 00 16 00 00 00 16 00 00 00 03
80 23 00 00 00 23 00 00 00 FF 00 36 00 00 00 36 00 00 00 FE 00
250 * 12 03 01 01 FF 5C 00 01 FF FE 00 FB 00
But when I copy sprites 249 and 250 nothing happens .
P.S. I change the ID in action3 from 5C to my vehicle ID.
I try also deleting last to bytes from Action3 (the FB 00). still nothing
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Add field on vehicle window
Small example m4nfo -> nfo:
Note that for text IDs you have to give a callback result in callback 23, i.e. for ID "0x200" 0x8200 (00 82).
regards
Michael
Code: Select all
define(TAL_HIGH1, 0×200) // O 'Breslau' 1913
defgrftext(TAL_HIGH1, ALL,
T_BLACK _TYPE T_LORANGE "Breslau" CRLF
T_BLACK _WEIGHT T_LORANGE "22t" CRLF
T_BLACK _VOLUME T_LORANGE "28 m" B3 CRLF
T_BLACK _AVAIL T_LORANGE "1913 - 1935" CRLF
T_BLACK _LIFE T_LORANGE "40" _YEARS CRLF
CRLF T_LGREEN _REFIT
CRLF T_BLACK _DBXL09,
...
)
->
25 * 0 04 00 FF 33 00 d2
98 81 70 d4 8A "Breslau" 0d
98 81 71 d4 8A "22 t" 0d
98 81 72 d4 8A "28 m" B3 0d
98 81 73 d4 8A "1913 - 1935" 0d
98 81 74 d4 8A "40" 81 75 d4 0d
0d 91 81 77 d4
0d 98 81 7e d4 00
...
def(4) callback(
grftext(TAL_HIGH1) if(CB_TEXT)
ref(3) else
)
->
838 * 0 02 00 04 85 0C 00 FF FF 01
00 82 23 00 23 00
00 03
regards
Michael
Re: Add field on vehicle window
Thank you for your time and support. I try your code, also found some other code but still not appear. After I chaange something in Action3 like added ID of this action2, only then it worked, but not like I was expected. It changed also my picture of the trolley. It is something that I'm missing but I don't know what.michael blunck wrote: ↑12 Mar 2021 13:49 Small example m4nfo -> nfo:
Note that for text IDs you have to give a callback result in callback 23, i.e. for ID "0x200" 0x8200 (00 82).Code: Select all
define(TAL_HIGH1, 0×200) // O 'Breslau' 1913 defgrftext(TAL_HIGH1, ALL, T_BLACK _TYPE T_LORANGE "Breslau" CRLF T_BLACK _WEIGHT T_LORANGE "22t" CRLF T_BLACK _VOLUME T_LORANGE "28 m" B3 CRLF T_BLACK _AVAIL T_LORANGE "1913 - 1935" CRLF T_BLACK _LIFE T_LORANGE "40" _YEARS CRLF CRLF T_LGREEN _REFIT CRLF T_BLACK _DBXL09, ... ) -> 25 * 0 04 00 FF 33 00 d2 98 81 70 d4 8A "Breslau" 0d 98 81 71 d4 8A "22 t" 0d 98 81 72 d4 8A "28 m" B3 0d 98 81 73 d4 8A "1913 - 1935" 0d 98 81 74 d4 8A "40" 81 75 d4 0d 0d 91 81 77 d4 0d 98 81 7e d4 00 ... def(4) callback( grftext(TAL_HIGH1) if(CB_TEXT) ref(3) else ) -> 838 * 0 02 00 04 85 0C 00 FF FF 01 00 82 23 00 23 00 00 03
regards
Michael
If I use action04 and action2 like you suggested (without action3) should work? As far as I read about action3 is just mapping action0 vehicle id with some cargo define at action2 and also some graphics define at action 2, but I cannot figure out what to do.
Here is a pat of the code:
76 * 1 00
77 * 9 02 01 AA 01 01 00 00 00 00
78 * 9 02 01 DD 01 01 01 00 01 00
79 * 14 02 01 01 81 10 00 FF 01 49 80 01 01 AA 00
80 * 14 02 01 03 81 0C 00 FF 01 01 00 33 33 AA 00
82 * 10 03 01 01 44 01 FF DD 00 03 00
So after Sprite 8 I added somethink like this:
81 * 53 02 01 FC 89 0C 00 FF FF 00 00 04 FA 00 00 00 00 00 00 00 00 00 FD 00 16 00 00 00 16 00 00 00 00
80 23 00 00 00 23 00 00 00 FE 00 36 00 00 00 36 00 00 00 FC 00
When I reffer in action I replace DD with FC (id of the action 2 that I added). then it worked but my trolley changed it's picture
-
- Tycoon
- Posts: 5948
- Joined: 27 Apr 2005 07:09
- Contact:
Re: Add field on vehicle window
Ah, you didn't mention that you're on cargo culting.
In fact, Eddi and me only showed code snippets illustrating use of callback 23 for extra text in purchase menu.
We didn't provide a complete grf, in no way. I.e., o/c you need proper action 0 and action 3 as well.
regards
Michael
In fact, Eddi and me only showed code snippets illustrating use of callback 23 for extra text in purchase menu.
We didn't provide a complete grf, in no way. I.e., o/c you need proper action 0 and action 3 as well.
regards
Michael
Re: Add field on vehicle window
OK. I'm not very familiar with case. Shold it be something like this:
* 20 02 01 03 81 0C 00 FF 01 01 00 33 33 AA 00 00 80 23 00 02 00 ?
I try also like this with no luck:
* 22 02 01 03 81 0C 00 FF 01 01 00 33 33 AA 00 00 80 23 00 23 00 02 00 ?
I undestant the 00 80 means first item inside action4 block that I define earlier. 02 00 don't know what it means.
Anyway, does not show any additional text with the combination above. Any ideeas?
P/S. I let action3 like it was before:
82 * 10 03 01 01 44 01 FF DD 00 03 00
Thanks for your help
Re: Add field on vehicle window
ok. step backwards for a minute. excercise for you:
take this line
Code: Select all
80 * 14 02 01 03 81 0C 00 FF 01 01 00 33 33 AA 00
Code: Select all
80 * 14 // number and length
02 // action 2
01 // feature 1
...
https://newgrf-specs.tt-wiki.net/wiki/V ... on2#Format
Re: Add field on vehicle window
I looked on the wiki bt I do not understant all the data there. Here is what in uderstood:Eddi wrote: ↑14 Mar 2021 22:52ok. step backwards for a minute. excercise for you:
take this lineand comment each byte with it's meaning like this:Code: Select all
80 * 14 02 01 03 81 0C 00 FF 01 01 00 33 33 AA 00
use this page for reference:Code: Select all
80 * 14 // number and length 02 // action 2 01 // feature 1 ...
https://newgrf-specs.tt-wiki.net/wiki/V ... on2#Format
80 * 14 // number and length
02 // action 2
01 // feature 1
03 - ID of Action2, to be used in action 03 if neccesarry
81 - I guess it's refering what to access from the callback parameter (example for callback 33 , has a param of 01 00 access 00)
0C - callback
00 FF 01-I'm lost
01 00 - the call back parater or return (I saw that if I set for example 01 80 in callback 23, it will write the 2nd data from action04 string - because of that 01)
33 33 - I guess this is the call back (although I was expected 33 00)
0A 00 - I'm lost
Any help will be appreciated.
Thanks
Re: Add field on vehicle window
I figure out the action2 command but I cannot integrated in Action3.sky81 wrote: ↑15 Mar 2021 06:09I looked on the wiki bt I do not understant all the data there. Here is what in uderstood:Eddi wrote: ↑14 Mar 2021 22:52ok. step backwards for a minute. excercise for you:
take this lineand comment each byte with it's meaning like this:Code: Select all
80 * 14 02 01 03 81 0C 00 FF 01 01 00 33 33 AA 00
use this page for reference:Code: Select all
80 * 14 // number and length 02 // action 2 01 // feature 1 ...
https://newgrf-specs.tt-wiki.net/wiki/V ... on2#Format
80 * 14 // number and length
02 // action 2
01 // feature 1
03 - ID of Action2, to be used in action 03 if neccesarry
81 - I guess it's refering what to access from the callback parameter (example for callback 33 , has a param of 01 00 access 00)
0C - callback
00 FF 01-I'm lost
01 00 - the call back parater or return (I saw that if I set for example 01 80 in callback 23, it will write the 2nd data from action04 string - because of that 01)
33 33 - I guess this is the call back (although I was expected 33 00)
0A 00 - I'm lost
Any help will be appreciated.
Thanks
If I append the command like this:
02 01 03 81 0C 00 FF 01 02 00 33 33 AA 00
00 80 23 23 FE 00
then the text will not appear.
The text appear if I set in Action3 the ID of this text after the action0 ID, like this:
* 10 03 01 01 44 01 FF 03 00 03 00
But I cannot do that because this alterates the graphic picture of the bus.
So the solution is to make another Action2 variaation with same ID like the grapfics: DD
something like this:
188 * 1 00
189 * 9 02 01 AA 01 01 00 00 00 00
190 * 9 02 01 DD 01 01 01 00 01 00
191 * 14 02 01 01 81 10 00 FF 01 49 80 01 01 AA 00
192 * 14 02 01 03 81 0C 00 FF 01 01 00 33 33 AA 00
193 * 14 02 01 DD 81 0C 00 FF 01 00 80 23 23 FE 00
194 * 10 03 01 01 44 01 FF DD 00 03 00
But the picture that appear in the buying window is not the one from Sprit 190 or sprit 189.
Like is ignoring Sprit 189,190.
This happens only if I inserted line 193.
Any ideeas?
Last edited by sky81 on 15 Mar 2021 09:17, edited 1 time in total.
Who is online
Users browsing this forum: Google [Bot] and 6 guests