Add field on vehicle window

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: Add field on vehicle window

Post by michael blunck »

Let's see:

Code: Select all

80 * 14	 02 01 03 81 0C 00 FF 01 01 00 33 33 AA 00

->

80 * 14 // sprite number and its length
02 // varAction 2
01 // TTD feature (road vehicle)
03 // sprite ID (for reference)
81 // access type of this action2 (byte access for this vehicle)
0C // check callback var for callback type
00 FF // adjust current variable (shift var right = 0, AND mask result by 0xff)
01 // number of ranges to check for (1)
01 00 // chain to sprite ID (1) on result true (33)
33 33 // range to check for callback type (sound callback)
AA 00 // chain to sprite ID 0xAA on result false
If I append the command like this:

Code: Select all

02 01 03 // varAction2 road vehicle
81 0C 00 FF 01 // check for cb
02 00 33 33 // chain to ID 2 if sound cb
AA 00 // chain to sprite ID 0xAA if not
00 80 23 23 // chain to text ID 0 if additional text cb 
FE 00 // chain to ID 0xFE if not
then the text will not appear. 
Your varAction 2 is malformed. You are checking two (2) ranges.

Code: Select all

* 10	03 01 01 44 01 FF 03 00 03 00
FF xx here denotes the sprite ID of the purchase sprite. You only need this if you want to display a different vehicle sprite in the purchase menu. In addition cb 23 needs to be cheked for in the purchase menu chain. In your case, both refer to sprite ID 3.

So, this makes no sense:

Code: Select all

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
192 * 14	02 01 DD 81 0C 00 FF 01 00 80 23 23 FE 00
193 * 10	03 01 01 44 01 FF DD 00 03 00

->

189 * 9	02 01 AA 01 01 00 00 00 00 // vehicle sprite (on map)
190 * 9	02 01 DD 01 01 01 00 01 00 // vehicle sprite (in purchase menu)

191 * 14	 02 01 01 81 10 00 FF 01
49 80  01 01 AA 00 // cb: sound effect (0x49, bridge sound)

192 * 14	 02 01 03 81 0C 00 FF 01 
01 00  33 33 AA 00 // check cb: sound

192 * 14	 02 01 04 81 0C 00 FF 01 
00  80  23 23 DD 00 // check cb: additional text (text ID 0)

193 * 10	 03 01 01 44 01 FF 04 00 03 00
HTH
Michael
Image
sky81
Engineer
Engineer
Posts: 38
Joined: 29 Oct 2019 05:49

Re: Add field on vehicle window

Post by sky81 »

Thank you very much for your help ad time. Now I understand more of this and now it is working.

I saw that there is an advance action2, which say something like Result=var1+var2.
Do you know if it is possible to concatenate 2 different strings to appear in the window?
For example: I will define two action 4 commands then I call 2 times the action 2 like you show me?
The 2nd time I should set the bit5 in varadjust?

Thank you again for your time
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: Add field on vehicle window

Post by michael blunck »

I saw that there is an advance action2, which say something like Result=var1+var2. 
Do you know if it is possible to concatenate 2 different strings to appear in the window?
For example: I will define two action 4 commands then I call 2 times the action 2 like you show me? 
The 2nd time I should set the bit5 in varadjust?
Advanced action2s are used for mathematical operations on variables.
Dynamically concatenating strings might be a bit complicated, see Eddi's post.

The easiest way to display different independent static strings is to concatenate them manually, like it is done in my example on page 1.

This example also shows the use of "substrings" in composing strings for cb23: i.e. _TYPE, _WEIGHT, _VOLUME, ... are references to substrings already defined beforehand. This would be done in nfo by "81 xx xx", e.g. "81 70 d4" would insert substring "Type: " (0xd470), etc. This works for all languages.

HTH
Michael
Image
sky81
Engineer
Engineer
Posts: 38
Joined: 29 Oct 2019 05:49

Re: Add field on vehicle window

Post by sky81 »

OK, thanks.
I thought it might be a way to concatenate dynamically the strings to not define a long string compose from many substrings
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Add field on vehicle window

Post by Eddi »

yes, there is. but it's complicated...
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 11 guests