I want code (another seperate function) that will call any function based on my $numCalls variable without using if statements or case statements as I may have many conversations. I know the solution has something to do with using State.variables I’m pretty sure. Just not sure of correct syntax.
Here’s what I’m trying inside of another function:
<<set $numCalls += 1>>
<<set _temp to State.variables["conversation"+$numCalls]>>
<<_temp>> /* I want this to call the function <<conversation2>> */
I’ve also tried
<<set $numCalls += 1>>
<<set _temp to `"conversation"+$numCalls`>>
<<_temp>> /* but conversation2 function still doesn't get called */
Ah yes, I did something like this in my last game using what’s been called the “stupid <<print>> trick.” Which is that if you tell Sugarcube to print something and the string printed is valid Sugarcube markup, it will then also execute that markup. You don’t even need a temp variable; you can just say <<print "<<conversation" + $numCalls + ">>">>.
It feels so kludgy that I wince a little every time I do it, but it does work.
What are your conversations doing? Do they need to be macros or widgets? If they could be passages, you could do <<include `"conversation" + $numCalls`>>