Non-threaded

Forums » Newbie Central » Read Thread

Introduce yourself and get to know the community.

String Variables

9 years ago

Is there a way that variables can hold strings in storygames? 

i.e. var name = "";

The clerk looked at the floor sheepishly, "I'm sorry, I didn't catch your name."

story choices

a. Adam

b. Anthony

c. Sarah

d. Sydney

e. (User can choose their own name) / userInput

userInput = name;

 

String Variables

9 years ago

Yes, it's possible. This article tells you how to do it. If you want more help, somebody else will have to explain. I'm not that adept at coding yet.

String Variables

9 years ago

First up, hi, welcome, etc. Second, things and questions like this should go in the writing workshop, and they have been answered in there a few times.

Create a variable, PLAYERNAME
Page with a list of names (don't both using a userinput one, to make it with anything more then 2 or 3 letters, is monstrously annoying. You'd need to have a page with 26 links for each letter, repeat for every letter. Not difficult, just tedious). ANyway, link 1 = Ted, set Playername to 1. Link 2 = Ajax, set playername to 2. In the places you want to use their name in text, just need to call it back (If PLAYERNAME = 1, "Ted", if Playername = 2, "Ajax", etc)

String Variables

9 years ago

Actually this kind of thing should go in the advanced editor forum. Stop spreading these disgusting lies to newbies, gosh.

But yes, the most straightforward way to do this is just a matter of assigning a number to whichever name options you give and using on page variables to display them in your story.

Don't let the player enter in their own name unless you hate yourself.