Twine Version: 2.8.1
Story Format Version: Sugarcube 2.36.1
Hi! I’m trying to get my variable’s first letter to show up as a capital letter. This is what I’ve done:
$rulerthey.toUpperFirst()
yet it returned as [function].
I’m pretty sure what i did was correct. I checked everything but nothing seemed to be wrong with my code. What am I doing wrong?
Depending on what you need, there’s two possibilities.
If you want to show the variable with a capital first letter, you can use the <<print>> macro.
<<print $rulerthey.toUpperFirst()>>
It won’t change the variable per se, but it will ensure the first letter is a capital.
However if you want to change the variable itself, you can use the <<set>> macro.
<<set $rulerthey to $rulerthey.toUpperFirst()>>
I’m not sure there’s any way to get any function (somthing with parenthesis) to work directly in the text, you have to use it inside a macro or a call to javascript.
Yeah, there’s a pretty limited set of things that you can write directly in your text without using a <<print>>: they’re described in the documentation under Naked Variable Syntax.
So what’s happening (I assume?) is that it’s printing $rulerthey.toUpperFirst (which is a function) and then showing the parentheses after it. Are you seeing [function]()?
Hiev made a cool page to display how different variables are displayed on the page depending on the kind of variable they are, whether a function is used or a macro: