debug prints -- simple & practical
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.
debug prints -- simple & practical
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:
With a little macro (rename it as you wish), we can do just that for WML vars:
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.)
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!
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"
Code: Select all
{note number} # => UI message "number := 3"
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
Hope this helps some of you. Thank you for reading!
Re: debug prints -- simple & practical
For more complex cases, just call [inspect][/inspect].
I use it as https://github.com/ProditorMagnus/Oroci ... ns.lua#L61 https://github.com/ProditorMagnus/Oroci ... nts.lua#L9 https://github.com/ProditorMagnus/Agele ... nu.cfg#L98
I use it as https://github.com/ProditorMagnus/Oroci ... ns.lua#L61 https://github.com/ProditorMagnus/Oroci ... nts.lua#L9 https://github.com/ProditorMagnus/Agele ... nu.cfg#L98
- lhybrideur
- Posts: 369
- Joined: July 9th, 2019, 1:46 pm
Re: debug prints -- simple & practical
I usually do horrible things like [message][/message] but it probably does not work everywhere.