debug prints -- simple & practical

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
denispir
Posts: 184
Joined: March 14th, 2013, 12:26 am

debug prints -- simple & practical

Post by denispir »

Hello,

Experienced game authors certainly have their own tools for debug prints, maybe better than that. Anyway: I have found a way to implement for WML the wonderful little procedure "note" that I use in debugging... when the programming language allows implementing it: it must be a dynamic language that keeps variable ids. Basically it is used that way:

Code: Select all

    number := 3
    ...
    note number     # => terminal line "number := 3"
With a little macro (rename it as you wish), we can do just that for WML vars:

Code: Select all

    {note number}   # => UI message "number := 3"
The macro code is below. I have also implemented note2 and note3 for 2 or 3 variables, each one on a line. (Much simpler to have 3 macros than using optional args and/or counting them.)

Code: Select all

#define note var_id
[message]
    speaker = narrator
    message = "{var_id} = ${var_id}|"
[/message]
#enddef

#define note2 var_id_1 var_id_2
[message]
    speaker = narrator
    message = "{var_id_1} = ${var_id_1}| ; {var_id_2} = ${var_id_2}|"
[/message]
#enddef

#define note3 var_id_1 var_id_2 var_id_3
[message]
    speaker = narrator
    message ="
{var_id_1} = ${var_id_1}|
{var_id_2} = ${var_id_2}|
{var_id_3} = ${var_id_3}|"
[/message]
#enddef
If you are not familiar with such mess, watch the way to include the value of a WML var of which is given the id: ${id}| , meaning {id} for the literal string of the id, inside $...| to have the value of the variable.

Hope this helps some of you. Thank you for reading! ;-)
User avatar
lhybrideur
Posts: 369
Joined: July 9th, 2019, 1:46 pm

Re: debug prints -- simple & practical

Post by lhybrideur »

I usually do horrible things like [message][/message] but it probably does not work everywhere.
Post Reply