I actually specifically did it this way to avoid using prompt because I hate the timing of the prompt (ie I have to give names their own passages because they will pop up right away) and I hate that it clashes with the aesthetic of the game and breaks immersion. This isn't a perfect solution but I have used prompt and wanted this code on purpose to avoid it 😅😅
Okay, my last attempt! This must be annoying, I'm sorry.
First, the variables $firstname and $lastname have to be set/created somewhere so that the variables actually have a value, even if it's "".
(set: $firstname to "", $lastname to "")
Then on the passage where the player inputs their name, I tried to figure out how to force the player to do so. Allowing the player only to continue once they hit those "Confirm" buttons.
My solution now was to turn [that was that.] into a named hook.
Then I created an (even:) that checks whether $lastname and $firstname have the value "" or not.
Once both variables have a value that is not "", the named hook gets replaced with a passage link.
Meaning the player can only continue once both names have been set.
See below:
...but when you'd asked if maybe a mistake had been made, the man at the desk had said it didn't matter, and [that was that.]<goto|
(event: when ($firstname is not "") and ($lastname is not ""))[(replace: ?goto)[[[that was that.->prologue_6 start]]]]
Oh no it's not annoying !! I'm glad to have another set of eyes on it !! And it probably would be good to at least be able to inform people when they haven't hit the right buttons huh, although I still would rather just set a name for them. I think my big issue isn't so much worry that people will forget, more or less that there's a subset of readers who aren't interested in picking a name at all and would usually opt for a default.
I am initializing first and last name to be blank, but I did so with the intent of setting a name if the names had not been set using confirm, which circles us back around to "it only works for ONE of the variables for no particular reason". My prior idea to set a "default" name while initializing the variables and then allowing them to be overwritten with the confirm button yielded results though !! Not functioning results, but I'm finding that regardless of how first and last name are intialized, the javascript will always overwrite them with null value 0 if the confirm button isn't clicked. Even setting the value in the HTML is moot if the confirm buttons aren't clicked.
OH I JUST DID IT !! I made the (set:) on the subsequent page check for both a variable that was equal to zero and a variable that was completely unset. I think the reason for it only working for one or the other when I attempted one way or another is because I think the code is meant to serve one name box on one page, s I think one name was being set t value blank, or whatever value was in the HTML, and the other one wasn't being set at all.
Or, whatever. I'm going to upload that change, thanks for talking through it with me !!
I usually use (link:) on twine when I'm using the prompt macro and then stick the variable there so it prints their name once they've entered it- (link: "Change")[(set: $name to (prompt: "Your name", "whatever"))$name]
I also use the (if:) macro for making sure they've changed their name from the default I set earlier, and only let them continue once they have, with the help of (live:), so that they have to open the link in order to continue.
The HOOPS that Harlowe makes us jump through to set custom string variables smh 😩 I usually just punish naughty users who don't set their name by giving them a default one. I figure that does double the work because then if people don't want to bring out the ol name generator they can just take whatever I give them 😂