Page 1 of 1

Parameters in custom messages

Posted: 02 Dec 2008 13:27
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

Re: Parameters in custom messages

Posted: 02 Dec 2008 16:53
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?

Re: Parameters in custom messages

Posted: 02 Dec 2008 20:42
by a.locritani
I want to use it as a message returned from callback 28

Re: Parameters in custom messages

Posted: 02 Dec 2008 21:49
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

Re: Parameters in custom messages

Posted: 02 Dec 2008 22:11
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.

Re: Parameters in custom messages

Posted: 03 Dec 2008 02:50
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.

Re: Parameters in custom messages

Posted: 03 Dec 2008 08:41
by a.locritani
Thanks, DaleStan, I'll try your suggestion.