Creating the name variable


First off, I’m sorry that I’m posting a second discussion on the same topic as my last one, but I’m in a bit of a hurry and considering that I’m a bit slow with technology and the fact that I need to get this done as soon as possible, here it is again:

I want to creat a text box for the player to write their character’s name in and then be able to program to game so that everytime their name comes up I can just type something like *player_name or something like that so that I won’t have to make a million different copies. Also, I’d like to know how to be able to make choices so that whatever choice the person chooses it shows up on the “stats” area. Example:

Which clan will you be in?





And then which ever one they pick will appear in the blank spot on the stats screen that says “Clan:”

Pictures of what you’re talking about help a lot!


I use fakechoice so it falls to the next thing it saves time for me

     *set clan "Thunder Clan" 
  #River Clan
     *set clan "River Clan"
  #Shadow Clan
     *set clan "Shadow Clan"
  #Wind Clan
     *set clan "Wind Clan"

Put name here
*input_text player_name
*set player_name "$!{player_name}" (this will capitalize the name, but this isnt needed)

Sorry im not too indepth with the explaining, Im not the best person at breaking things down

but if you ever need the player to type something in if its a name

*input_text [insert stat here]

and if its a number

*input_num 1 100 (the first number you put in is the starting range and the second is the end range, so thats pretty much saying you can pick a number from 1-100)

If you ever need anything I dont mind answering, you can always PM me if you feel your posting too many threads


Thanks, I really appreciate that.


Just to expand, ${player_name} is what will display the variable each time - you have to remember the dollar sign and curly braces for it to display correctly ingame.

As a writing tip, you might want to use an easy placeholder, like pname and then use your processor’s Replace action to change it to ${player_name}.

From what I can tell, Notepad ++ is pretty much the most utilized word processing program when writing a ChoiceScript game, as it keeps an easy track of indentation and parenthetic operations. I’d switch to it if you’re not using it already.


Also when you use Notepad++ for me I just edit scenes and stuff normally but I use Notepad on the stuff I cant open normally idk if its only me but when I normally write a scene or something then switch to notepad I get tons of errors about indentions and tons of other stuff


Okay, so I moved everything over to Notepad++, but of course, I’m still getting some errors. Here’s how I have some of the files set up (startup):

What is your name?


#It is *input_text name
Example description *set name ${player_name}


text Name

----------------(and mygame.js):

stats = {
knowledge: 50
,player_name: ${player_name}

The errors that come up when I try to open the index are:

Invalid character
Unable to get value property ‘setStartingStatsClone’: object is null or undefined
(and when I click on Show Stats): Unable to get value of the property ‘sceneName’: object is null or undefined


This is the proper structure for a fake/non-guiding choice:

You have to choose a weapon...
   #I chose a sword!
     *set chosen_weapon "sword"
   #I chose an axe!
     *set chosen_weapon "axe"
   #I chose a mace!
     *set chosen_weapon "mace"
   #I chose a rubber duckling!
     *set chosen_weapon "duckling"

Here’s an example of default name input, it doesn’t go under a choice:

*input_text player_name
Ah, so your name is $!{player_name}, and what a marvellous name it is!

In mygame.js, have this (not $!{player_name}):

stats = { 
knowledge: 50 
,player_name: ""


Just reposting my draft earlier that I thought I submitted

Okay so startup should look something like this, also I see your problem your name stat is the player_name stat so adjust all the following like this

What is your name?

  #It is
    *input_text player_name

choicescript_stats like this

  text player_name

and here is another problem here your creating a stat then trying to set that stat to display itself which you can never do in mygame.js thats a no-no

stats = {
  knowledge: 50
  ,player_name: ""

the stat is set to unknown until in the scene when the reader inputs the text it should change that stat for you, everything should be all set…

But yah its pretty much the same stuff CJW said, but yah if I missed something plz tell me


I wrote it down just as you did, but I’m still coming up with the same errors.


hmm hold on


take the ‘setStartingStatsClone’ whatever that stat out you cant capitalize anything unless its in gray in the mygame.js


But that’s just it- either it’s not there or I can’t find it. I’m not really sure what it is (I mean, I could guess by the name, but there doesn’t seem to be anything that would suggest it)



Any chance I could convince you to paste your mygame.js contents in between some `


` tags for us? It would make it easier to diagnose the problem.


Sure. This is starting at line 21

// Specify the list of scenes here, separated by commas, with no final comma

nav = new SceneNavigator([


// Specify the default starting stats here

stats = {
    knowledge: 50
    ,loyalty: 50
    ,medicine: 50
    ,faith: 50
    ,ambition: 50
    ,honor: 50
    ,courage: 50
    ,compassion: 50
    ,fighting: 50
    ,hunting: 50
    ,graypaw: 50
    ,bluestar: 50
    ,tigerclaw: 50
    ,sandpaw: 50
    ,player_name: ""


// Specify the stats to use in debug mode

debugStats = {
    cats: 50
    ,shoes: 50

// or just use defaults
// debugStats = stats


Well, the good news is that there’s nothing wrong with your mygame.js (other than the odd debugStats, but those aren’t causing your errors). Your stats should function just fine as long as you’re using the right formats for displaying your variables.

The bad news is that I can’t narrow it down anymore than to tell you it’s something with your scene files. Are you still getting the “invalid character” error? That one can at least give you a location (character and line number) to start figuring out what’s wrong.


Yah, there should be no reason im pretty sure you only get a stat clone when you go something like this in your mygame

player_name: ${player_name}

that would cause that error but I dont see why its saying that


I checked over the list of stats in mygame.js and compared it to the choicescript_stats page to see if I had accidently miss-spelled anything or something like that and couldn’t find any errors or anything that would suggest that something was wrong. Yet I’m still getting the “invalid character” error. I’m sorry to ask again, but are you sure there’s nothing wrong with the files I posted? Or maybe there’s another file I should check?

The only thing in mygame.js about names is ,player_name: “”, and if I’m hearing you two correctly, there’s nothing wrong with what I’ve written. I’m so confused as to why none of this seems to be working, but I really appreciate that the two of you have been trying to help, even if nothing has really been solved so far.


Make sure you’re not copying code from something like Word.
You need to write it directly in your editor, that’s the only other common issue it might be.


I’m typing it directly into Notepad++, so I’ve made sure of that.


I think I’ll try uninstalling and then re-downloading it, just to see if that helps at all.