I'm using Twine 2.0.11 and SugarCube 2.7.2
In the StoryInit passage I have the line
<<set $Strength to [1,0]>>
The first entry in the array is supposed to be the strength score, the second one the current training level for increasing it.
In the character sheet I'm using to keep track of variables while working I'm using
Strength <<print $Strength[0]>>, Training <<print $Strength[1]>>
to display the current values whenever I visit that passage.
Sadly, the second entry doesn't seem to exist. In fact, when I look at it in the debug view, the entire <<print...>> seems to be missing without any error messages.
I've just started to use arrays and widgets instead of ... less elegant solutions, but this is an error I can't seem to figure out.
Comments
Just for the fun of it I just tried adding a third value, so now it's [1,0,0]. The first and third are displayed, for the second the <<print...>> part is still missing.
I've retyped it, replaced the $Strength[1] with $Name (which does give me the <<print...>> block and displays the name).
Is this maybe a bug?
And another update before going to bed:
I tried making a five-field array [1,2,3,4,5] to see if maybe uneven index numbers were a problem, but 0 and 2-4 work fine, just field 1 is weird. So I'll work around it by avoiding that.
Of course now there's the problem how to report this. I can't even tell if it's a problem with Twine or SugarCube.
I also doubt that it's an issue with SugarCube 2.7.2, for two reasons. First, you're talking about very basic code here—meaning, if it were a SugarCube issue, everyone would be complaining. Second, I tried the exact code shown above and I cannot repro your issue—it works exactly as it should for me, using Play or Test mode.
Is that the actual code from your project or an example? If it is the actual code, was it copy-pasted directly from your project or did you retype it?
EDIT: Also, what does the following print?
Now that I've tried to use the third field, that one is not working and the second one is working fine. =/
I did retype it, but here's those lines as c&p in their current state.:
From the StoryInit:
From the character sheet: EDIT: I know I'm not using an index here, I just wanted to see the whole array to maybe get a hint for the error right now.
And, just to be complete, since it shouldn't have run before doing any training, the widget I want to use for the levelup:
Here's the line I use to call the widget:
And here's the output on the sheet (with the name of the next attribute included):
Now that the problem has moved with me changing which index I use, I suspect I'm doing something wrong in the widged, but, again, it shouldn't have run between starting the test and opening the character sheet.
EDIT: Also, I've updated to SugarCube 2.8.0 now. That release must have happened a day or two after I found Twine. The update didn't change anything though.
Buuut, I'm also an idiot. When pasting your line into the start passage I saw that I had forgotten about a call to run the widget from when I started working on it earlier. That call only had the variable name and no number to increase the training field with, so that's what the error was.
Of course now I see that the training is not working (or at least not the way I want it to), but that I'll have to look at myself first.
The invocation should be: Note the absence of a comma. Macro arguments are separated by whitespace.
As for the widget itself, try the following:
Thanks, I'd have probably taken at least a day or two to notice the invocation was wrong. Other than that, my new (and now, with the correct invocation, working) version was this:
with as the (corrected) invocation.
Yours does seem better of course. I think so far I haven't even looked at Wikifier.
Thanks again!