Trying to get a box with the playername to appear in it

Well I’ve lost my old code and I’m a bit stumped in trying to get playername entry done.

I have some code but it’s kinda error-prone…

<<textbox "$name" $name>> \
<<button "Confirm">>
<<set $name to $name.trim()>>
<<if $name is "">>
	<<replace "#name-error">>Please enter a name!<</replace>>
<<else>>
	<<goto "Intro">>
<</if>>
<</button>> &nbsp;&nbsp; \
<span id="name-error"></span>

I have a storyInit file with this within it:

<<set $name to "John">> 

Yet when I run the code the box doesn’t appear, name can’t be entered.

I am using Twine 1.4.2

Since that’s SugarCube code, I’ll assume that’s what you’re intending to use.

I have a storyInit file […]

If that’s not a typo, then that’s part of your problem. The passage’s name is StoryInit and, like all special passage and tag names, is case sensitive—i.e., capitalization matters.

Yet when I run the code the box doesn’t appear, name can’t be entered.

Did you receive any errors or does the text box simply not show up?

I am using Twine 1.4.2

Which version of SugarCube did you install and did you select it as your project’s story format? SugarCube is not bundled with Twine 1, so you must add it manually, and the default story format for Twine 1 projects is Sugarcane, so you must select SugarCube as your project’s story format.

1 Like

I’ve just installed twine 2.3.4 and this seems to have fixed the issues as my old files are now restored.