How to have a write your own name option

I managed to set up a text area but what I'm having trouble with is getting my game to recognize what the player puts into the text box as their name from then on,
I'm using the basic:

squiffy.set("name", jQuery("#text_first").val());

However it still doesn't recognize it as the name and doesn't display the text below it which is:

@clear
So your a {name} a {age} year old {gender}?

Any help here?


The problem is probably with the @clear.

@ lines are processed before javascript, so it clears the screen, and then looks for a box currently on the screen with the id text_first.

So you probably want to do:

    squiffy.set("name", jQuery("#text_first").val());
    squiffy.ui.clearScreen();

So you're {name}, a {age} year old {gender}?

Using the javascript version of the clear function gives you better control over which order things are done in.


Yes that worked thank you!
Now I just have to find a way to make it save the text input not save it as " true"


That's an odd problem, but similar to something I've heard about before. Haven't been able to figure out what causes it, because the people having this issue weren't able to share a simple test program that shows the error


My preference is to put JS into separate sections to avoid confusing myself in longer stories.

[[First]]:
What's your name?  <em>My name is</em> <input type="text" style="text-transform: capitalize" id="Jane" size="15">. [[OK]](JS 1)

[[JS 1]]:
    squiffy.set("Jane", jQuery("#Jane").val().replace(/^\w|\s\w/g, function(t) { return t.toUpperCase() }));
    squiffy.story.go("Second");

[[Second]]:
@clear
Hi, {Jane}.

mrangel (above) has also made this extremely handy abbreviation if you use lots of inputs.


[[]]:
    $("input").each(function () {
        set (this.id, this.value);
    });


[[Start]]:

First Name: <input id="FirstName"/><br>
Middle Name:  <input id="MiddleName"/><br>
Surname: <input id="LastName"/><br>
Mother's Maiden Name: <input id="MMName"/> [[Go]](enterInputs)

[[enterInputs]]:
@clear
Greetings, {FirstName} {MiddleName} of the clan of {LastName}, ally of clan {MMName}.

Yeah, however I did figure it out,
When using this:

squiffy.set("name", jQuery("#text_first").val());

I didn't put "#name" in the place where "#text_first" is also I found another text box JS that was much easier and for only one line of text, whereas textarea was for multiple lines.

Input type="text" id="name"/>
[[Yes]](nameT

It works! Thanks for all y'alls help you put a end to my week frustration with it


This topic is now closed. Topics are closed after 180 days of inactivity.

Support

Forums