Howdy, Stranger!

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

User input in Harlowe

I've been struggling to create a simple form at the beggining of a game, where the player can define attributes of his character such as name, job, etc. This post http://scopecreepstudios.com/blog/2015/01/11/44/ was my main source of information.

It's working, but with a real problem: none of the values are stored for more than one passage.

For example, if I have an input on the first passage where the player can set his name (and (set:$yourName to ?fname)), I can show that name on the next passage using "Name: $yourName". However, it doesn't persist to a third passage, and will not work .

"prompt" would be a workaround, since it keeps the value, but it's far of what I was planning. Any chance to keep the user input for reusing all around — in a custom sidebar, for example?

Comments

  • I have attached a basic test of the hack code you linked to, it contains four passage and if you enter a value in the input field, click the Yes that's it and then click on each of the markup links that appear at the bottom of each passage you will see that the $rivalName variable has a value on each of the next three passages.

    The following example shows how to input two values on one passage using the code from that link:
    Your Name: []<fname|
    <input type="text" name="fname" value="Unknown"><button type="submit" onclick="customScripts.submitName('fname')">Update Name</button>
    
    Your Job: []<fjob|
    <input type="text" name="fjob" value="Unknown"><button type="submit" onclick="customScripts.submitName('fjob')">Update Job</button>
    
    [[Second Passage]]
    
    (live:100ms)[(set: $yourName = ?fname)(set: $yourJob = ?fjob)]
    
    ... the Second Passage contains the following:
    Second Passage
    
    Your Name: $yourName
    Your Job: $yourJob
    
  • Thank you, I'll take a look, maybe I'm messing up something in my Javascript, since I have a form validation.
  • Great, now it's working as you've described, and I feel utterly idiot because I have no idea on why it wasn't before...
    Thanks!
  • I try this but i get an error with the button : customScript is not defined ar HTMLButtonElement.onclick.

    There are a special javascript to embed somewhere ?
Sign In or Register to comment.