So I'm making a dungeon-crawler labyrinth style twine in which you can choose to enter a room and can either gain or lose currency (ORE). The following is a test example of a room with a risk rating of 4:
passage:tc1
<<if visited ("tc1") lte 1>>
<<set $dice to either (0,0,0,0,0,0,1,1,1,1)>>
<<if $dice is 0>> you gain <<print $ore += 20>> ORE
<<endif>>
<<if $dice is 1>> you lose <<print $ore -=5>> ORE
<<endif>>
<<endif>>
<<if visited ("tc1") gte 2>>
already visited!
<<endif>>
so there's a 6/10 chance of gaining ore, and a 4/10 chance of losing ore
thing is, this is pretty clunky to put into every cave. I'm quite new to twine (this is only my second game), so I'm not sure how i would go about simplifying this. Is my best option just to edit it passage to passage in order to customize it to my needs? Thank you in advance!
Comments
Anyway, the basics of what you want would be more like the following (upon the first visit only, there's a 60% chance to gain ore elsewise ore is lost). Don't give
visited()
a parameter and it will check the current passage by default. Userandom()
to determine the gain/loss status. For example: (I dropped the "already visited" message, as I assumed it was for debugging purposes) Depending on how often you want this to happen and where, wrapping it up into a widget would save you having to type it all in again (or making a task out of it to make it even more automated, though that would involve JavaScript).That really helps out! oh and it's only gonna display on certain passages. thank you again!
widget
tagged passage): Then simply do the following it in the appropriate passages: If you don't need to alter the percentage chance of gaining ore or the amounts, then the widget could be simplified.