I began working on a new game (playing Life of a Wizard inspired me to get back to my attempts to write a ChoiceScript game) and I went to test what I’d done so far, and before anything shows up on the screen regarding my game, I get two error messages, the first saying, “Expected identifier, string or number,” the second saying, “window.nav” is null or not an object." What do those even mean?! No part of my game showed up at all, so I can’t believe it is something to do with the coding, as I have never had this issue and as far as I can tell, none of my coding was even reached before the error showed up. My Internet browser also will not run any completed “Choice of” or “Hosted” games from the site anymore, so maybe it doesn’t have anything to do with my coding?
Sounds like poor formatting in mygame.js to me, could you copy and paste its contents for me?
// Specify the list of scenes here, separated by commas, with no final comma
nav = new SceneNavigator([
“startup”
,“gosub”
,“ending”
,“death”
]);
// Specify the default starting stats here
stats = {
name: “Unknown”
,race: “Unknown”
,gender: “Unknown”
,sexuality: “None”
,health: “100”
,magic: “100”
,arrows: “25”
,birthplace: “Unknown”
,home: “Unknown”
,occupation: “None”
,good: “50”
,stoic: “50”
,honorable: “50”
,willpower: “0”
,physicality: “0”
,scheming: “0”
,charming: “0”
,observant: “0”
,impulsive: “0”
,clean: “0”
,vain: “0”
,geography: “0”
,lore: “0”
,agriculture: “0”
,herbalism: “0”
,artistic: “0”
,smithing: “0”
,nature: “0”
,mag_sense: “0”
,hunting: “0”
,cooking: “0”
,weather: “0”
,quick: “0”
,wood: “0”
,alchemy: “0”
,leadership: “0”
,resourceful: “0”
,mel: “0”
,ran: “0”
,ste: “0”
,thi: “0”
,evo: “0”
,ill: “0”
,enc: “0”
,tra: “0”
,hea: “0”
,div: “0”
,nec: “0”
,geo: “0”
,gold: “0”
,weap: “None”
,const: “Healthy”
,quirk: “None”
,stand: “Lowly Citizen”
,name1met: “No”
,name1name: “None”
,name1sex: “None”
,name1romancable: “No”
,name1relate: “None”
,name1occu: “None”
,name1hadsex: “No”
,name1race: “Human”
,name1combat: “None”
,name2met: “No”
,name2name: “None”
,name2sex: “None”
,name2romancable: “No”
,name2relate: “None”
,name2occu: “None”
,name2hadsex: “No”
,name2race: “Human”
,name2combat: “None”
,name3met: “No”
,name3name: “None”
,name3sex: “None”
,name3romancable: “No”
,name3relate: “None”
,name3occu: “None”
,name3hadsex: “No”
,name3race: “Human”
,name3combat: “None”
,name4met: “No”
,name4name: “None”
,name4sex: “None”
,name4romancable: “No”
,name4relate: “None”
,name4occu: “None”
,name4hadsex: “No”
,name4race: “Human”
,name4combat: “None”
,lordkilenaolromancable: “No”
,lordkilenaolrelate: “None”
,lordkilenaolhadsex: “No”
,ladylinellaromancable: “No”
,ladylinellarelate: “None”
,ladylinellahadsex: “No”
,woodedwitchromancable: “No”
,woodedwitchrelate: “None”
,woodedwitchhadsex: “No”
,mountainmageromancable: “No”
,mountainmagerelate: “None”
,mountainmagehadsex: “No”
,name1heshe: “he”
,name2heshe: “he”
,name3heshe: “he”
,name4heshe: “he”
,name1hisher: “his”
,name2hisher: “his”
,name3hisher: “his”
,name4hisher: “his”
,name1hishers: “his”
,name2hishers: “his”
,name3hishers: “his”
,name4hishers: “his”
,name1himher: “him”
,name2himher: “him”
,name3himher: “him”
,name4himher: “him”
};
// Specify the stats to use in debug mode
debugStats = {
name: “Unknown”
,race: “Unknown”
,gender: “Unknown”
,sexuality: “None”
,health: “100”
,magic: “100”
,arrows: “25”
,birthplace: “Unknown”
,home: “Unknown”
,occupation: “None”
,good: “50”
,stoic: “50”
,honorable: “50”
,willpower: “0”
,physicality: “0”
,scheming: “0”
,charming: “0”
,observant: “0”
,impulsive: “0”
,clean: “0”
,vain: “0”
,geography: “0”
,lore: “0”
,agriculture: “0”
,herbalism: “0”
,artistic: “0”
,smithing: “0”
,nature: “0”
,mag_sense: “0”
,hunting: “0”
,cooking: “0”
,weather: “0”
,quick: “0”
,wood: “0”
,alchemy: “0”
,leadership: “0”
,resourceful: “0”
,mel: “0”
,ran: “0”
,ste: “0”
,thi: “0”
,evo: “0”
,ill: “0”
,enc: “0”
,tra: “0”
,hea: “0”
,div: “0”
,nec: “0”
,geo: “0”
,gold: “0”
,weap: “None”
,const: “Healthy”
,quirk: “None”
,stand: “Lowly Citizen”
,name1met: “No”
,name1name: “None”
,name1sex: “None”
,name1romancable: “No”
,name1relate: “None”
,name1occu: “None”
,name1hadsex: “No”
,name1race: “Human”
,name1combat: “None”
,name2met: “No”
,name2name: “None”
,name2sex: “None”
,name2romancable: “No”
,name2relate: “None”
,name2occu: “None”
,name2hadsex: “No”
,name2race: “Human”
,name2combat: “None”
,name3met: “No”
,name3name: “None”
,name3sex: “None”
,name3romancable: “No”
,name3relate: “None”
,name3occu: “None”
,name3hadsex: “No”
,name3race: “Human”
,name3combat: “None”
,name4met: “No”
,name4name: “None”
,name4sex: “None”
,name4romancable: “No”
,name4relate: “None”
,name4occu: “None”
,name4hadsex: “No”
,name4race: “Human”
,name4combat: “None”
,lordkilenaolmet: “No”
,lordkilenaolromancable: “No”
,lordkilenaolrelate: “None”
,lordkilenaolhadsex: “No”
,lordkilenaoldiplomacy: “None”
,ladylinellamet: “No”
,ladylinellaromancable: “No”
,ladylinellarelate: “None”
,ladylinellahadsex: “No”
,ladylinelladiplomacy: “None”
,woodedwitchmet: “Np”
,woodedwitchromancable: “No”
,woodedwitchrelate: “None”
,woodedwitchhadsex: “No”
,woodedwitchdiplomacy: “None”
,mountainmagemet: “No”
,mountainmageromancable: “No”
,mountainmagerelate: “None”
,mountainmagehadsex: “No”
,mountainmagediplomacy: “None”
,name1heshe: “he”
,name2heshe: “he”
,name3heshe: “he”
,name4heshe: “he”
,name1hisher: “his”
,name2hisher: “his”
,name3hisher: “his”
,name4hisher: “his”
,name1hishers: “his”
,name2hishers: “his”
,name3hishers: “his”
,name4hishers: “his”
,name1himher: “him”
,name2himher: “him”
,name3himher: “him”
,name4himher: “him”
};
// or just use defaults
// debugStats = stats
Thanks so much for the quick response! Also, I purposely removed some of the scenes from the navigator since I will be making them different from what starts out there anyway. I realize that there are some “strange” variables in there, but I am planning on adding some humorous “achievements” of a sort at the very end of the game.
Have following variables have been copied and pasted from somewhere (MS Word for example)? The quotation marks need changing, I’ve fixed the top one as an example:
,name1heshe: “he”
,name2heshe: “he”
,name3heshe: “he”
,name4heshe: “he”
,name1hisher: “his”
,name2hisher: “his”
,name3hisher: “his”
,name4hisher: “his”
,name1hishers: “his”
,name2hishers: “his”
,name3hishers: “his”
,name4hishers: “his”
,name1himher: “him”
,name2himher: “him”
,name3himher: “him”
,name4himher: “him”
Can you see the difference?
Wow! Thanks SO much! That honestly NEVER would have occurred to me since I have copied and pasted from MS Word before and nothing bad happened! I can’t believe that I have never copied anything with quotation marks before! I’ll try it!
No problem, though it is advisable to write choicescript straight into a text editor like Notepad ++ (or just notepad) to avoid any additional problems like that.
Alright, I thought that would fix it, but it didn’t. Do you see anything else wrong with it, by any chance? Also, on a different note, is it possible to have a *choice within the stat page? If not, do you know of a different way to have more than one stat screen? Even though many of the variables above will not be displayed, there are still way too many to comfortably put on one stat screen.
You can have multiple stat screens through some ‘hacking’ and you can (now) use choices on stat screens to simulate multiple pages. The latter is the “supported” method, and is much easier to implement though
As for your issue, I actually copy and pasted your mygame variables into a local copy of CS and tested it myself, at first I got an error but after fixing all of them it worked flawlessly, are you sure you got them all?
This is my set (if you want to copy and paste):
I thought I got them all, but it’s possible I missed a couple. I’ll just paste yours and see what happens! Thanks, and again for the stat screen question!
I tried it again, and it didn’t work. I am still getting the same error. What does window.nav mean, and what does it mean when I need a string or number identifier?
The “expected string, identifier etc” error basically means there’s a syntax error in your javascript, since the only file you should have edited that is javascript based is mygame.js - it means something is up with that.
The " problem WAS causing that error, but maybe something else is too, like a missing comma or a semi colon where a colon should be etc.
windows.nav is an “object”; I’m pretty sure it’s related to the other error in this case, the j/s engine is just crashing before it defines it and something else is trying to reference it.
Suggestion? Download a fresh copy of choicescript and copy and paste the mygame.js over yours, keep your other files (and backup your variable list of course).
If that works, you know something is up with mygame.js at least.
So if I get a perfectly new mygame and then paste the version of the variables into it that you edited, it should work then? I haven’t touched any other part of the mygame document.
Has there been a recent java update that I neglected to download so my j/s is out of date and that is what is causing it? Could that cause the error? I don’t even know anything about java, if you couldn’t tell that on your own… Lol, you could tell that on your own- who am I kidding?
I’m not saying it *will* work, but if it does, you know then where your problem lies.
Well, I tried it… It still didn’t work. It worked when I tried opening the game with a completely untouched mygame, so I know that the problem is still with the stat listings. Thanks for all of your help. I’ll post back here if I still can’t figure it out on my own.
That’s a start at least!
I’m sure you’ll manage, if you’re really stuck, I advise uploading it to dropbox or another online source so I can actually see it running - it’s a lot easier to debug that way.
Well, since I know for a fact that the error is with the stats, I am now going through a new mygame and adding the stats to the document 5-10 at a time and then running the game after every few added so that if there is a problem, I can figure out exactly where it is. It is tedious, but when I read through them I didn’t see anything wrong, so it is probably less work to just retype them all out. SO FAR it is working and I am about fifteen stats in.
WOOHOO!!! I found the error! It is running just fine as of right now! I’ll post again if I run into another problem, but for now thanks for all the help!
@Galador - Glad to hear it, and any time. Good luck with your game
Short question:
Galador defines his variables as for example
,leadership: “0”
Wouldn’t that set the variable leadership equal to the string “0” - not to the number?
@loelet Correct, well spotted.
@Galedor You may want to remedy that.