Error in mygame.js and ui.js


I am getting the following errors on a frequent basis. Up until now I have been redownloading choicescript and pasting my mygame.js and startup.txt into the new files and this has allowed me to use the games for a while, but then I get the same error again. The most recent case has happened after I know I have made no changes to the file.

Error: Invalid character
File: file:///C:/Users/Laptop/Documents/COG%20backup/SA/web/mygame/mygame.js
Line: 1
User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)
Load time: 1330246381512
Persist: cookie



What were you doing when the error occured?

Error: Unable to get value of the property ‘setStartingStatsClone’: object is null or undefined
File: file:///C:/Users/Laptop/Documents/COG%20backup/SA/web/ui.js
Line: 643
User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)
Load time: 1330246381512
Persist: cookie



Contents of mygame.js are as follows:


  • Copyright 2010 by Dan Fabulich.
  • Dan Fabulich licenses this file to you under the
  • ChoiceScript License, Version 1.0 (the “License”); you may
  • not use this file except in compliance with the License.
  • You may obtain a copy of the License at
  • See the License for the specific language governing
  • permissions and limitations under the License.
  • Unless required by applicable law or agreed to in writing,
  • software distributed under the License is distributed on an
  • either express or implied.

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

nav = new SceneNavigator([


// Specify the default starting stats here

stats = {
forename: “Not Set”
, surname: “Not Set”
, gender: “Not Set”
//formal greeting sir/ma’am
, f_greeting: “Not set”
//informal greeting - boy/lady
, i_greeting: “Not set”
//flirty greeting - handsome/beautiful
, fl_greeting: “Not set”
, days_passed: 0
, days_remaining: 28
, study: 0
, social: 0
, fitness: 0
, fatigue: 0
, flight_training: 0
, aerial_combat: 0
, mechanics: 0
, navigation: 0
, survival: 0
, max_days: 28
, flight_attend: 0
, combat_attend: 0
, mechanic_attend: 0
, navi_attend: 0
, survival_attend: 0
, lesson: “Not set”
, flight_skill: 10
, fox: 0
, katt: 0
, molly: 0
, jasper: 0
, benny: 0
, flight_buddy: “None”
, aerial_buddy: “None”
, mech_buddy: “None”
, navi_buddy: “None”
, survival_buddy: “None”
//drlb is lower boundary of dice roll, drub is upper boundary of dice roll.
, diceroll: 0
, drlb: 1
, drub: 3
, lastroll: 0


// Specify the stats to use in debug mode

debugStats = stats`

Not really sure what the problem is, though I suspect the second error is a result of the first error, which makes me think there’s an issue with the mygame.js - line 1 is the disclaimer though, so I’m stumped. Any help would be appreciated, I have e-mailed support anyway, but wondered if anyone else had come across this.


Just downloaded newest version of choicescript and my files work fine in this version. However, I’m not convinced I’m not going to get the error again and looking at these forums this error is something that other people have encountered. Apologies for double post, but can’t see any other way to edit my original post.

Edit: And of course the second I post, the second I see the edit option…


Don’t worry, you’re not going batty, you only get an edit option for something like the first half hour, I think it is. After that it becomes a permanent post.

I’ve never had this particular error but (bearing in mind my own woeful inexperience with these things) it does sound like something relating to the version of ChoiceScript you were running, and should hopefully now be resolved.


Okay, so suddenly got the same error again(!), so did a quick google on the invalid character remark as I began to think this might be a .js issue rather than a choicescript one. Turns out Windows 7 has a (un)helpful little feature when obtaining files from elsewhere (i.e. download from the net) that can ‘block’ you from using certain files. By right clicking the ui.js, there is an option to unblock the file in the general pane beneath attributes. Doing this has fixed the entire issue!

Ideally it seems you should unblock the zipped file before extracting, otherwise it could block more than one file.

Very weird one, but I think a few people might have been victim to it. No idea why it initially allows you to work with a blocked file then it doesn’t but hopefully that’s the end of that one!

Anyway, not sure if CS devs frequent this forum, but it might be an idea to mention this on the download page for Windows 7 users (although weirdly I’m sure I’ve not come across this on my desktop PC which is also Windows 7…)


I have an error very similar to yours, except it is line 1 char 1 that is undefined. I tried your fix and re-extracted, to no avail. If anyone can help me, it would be much appreciated. I have what I think is a good idea and I’d like to make a game with this script.

Thank you!


Hm… The actual JavaScript is usually above my head, but one thing I can think of is trying to start from the top. Redownload the zip file and check that it’s not blocked. Once you’ve extracted the files, check that they’re not blocked individually too.