How to display speed in proper units in additional text CB?

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
User avatar
George
Tycoon
Tycoon
Posts: 4363
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

How to display speed in proper units in additional text CB?

Post by George »

Hi,
I've tried:
STR_PURCHASE_HINT_SPEED_CHANGE_ON_LOAD :Max speed changes to {VELOCITY} when loaded
string(STR_PURCHASE_HINT_SPEED_CHANGE_ON_LOAD, 70 km/h));
I get nmlc ERROR: "xussr.nml", line 20942: Syntax error, unexpected token "km/h"
How should I specify the data to the {VELOCITY}?
I've tried
string(STR_PURCHASE_HINT_SPEED_CHANGE_ON_LOAD, 70));
I get nmlc ERROR: "lang\english.lng", line 992: Provided a static argument for string command 'VELOCITY' which is invalid
What to do?
Image Image Image Image
Eddi
Tycoon
Tycoon
Posts: 8272
Joined: 17 Jan 2007 00:14

Re: How to display speed in proper units in additional text

Post by Eddi »

you cannot use units in the "string()" itself, you must push the value to the stack in a callback.
User avatar
George
Tycoon
Tycoon
Posts: 4363
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Re: How to display speed in proper units in additional text

Post by George »

Eddi wrote:you cannot use units in the "string()" itself, you must push the value to the stack in a callback.
How can I do in additional_text CB in NML? Could you provide some small example (switch)?
Image Image Image Image
Eddi
Tycoon
Tycoon
Posts: 8272
Joined: 17 Jan 2007 00:14

Re: How to display speed in proper units in additional text

Post by Eddi »

it's probably not "small", but this is the code i use:

Code: Select all

switch(FEAT_TRAINS, SELF, VEH_ID(text_switch_default), [STORE_TEMP(string(STR_AUTO_0) | string(STR_USAGE_PASSENGER) << 16, 0x100), STORE_TEMP(string(STR_TRACK_TYPES_DEFAULT) | string(STR_TRACK_TYPE_E) << 16, 0x101), 0]) {
        return string(STR_ENG_DESCRIPTION);
}
with these strings:

Code: Select all

STR_AUTO_0 :Bo'Bo'
STR_USAGE_PASSENGER                                             :Main line passenger
STR_TRACK_TYPES_DEFAULT                                         :{STRING}
STR_TRACK_TYPE_E                                                :{YELLOW}electrified{ORANGE}
STR_ENG_DESCRIPTION                                             :{BLACK}Axle Scheme: {GOLD}{STRING}{BLACK} Use: {GOLD}{STRING}{BLACK}{}Track Class: {GOLD}{STRING}{BLACK}
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 19 guests