Errors which seem to have no reason


#1

Hi I have been trying to get my mygame.js file working for days now. I have come up against countless errors, very few of which I have solved, and most of which have mysteriously disappeared (probably to reappear later). The current one I have is an error saying:

Expected “}”

After an option to send an email about my error, another comes up saying:

Unable to get value of the property ‘setStartingStatsClone’: object is null or undefined.

I think the second message is as a result of the first one.

This is my mygame.js file without the disclaimer:

nav = new SceneNavigator([
“Setup”
,“A Villiage Burning”
,“Prisoner”
,“A Chance to Prove Yourself”
,“Training”
,“Ascension”
,“Trouble”
,“Hope”
,“A Series of Encounters”
,“The Emperor”

]);

stats = {
name: “Unknown”
,gender: “Unknown”
.age: 18
,leadership: 20
,intelligence: 20
,attractiveness: 20
,strength: 20
,dexterity: 20
,magic: 20
,cunning: 20
,constitution: 20
,luck: 20
,likability: 20
,spontaneity: 20
,valour: 20
,pride: 20
,disdain: 20
,wounds_text: 0
,rank: 50
,style_text: 7
,ally_name: “Unknown”
,ally_loyalty: 0
,heart_text: 0
,rebellion_text: 3
,vengance_text: 0
};

debugStats = stats

Thanks. Please bear in my I have had numerous other errors but for whatever reason they are no longer appearing.

I am pretty sure the error is to do with the 3 variables that are set to “Unknown” as when i remove these it loads up fine.

Don’t get me started on the stats screen.

Thanks again.

EDIT: I don’t know if this is the same for you but when I view this discussion, the spaces needed in the mygame.js file, like before “Setup”, do not show. Please imagine they are there.


#2

I am no expert but I believe you do not want the string lines set in mygame.js just the varibles. So no text just number. The rest set up at the first page of your game. Use *temp or *create and *set. This will solve some of the issues.


#3

@OmniAlpha It looks like you have a period instead of a comma before age. Other than that, I see nothing wrong.


#4

I concur!

Expected “}” must surely be the least helpful error message of all time . . . Anyone care to suggest an even less helpful one? :smiley:


#5

Thank you for the prompt replies. I changed the full stop (period) to a comma shortly after posting this but it still didn’t work. Now, for no apparent reason, it is working perfectly which, despite being odd, is still a best result.

However, just for future reference, which lines are the string lines that Lordirish mentioned?

Thanks anyway


#6

@OmniAlpha, I agree that the period before the age variable was the cause of your seeing the described error. The error message is somewhat helpful, in that it indicates that you have an opening ‘{’ somewhere that isn’t being matched correctly to a closing ‘}’. Either the closing ‘}’ is missing completely, or you’ve tried to do something illegal after the opening ‘{’ and before its matching ‘}’. And, yep, that’s what you had, an illegal period between the matching ‘{’ and ‘}’ for your stats.

As for having string variables in mygame.js, they work just fine for me. JavaScript allows it, and mygame.js is JavaScript, so their presence in the mygame.js file should not be the cause of any problems. In my games, I don’t use *create at all. If I have a permanent variable, I put it in mygame.js and assign it a number, a string, or a boolean, according to how I’ll be using the variable in the game. Works for me.


#7

See I am still learning could never make the string work inside mygame.js proabably a typo on my part.


#8

@OmniAlpha A string is a value that includes two or more characters. So “Unknown” and “Un” are strings, while “U” is just a character. The name variable in your mygame.js is thus an example of a variable set to a string value. So are the gender and ally_name variables.

As @eposic has noted, there’s nothing wrong with having string variables declared in mygame.js. Pretty much all of the newer Choice games do exactly that and nobody is complaining about those games not working.


#9

Depending on who you’re talking to, “U” is also considered to be a string. In some programming languages, you’d represent the character U as ‘U’ and the string U as “U”, and there is a definite distinction. In JavaScript, they’re both strings; you can use either single quotes or double quotes to enclose zero or more characters, and they are considered strings. Yes, “” is also considered to be a string – the empty string.


#10

@eposic True enough. My definition was more literal than functional and potentially misleading. In retrospect I should have worded that differently to better match the javascript context of mygame.js. So yes, a string variable can contain just a single character, or even no characters at all, ie. the empty string.


#11

accidental repeat


#12

I’ve just started a new segment of my game but when I went to try it out an error message saying “invalid character” appeared. I have looked through the new segment and the end of the previous one and see no problem.
Here is the offending script:
From now on you will gain XP when you complete a mission objective. As a reward I am granting you a level, some XP and your first ability.
*level + 1
*xp %+ 10
*choice
*if (aclass=“warrior”)
#Hilt smack: Does 20 points of damage and stuns.
*set abilities “hilt smack”
*page_break

#Double swipe: Deals double damage.
*set abilities “double swipe”
*page_break

#Composure: Heals 20 points.
*set abilities “composure”
*page_break

*elseif (aclass=“mage”)
#Lightning blade: Does 20 points of damage and stuns
*set abilities “lightning blade”
*page_break

#Double flame: Deals double damage.
*set abilities “double flame”
*page_break

#Heal: Heals 20 points
*set abilities “heal”
*page_break

End of test
*finish Test end
And here is the end of the previous script just incase the problem lies there:
*label rec
“So I went to see the headmaster and he suggested that I join you guys.”
*line_break
“Did you ever close the Planar Gate?” Raven asks.
*line_break
“Not me personally but yeah.” The bathroom door opens and Ras steps out. He then walks over to you.
*line_break
“Right, I think it’s about time you meet the rest of the group,” He says
*finish Chapter two-Mission 1


#13

*level + 1
*xp %+ 10

At first glance, those are invalid - seems like they should be *set commands?


#14

It would also be helpful to post actual code snippets with < pre> before and < /pre> after, removing those spaces. That will show the indentation used.

General note: you probably also don’t need all those *line_break commands in your narrative. Just leaving a blank line between paragraphs is fine, as ChoiceScript will also insert that blank line when displayed.

Might be worth checking out the following article before you type up too much more:


#15

Nah, doesn’t work


#16

-=space
From now on you will gain XP when you complete a mission objective. As a reward I am granting you a level, some XP and your first ability.
*set level + 1
*set xp %+ 10
*choice
-*if (aclass=“warrior”)
#Hilt smack: Does 20 points of damage and stuns.
—*set abilities “hilt smack”
—*page_break

#Double swipe: Deals double damage.
—*set abilities “double swipe”
—*page_break

#Composure: Heals 20 points.
—*set abilities “composure”
—*page_break

-*elseif (aclass=“mage”)
#Lightning blade: Does 20 points of damage and stuns
—*set abilities “lightning blade”
—*page_break

#Double flame: Deals double damage.
—*set abilities “double flame”
—*page_break

#Heal: Heals 20 points
—*set abilities “heal”
—*page_break

End of test
*finish Test end


#17

You’re also using *page_break incorrectly – what you need in place of those is a *finish or *goto (label) or similar.

You need to read this:

And this:

For proper use of *choice and *if / *elseif / *else

And this:

To better understand the purpose and correct use of *page_break

Your indentation is also still incorrect, so definitely do read this:

In fact, no offense, but I would honestly suggest pausing in developing your game and go read the Wiki. You’ll save yourself a lot of frustration.


#18

Fixed this section for you, but you do need to learn for yourself why this code will work and yours doesn’t, otherwise you’ll struggle to get anywhere fast.


*set level + 1 
*set xp %+ 10 
*if (aclass = "warrior") 
  *choice
    #Hilt smack: Does 20 points of damage and stuns. 
      *set abilities "hilt smack" 
      *goto end_of_test
    #Double swipe: Deals double damage. 
      *set abilities "double swipe" 
      *goto end_of_test
    #Composure: Heals 20 points. 
      *set abilities "composure" 
      *goto end_of_test
*elseif (aclass = "mage") 
  *choice
    #Lightning blade: Does 20 points of damage and stuns 
      *set abilities "lightning blade" 
      *goto end_of_test
    #Double flame: Deals double damage. 
      *set abilities "double flame" 
      *goto end_of_test
    #Heal: Heals 20 points 
      *set abilities "heal" 
      *goto end_of_test
*else
  You are neither a warrior nor a mage!
  *goto end_of_test

*label end_of_test 
*finish Test end 


#19

Doesn’t work. I’ve checked, double check and triple checked all of my files and nothing seems out of the ordinary.


#20

*if (aclass = "warrior") 

  *choice

and


*elseif (aclass = "mage") 

  *choice

Are the lines that you’ve put wrong; put them as Vendetta said (and as I did above; I quoted Vendetta) and it’ll work.