I’ve been working on a game, and in the process came across an error. When using the (alert: ) macro, if I try to have displayed in the alert a variable, it leaves the space on the alert blank. Is there a simple solution to this I’m missing, or is there another solution to this problem?
Here is the code that I have for this.
(alert: "You've Leveled Up
Your new attack is: $attackpoints
Your new health is: $health")]
The variables are declare in a previous passage.
Twine Version: 2.3.9
It appears Harlowe doesn’t evaluate the value of story variables you are embedding the String literal you are passing as an argument to the
(alert:) macro, which is why there are ‘blank’ spaces at the point those variables appear.
(note: These is also a potential issue of the fact that you are include line-breaks within the declaration of that String literal, which isn’t normally allowed in most macro/programming languages.)
I tested the following example, which uses String concatenation and the
(str:) macro, and it displayed numeric values within the String being shown by the
(alert:) macro. I also replace the line-breaks with actual HTML
<!-- initials some debug values -->
(set: $attackpoints to 20, $health to 30)
(alert: "You've Leveled Up<br>Your new attack is: " + (str: $attackpoints) + "<br>Your new health is: " + (str: $health))