Describe the bug
I set out to create a character object (adventurer) which could be procedurally fed multiple dialogue lines to be customized within the object itself, via string interpolation using the template literal backtick (). The function would then at runtime be able to generate the proper phrase given global variables, or those on the object itself, even if they've been modified during play. The issue is that using the macro <> is causing interference with the reserved words "to" and "is".
The code would go like this:
<<set $namePicked to "Nathan">>
<<set $jobPicked to "barkeep">>
<<set $adventurer = {
name : $namePicked,
job : $jobPicked,
introduction : function(){
return `My name is ${this.name}. I used to be a rising ${this.job} until I was recruited to be an adventurer.`;
}
}>>
<<print $adventurer.introduction()>>
Expected behavior.
It was expected that the $adventurer.introduction() function would return the string "My name is Nathan. I used to be a rising barkeep until I was recruited to be an adventurer." but it instead returns the string "My name === Nathan. I used = be a rising barkeep until I was recruited = be an adventurer." (which, granted, is pretty funny).
Screenshots.
This is what the user would see.
To Reproduce:
The code above should work to reproduce the issue.
Project details.
SugarCube Version: 2.34.1
Included Add-ons: None
Included Libraries: None
Compiler & Version: Twine 2.3.13, Tweego 2.1.1
Additional context.
Is this a pure question of "Sugarcube doesn't support template literals", or should there be a better way of handling this kind of issue?
Describe the bug I set out to create a character object (adventurer) which could be procedurally fed multiple dialogue lines to be customized within the object itself, via string interpolation using the template literal backtick (
). The function would then at runtime be able to generate the proper phrase given global variables, or those on the object itself, even if they've been modified during play. The issue is that using the macro <> is causing interference with the reserved words "to" and "is".
The code would go like this:
Expected behavior. It was expected that the
$adventurer.introduction()
function would return the string "My name is Nathan. I used to be a rising barkeep until I was recruited to be an adventurer." but it instead returns the string "My name === Nathan. I used = be a rising barkeep until I was recruited = be an adventurer." (which, granted, is pretty funny).Screenshots. This is what the user would see.
To Reproduce: The code above should work to reproduce the issue.
Project details.
Additional context. Is this a pure question of "Sugarcube doesn't support template literals", or should there be a better way of handling this kind of issue?