0 votes
by (490 points)

Hello! I'm trying to create a small segment of my Twine game in which the player is scrolling through stations on a radio - and depending on which station they are on, it will output flavor text suitably, e.g.,

<<if $radio eq "69">>
A woman's voice says 'nice', and then the radio crackles with static before falling silent.

However, I've been out of touch with coding and such for a while now, and I'm not entirely sure how to go about this. If possible, I'd like to have the radio interface (up and down tuning buttons with the readout of what station you're on in between them), and below that, whatever flavor text corresponds to the station you're on. I have no problems with the if/then variables as regards to the text, but the radio interface is stumping me. :/

What I've got so far is as follows (it isn't much and it isn't good, sorry in advance):

The passage is called 'Radio' (as a placeholder), and this is what I've got in it so far -

[[UP|radio][set $radio += 1]]
[[DOWN|radio][set $radio -= 1]]

I set the variable in the passage just before it -

		<<set $radio to 88>>

And possibly because it's a passage that redirects to itself (or... I don't know. something else), clicking on the UP and DOWN buttons does nothing but generate an error message. Help would be appreciated!

1 Answer

0 votes
by (44.7k points)
selected by
Best answer

If the passage is called "Radio" then one problem is that you're trying to navigate to a passage named "radio" instead of "Radio".  The upper/lower-case matters.  The other problem is that you don't put "set" there in the part of the link that changes values.  So, for example, you'd need to change:

[[UP|radio][set $radio += 1]]


[[UP|Radio][$radio += 1]]

If you plan on having a bunch of channels, then you should probably use the <<switch>> macro, instead of a bunch of <<if>> macros.  The <<default>> within a <<switch>> macro can handle the "empty" channels, if you want to do that.

If the text from each channel is long, random, or progresses through events, you also might also want to use the <<include>> macro, and have a passage for each channel, which you display using that macro.

A short example would be:

<<if $radio > 108>>
	<<set $radio = 88>>
<<elseif $radio < 88>>
	<<set $radio = 108>>
[[UP|Radio][$radio += 1]]
Current radio channel: FM $radio
[[DOWN|Radio][$radio -= 1]]

<<switch $radio>>
	<<case 88>>
		<<include "WABC">>
	<<case 103>>
		<<include "WXYZ>>
		You hear static.

And the "WABC" and "WXYZ" passages would contain the text for those channels (perhaps with their own switch macros to display different random text).

Hope that helps!  :-)


by (490 points)
You are brilliant; thank you so much!