Printing variable values inside messages
Posted: Tue Mar 22, 2011 2:17 pm
I thought that it would be useful to be able to include 'escape codes' inside of short and long messages which allow you to embed the values of the standard variables in the message. Currently, if you want to say something like:
"The indicator on the console reads: 13"
where 13 is a value that might change, you have to display the message, and then use SAYVAL in a macro to overlay the variable value. And this only works for BMSG and long messages, because the short message command SMSG displays the message, waits for the user to hit a key, and then removes the message before it continues with the macro, so you don't get a chance to overlay your value.
So here's how it works. Inside the message editor, you can write a code that will include the variable value in your message. For example, for the message above, if you want to keep the 'indicator value' in variable Q, then your message would be:
"The indicator on the console reads: @Q1"
When the game displays the message, it will replace "@Q1" with the current value of the variable Q (whatever it is at that point).
The codes are
@A1 through @Z1 - display variables A-Z
@A2 through @Z2 - display variables A2-Z2
I may also have a variation on this that lets you display the variable value (for the 16-bit variables) as either signed/unsigned, so maybe @Z1 would display it as signed (-32768 to 32767) and %Z1 would display it as unsigned (0 to 65535).
I have some code running that seems to work ok, so I am going to roll it into the next patch.
"The indicator on the console reads: 13"
where 13 is a value that might change, you have to display the message, and then use SAYVAL in a macro to overlay the variable value. And this only works for BMSG and long messages, because the short message command SMSG displays the message, waits for the user to hit a key, and then removes the message before it continues with the macro, so you don't get a chance to overlay your value.
So here's how it works. Inside the message editor, you can write a code that will include the variable value in your message. For example, for the message above, if you want to keep the 'indicator value' in variable Q, then your message would be:
"The indicator on the console reads: @Q1"
When the game displays the message, it will replace "@Q1" with the current value of the variable Q (whatever it is at that point).
The codes are
@A1 through @Z1 - display variables A-Z
@A2 through @Z2 - display variables A2-Z2
I may also have a variation on this that lets you display the variable value (for the 16-bit variables) as either signed/unsigned, so maybe @Z1 would display it as signed (-32768 to 32767) and %Z1 would display it as unsigned (0 to 65535).
I have some code running that seems to work ok, so I am going to roll it into the next patch.