Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Radio buttons, Dropdowns, and simple Buttons

edited July 2015 in Help! with 2.0
I think I make my life too difficult for no reason, but I swear when I think of doing things I just think of 'this shouldn't be hard..' - in this instance thinking that because this is an HTML output language, Twine 1 seemed to have this, and it is fairly intuitive functionality..

I guess the title is pretty much the question. So let's say that I have something like an inventory page:

You are wearing a TShirt
: Wear (TShirt | DressShirt)


How would I implement this functionality given the following UX options:
Opt 1: Wear a [X] TShirt | [_] DressShirt // <- Radio buttons, sentence updates based on whichever you clicked
Opt 2: Wear a [v| TShirt] // <- Dropdown - click on it, have the options appear underneath, choose one, sentence updated
Opt 3: Wear a [TShirt] | [DressShirt] // <- Two buttons, as you click either the sentence updates

Where whatever you choose, however much you click, the options remain and the sentence updates?

For Option 1, in Twine 1 (from what I can find in the forums) there was a <<radio... syntax, is that available still in Harlowe?
If it isn't then I'd guess there should be a way to do something like [|X|]<cl1|TShirt ; [|_}]<cl2|DressShirt ..
Using links of some kind, but I can't seem to get the hack to quite work..

For Option 2.. that may just be wishful thinking / not possible, I won't worry too much about it if that's the case

For Option 3 I've been trying to do a thing where I write to 'links' into a variable, and then when you click either the links get re-printed out along with the updated sentence.. but it keeps leaving junk around and twisting my brain into a pretzel

For updating that sentence I'm guessing a live timer should do it if I could get the radio buttons or buttons to stay on the screen..?

Sorry.. I can't seem to find anything in the forums about this using the search function, any thoughts, particularly about both radio buttons and static button behavior (dropdowns not a priority but a nice bonus)?

Thank you!!
================
UPDATE: Figured out the button version based on some other code someone had helped me with earlier this year, tweaked the functionality. Leaving it in the question since others might search for this topic sooooo posting below how I did that. Still curious about the radio button?
{(set: $choice to 3)
(set: $choices to (array: "T Shirt", "Dress Shirt", "No Shirt"))
(set: $clothes to $choices's 3st)
(live: 20ms)[
	(if: $choice > 0)[
		$clothes
	]
]}
{(set: $bodyLink to "|body>[
	(link: $choices's 1st)[
		(set: $choice to 1)
		(set: $clothes to $choices's 1st)
        (replace: ?body)[$bodyLink]
	] -- (link: $choices's 2st)[
		(set: $choice to 2)
		(set: $clothes to $choices's 2st)
        (replace: ?body)[$bodyLink]
	] -- (link: $choices's 3st)[
		(set: $choice to 3)
		(set: $clothes to $choices's 3st)
        (replace: ?body)[$bodyLink]	]
]")
$bodyLink
}

Comments

  • The Harlowe story format does not currently have built-in macros for things like radio-buttons, check-boxes, text-areas or buttons.

    Are you willing to change which story format you are using because SugarCube has built-in macros for all of the above and it also included in the Twine 2 application.

    No standard story format has a built-in macro for a Dropdown/Combo box, but SurgarCube does allow Authors to add their own macros, so it should be possible to add one.
Sign In or Register to comment.