Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

Reading through Sugarcube 2's macro documentation

$
0
0
I came across this . Can someone explain the what and why here? What does "..." do and
http://www.motoslave.net/sugarcube/2/docs/macros.html
Passing an expression as an argument.

...

For example, the following will not work because the macro parser will think that you're passing five discrete arguments, rather than a single expression:
<<click "Wake " + $friend + ".">> … <</click>>
You could solve the problem by using a temporary variable to hold the result of the expression, then pass that to the macro. For example:
<<set _text to "Wake " + $friend + ".">>\
<<click _text>> … <</click>>
A better solution, however, would be to use a backtick[1] expression (`…`), which is really just a special form of quoting available in macro arguments that causes the contents of the backticks to be evaluated and then yields the result as a singular argument. For example:
<<click `"Wake " + $friend + "."`>> … <</click>>
I tried running the code myself. It looks like in the first code example it thinks '+' is the name of a passage.
Error: the passage "+" does not exist. What does the "..." do exactly as a backtip expression? How does the ` after the "." in the 3rd code example make it different and what use does the _text (a temporary variable) provide?

Viewing all articles
Browse latest Browse all 1844

Trending Articles