Parameters in custom messages

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
a.locritani
Engineer
Engineer
Posts: 111
Joined: 08 Feb 2007 11:59
Skype: a.locritani
Location: Italy

Parameters in custom messages

Post by a.locritani »

Hi!
I've a simple question: can I put a parameter value in a custom message? example: parameter #1 = 1 -> text in custom message: "the first parameter is 1" in a dynamic way (so if param is 2 the same text shows 2 and so on) not using static messages and a series of "if" (action7)

I know that using action4 I can set custom messages, and string codes 7B..87 can format the text so it's shown on wanted format. but how putting parameters there?

and another question: string codes 7B..87 take their argument from the stack, but what this means? i know what a stack is: a LIFO (last-in/first-out) structure. well, string codes 7B...87 and others do a "pop" from the stack (I think), but who does "push" and when?

I've looked in the wiki and i found nothing. It's not there or I've missed it?

thanks in advance
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 991
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: Parameters in custom messages

Post by frosch »

Please specify where you want to use that "custom message".
a) ActionB
b) Vehicle/Station/Industry Name
c) Message returned by some callback (e.g. additional text in various build/show vehicle/industry windows)
d) something else?
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
a.locritani
Engineer
Engineer
Posts: 111
Joined: 08 Feb 2007 11:59
Skype: a.locritani
Location: Italy

Re: Parameters in custom messages

Post by a.locritani »

I want to use it as a message returned from callback 28
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: Parameters in custom messages

Post by michael blunck »

As the range 0000-03ff displays the misc .grf text Dxxx as error message, you should be able to use substrings in constructing those .grf texts, i.e. 81 Print substring (text ID in next 2 bytes of string).

regards
Michael
Image
a.locritani
Engineer
Engineer
Posts: 111
Joined: 08 Feb 2007 11:59
Skype: a.locritani
Location: Italy

Re: Parameters in custom messages

Post by a.locritani »

@michael blunk

ok, i know i can use substring but I can use parameters as substring? I think not. or at least I cannot find a text id that refers to parameter.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Parameters in custom messages

Post by DaleStan »

One of the 9A codes will push a word onto the stack. "\9A\##\00\00", preceeded by an action 6 that changes the \00\00 to the content of the appropriate parameter, will allow you to use any of the print-word codes to display the content of that GRF parameter. You could also use two print-byte codes, if the parameter was two packed bytes. Using the push-word code twice (high word first, I think) will, with some action 6 magicking, allow you to display a doubleword.

It's probably best to put this string in some out-of-the-way place (eg D3FF) , and reference it with \81, so you don't have to mess with the action 6 when you translate the string.
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
a.locritani
Engineer
Engineer
Posts: 111
Joined: 08 Feb 2007 11:59
Skype: a.locritani
Location: Italy

Re: Parameters in custom messages

Post by a.locritani »

Thanks, DaleStan, I'll try your suggestion.
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: belgi and 7 guests