0 votes
asked by (360 points)
<<set $numberOne = 2>>
<<set $operator = "/">>
<<set $numberTwo = 2>>

<<print $numberOne $operator $numberTwo>> (result = 1)

Can I somehow make it work?

1 Answer

+1 vote
answered by (55.3k points)
selected by
 
Best answer

You're close. You can use print, specifically, the patented Stupid Print Trick (tm) to force an evaluation: 

<<= '<<set _result to ' + $numberOne + $operator + $numberTwo + '>>' >>
_result (1)

That said, a function or a widget is probably a cleaner way to achieve this. 

Warning: I didn't test this code. It's possible I made a syntax error. 

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...