This is sort of a follow up to a
question I asked a while back. I figured a separate discussion was appropriate, as the aforementioned post is dated. Most forums aren't keen on bumping old topics.
Name replacement merely differs in the method used this time around. In the example depicted below, the author allowed the player to choose from a preset selection or type out their own.
I'd like to do the same, but I'm not sure what code to use, or how I would circumvent linking; and creating, a new passage for each name choice -- save, the "Here, I'll type it for you." option.
And in this same line of thought, how would I create an in-twine textbox?
The last name replacement method I used was external; a pop-up in the browser.
<% s.name_player = prompt("Enter Character Name") %>
Comments
Is this what you were referring to, or did you have the code for variables in mind when a choice is made?
If you want to disable story progress (i.e. the ability to move forward) until a name has been entered into the input box, should the player choose that option, then one of the easiest ways to do so is to disable the corresponding Next link until that requirement has been met.
Goes in Story JavaScript: And the passage code: Calling the textBox function sets up a post-display callback which configures the wrapped <input> and <button> elements based on the given parameters.
You can style the <button> element (i.e. #nameinput button) to make it look like the Choice of Robots sample, if that's important to you.
I'm playing with the code a bit; trying to re-use Stylesheet code that #choices buttons utilize, and applying it on the #nameinput button. However, the color doesn't show up when I hover the mouse over the box. What needs to be added to the Stylesheet for it look like the Paint.exe Mockup below?
I'd just like to have the background of the #nameinput box highlight like the #choices box.
An additional goal would be to add text before the textbox, as depicted in the mockup.
If this works, the "Next" button could be stylized to look like the #choices button.
And here is the stylesheet code used for the highlighted #choices boxes.
And the markup: