Printing variable values inside messages

Chris H.'s Ultima / ACS-style game development system!

Moderators: Ice Cream Jonsey, joltcountry

rld
Posts: 223
Joined: Sun Jan 25, 2009 2:17 am
Location: Dallas, TX

Printing variable values inside messages

Post by rld »

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.

garth

Post by garth »

I went to check out the latest download which I assume is in that "partial-megapatch" release from your 2010 post, but on mediafire the last update date reads 9-28-2010. Is there some other archive your keeping up to date rld?

rld
Posts: 223
Joined: Sun Jan 25, 2009 2:17 am
Location: Dallas, TX

Post by rld »

garth wrote:I went to check out the latest download which I assume is in that "partial-megapatch" release from your 2010 post, but on mediafire the last update date reads 9-28-2010. Is there some other archive your keeping up to date rld?
I haven't actually released a patch in a while, but I am just about to. The new patch, which will contain a few of the more recent hacks I have gotten working, will probably be posted on dropbox instead of mediafire once I have it ready to go.

Post Reply