WML: message / print

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
HaJo
Inactive Developer
Posts: 174
Joined: August 7th, 2005, 11:52 pm
Location: DE

WML: message / print

Post by HaJo »

It looks like variables work in the "message"-command, but not in "print":

Code: Select all

[event]
  name=start
  [set_variable]
  name=monster
  value="Merman"
  [/set_variable]
# ok:
  [message]
  speaker=narrator
  caption= "Test"
  message= "Monster: $monster."
  [/message]
# Bug:
  [print]
  text="Monster: $monster."
  size=20
  duration=100
  red,green,blue=255,255,255
  [/print]
[/event]
The message-statement shows "Monster: Merman.", which is ok.
But the print-statement shows "Monster: $monster.", i.e. it does not expand the variable.
-HaJo
Rhuvaen
Inactive Developer
Posts: 1272
Joined: August 27th, 2004, 8:05 am
Location: Berlin, Germany

Re: WML: message / print

Post by Rhuvaen »

HaJo wrote:The message-statement shows "Monster: Merman.", which is ok.
But the print-statement shows "Monster: $monster.", i.e. it does not expand the variable.
It's not a bug, it's a documented feature. Dollar signs don't get expanded in every context - it's one of the awkward things about WML. Variables and $-signs are always expressed in the [set_variable] format key.

Try this:

Code: Select all

[set_variable]
  name=print_message
  format="Monster: $monster"
[/set_variable]
[print]
  text=$print_message
[/print]
That will achieve what you desire :).
HaJo
Inactive Developer
Posts: 174
Joined: August 7th, 2005, 11:52 pm
Location: DE

Re: WML: message / print

Post by HaJo »

Rhuvaen wrote:
HaJo wrote:The message-statement shows "Monster: Merman.", which is ok.
But the print-statement shows "Monster: $monster.", i.e. it does not expand the variable.
Try this:

Code: Select all

[print]
  text=$print_message
[/print]
It works - Thanks !
it's one of the awkward things about WML
It would be nice if WML were more 'regular', i.e. less special cases such as this.
-HaJo
Post Reply