46
Technical Support / [2013-2-7] Adventure Cow patch
« on: February 07, 2013, 10:39:45 PM »
One quick update, support for gt, gte, and, or, etc.: http://gimcrackd.com/etc/doc/#code,if
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
So while messing in twine, I came across a place where I would want a random effect. Me still being relatively new to Twine, I have no idea if Twine is even capable of doing random events.
Say a player is drinking a potion. I want it to be able to give them a random amount of health or have a chance to poison them.
Is there even a way to do that?
<<set $random = Math.floor(Math.random()*3)>>
<<print $random>>
The reasons the syntax looks like this are long and cumbersome (and have a lot to do with Javascript), but just note that by replacing 3 with a different number, we will get that many different options (for example, if we use 10, we will get 10 numbers, 0-9).<<if $random == 0>>
[[effect one]]
<<endif>>
<<if $random == 1>>
[[effect two]]
<<endif>>
<<if $random == 2>>
[[effect three]]
<<endif>>