“ReferenceError: stats is not defined”

I’m having trouble with testing my game

The error I’m getting is: “ReferenceError: stats is not defined”

My code looks like this:

*title Choice of the Guardian
*author Blazing Shadows
    *scene_list



*create Passion 50
*create Dominance 50
*create Agility 50
*create Vigilance 50
*create V "woman"
*create W "girl"
*create X “she”
*create Y “her”
*create Z “hers”
*stat_chart
   opposed_pair Passion
     Peacefulness
   opposed_pair Dominance
     Submission
   opposed_pair Agility
     Brute Strength
   opposed_pair Vigilance
     Confidence

This is my first game, so it may seem choppy. I'm a pretty good storyteller because I imagine  everything my characters would do,so I hope that Choice of the Guardian is as good as I wanted it to be. This book is also set in a rather Medieval time period, just so you know.

*page_break I'm Sure It's Fine!

Long ago, before the time of The Curse and during the time of the Garden of Eden, back when the world was perfect, dragons roamed and ruled the Earth. There were four main kinds of dragons; the proud fire dragons with their flaming breath and bright, metallic, iron-hard scales. The earth dragons that spat scalding acid and had deadly stinging tails, not to mention a vastly  territorial nature. The wind dragons who glided on the winds, having no wings of their own, and able to fire bolts of lightning. And last, but not least in any way, the sea dragons with their immense size and strength, the biggest of all the dragon kinds, they preferred the water over flying, though the occasional flight was not out of the ordinary.
 
*line_break
    
When The Curse was inflicted apon Mankind,The dragons at first tried to continue living on the Earth, but they found that after three thousand years of trying to coexist, their race was dwindling. Mankind hunted them for sport, took over their homes, and stole their prey. Little by little, they began to realise that there was no longer a place for them among Mankind. Inherently magical creatures, the dragons tore a rift, a portal,  between an empty, safe world, and this one. Then, down to the last dragonette, they vanished through it.
 
*page_break

Well, all except four.
 
*page_break
A represenative from each tribe, the copper-colored fire, the pearl-scaled wind, the saphire-plated sea and the verdelite earth, each gave up their power to four worthy individuals, one from each corner of the world: modern-era Canada, Australia, Peru, and  Japan. Each of these people became the first Guardians, gifted with unbreakable bones, the power to control their respective elements, a specific set of abilities to match, and a fantastic healing  allowing them to live in the nature of five, sometimes six hundred years.
 
*line_break
    
But perhaps their greatest ability is to be able to transform into the dragons of old.
 
*page_break Cool

Now, one of the Guardians' lives has neared its end, and he has passed the dragon's power to you, a young . . .
*choice
    #Girl
    *goto next
    #Boy
     *set V "man"
     *set W "boy"
     *set X “he”
     *set Y “him”
     *set Z “his”
    *goto next

I see.

So you, as a very young ${W}, recieved the Dragon's Gift, and the ancient Guardian who gave it to you died as soon as the last rays of the sun faded from the sky. You don't remember him at all.

*page_break

What is your name, Guardian?
    *imput_text name
    *goto_next

You near the teen years, and your powers begin to manifest.

Now, let's find out what Gift you were given.

*page_break

If someone were to look for you, what would they most likely find you doing?
*choice
    #Watching the flames in the hearth writhe and dance.
     *set Passion %+5
     *set Vigilance %+5
    *goto_next
    #High in a tree, staring at the birds flying above me.
     *set Agility %+5
    *goto_next
    #Working in my flower/vegetable garden.
     *set Brute Strength %+5
     *set Peacefulness %+5
    *goto_next
    #Skipping rocks in the lake.
     *set Agility %+5
     *set Dominance %+1
    *goto_next

When working with friends to get something done, who gives the orders?
*choice
    #Me. I can handle the resposibility of managing a team.
     *set Dominance %+5
     *set Confidence %+5
    #Me and one other person. We work together to make sure everyone does their part.
     *set Dominance %+1
     *set Confidence %+1
    #Not me. I'll let someone else do the ordering around, thanks.
     *set Submission %+5
     *set Vigilance %+1
    #Ha! "Group project"? I always end up doing most of the work!
     *set Passion %+1
     *set Dominance %+3
     *set Confidence %+5
    
    *goto_next

Did the error tell you what line the problem was on?

If I had to guess, the issue (or at least an issue) is with the opposing pairs. You set leadership as a variable, but then set dominance and submission as the words you want opposing pair to be - but leadership is the variable. So when you later have “*set Dominance” the game doesn’t know what to do with that because dominance is not a variable, leadership is.

Instead in the setup, maybe do

*opposed_pair dominance
  submission

-edit: I only mentioned leadership: dominance/submission, but I imagine the same issue would apply with strength: agility/brute strength.

Firstly, it’s *stat_chart, not *create stat_chart.

Secondly, you need to put the opposed_pairs right after you put *stat_chart, with proper indentations. Preferably put it in choicescript_stat.txt, not in startup.txt.

2 Likes

I am still getting the same error. I have updated my code up top.

No. I copy-pasted the error message, so it did not tell me what line it was on.

Create the variables first, then put the *stat_chart part in.

You may find it useful to model your code after another game’s, such as Choice of the Dragon’s startup file.

http://www.choiceofgames.com/dragon/scenes/startup.txt

4 Likes

Nothing should precede the *create list but *title, *author, and *scene_list; in that exact order.

2 Likes

This code works (mostly) fine when I run this. However, I cut-and-pasted the *stat_chart section into the choicescript_stat.txt file, NOT the startup.txt file. Everything else, including the title, should be in the startup.txt file. What file is this code in? That’s as important as the content of your code.

Also, since your variables are defined in quotations, they will not run. Change:

*set "V" "woman"

to this:

*set V "woman"

And when you want to call those variables, you’ll do:

Ah, I see you are a young ${V}

Instead of the code below which will not run correctly:

Ah, I see you are a young {V}

Moreover, you’re also going to need to “create” V, W, X, Y… before you “set” them to something. Just like how you created Passion, Dominance, etc, you need to do the same with V, W, X, Y, Z.

1 Like

Ah. Thank you.

I’m still getting the same error, although I fixed it. I updaded my code up top.

*scene_list should not be indented. Put your scenes in order, indented, under *scene_list.

The first one one should be startup, where you declare your variables. Follow the model of Choice of the Dragon. I highly recommend that you carefully read all of the beginning links and pages, and carefully work through the code of Choice of the Dragon, ensuring that you understand what everything is doing. That will help you so much.

*title Choice of the Dragon
*author Dan Fabulich and Adam Strong-Morse

*scene_list
  startup
  lair
  queenpolitics
  clutchmate
  checkpoint
  heroes
  goblinhero
  warrequest
  worship
  mating
  evilwizard
  hibernation

*create name ""
*create brutality 50
*create cunning 50
*create disdain 50
*create gender "unknown"
1 Like

I fixed your entire code for you. I’d suggest you switch from using spaces to using tabs for your indentation.

STARTUP FILE

*title Choice of the Guardian
*author JONAH GREYE

*scene_list 
	origin
*create name "Unknown"

*create V "woman"
*create W "girl"
*create X "she"
*create Y "he"
*create Z "hers"
	
*create Passion 50
*create Dominance 50
*create Agility 50
*create Vigilance 50
*finish

SCENE origin

This is my first game, so it may seem choppy. I'm a pretty good storyteller because I imagine  everything my characters would do,so I hope that Choice of the Guardian is as good as I wanted it to be. This book is also set in a rather Medieval time period, just so you know.

*page_break I'm Sure It's Fine!

Long ago, before the time of The Curse and during the time of the Garden of Eden, back when the world was perfect, dragons roamed and ruled the Earth. There were four main kinds of dragons; the proud fire dragons with their flaming breath and bright, metallic, iron-hard scales. The earth dragons that spat scalding acid and had deadly stinging tails, not to mention a vastly  territorial nature. The wind dragons who glided on the winds, having no wings of their own, and able to fire bolts of lightning. And last, but not least in any way, the sea dragons with their immense size and strength, the biggest of all the dragon kinds, they preferred the water over flying, though the occasional flight was not out of the ordinary.
 
*line_break
    
When The Curse was inflicted apon Mankind,The dragons at first tried to continue living on the Earth, but they found that after three thousand years of trying to coexist, their race was dwindling. Mankind hunted them for sport, took over their homes, and stole their prey. Little by little, they began to realise that there was no longer a place for them among Mankind. Inherently magical creatures, the dragons tore a rift, a portal,  between an empty, safe world, and this one. Then, down to the last dragonette, they vanished through it.
 
*page_break

Well, all except four.
 
*page_break
A represenative from each tribe, the copper-colored fire, the pearl-scaled wind, the saphire-plated sea and the verdelite earth, each gave up their power to four worthy individuals, one from each corner of the world: modern-era Canada, Australia, Peru, and  Japan. Each of these people became the first Guardians, gifted with unbreakable bones, the power to control their respective elements, a specific set of abilities to match, and a fantastic healing  allowing them to live in the nature of five, sometimes six hundred years.
 
*line_break
    
But perhaps their greatest ability is to be able to transform into the dragons of old.
 
*page_break Cool

Now, one of the Guardians' lives has neared its end, and he has passed the dragon's power to you, a young . . .
*choice
	#Girl
		*set V "woman"
		*set W "girl"
		*set X "she"
		*set Y "her"
		*set Z "hers"
		*goto next
	#Boy
		*set V "man"
		*set W "boy"
		*set X "he"
		*set Y "him"
		*set Z "his"
		*goto next
*label next
I see.

So you, as a very young ${W} recieved the Dragon's Gift, and the ancient Guardian who gave it to you died as soon as the last rays of the sun faded from the sky. You don't remember him at all.

*page_break

What is your name, Guardian?
*input_text name
*goto teen_years

*label teen_years
You near the teen years, and your powers begin to manifest.

Now, let's find out what Gift you were given.

*page_break

If someone were to look for you, what would they most likely find you doing?
*fake_choice
	#Watching the flames in the hearth writhe and dance.
		*set Passion %+5
		*set Vigilance %+5
	#High in a tree, staring at the birds flying above me.
		*set Agility %+5
	#Working in my flower/vegetable garden.
		*set Agility %-5
		*set Passion %-5
	#Skipping rocks in the lake.
		*set Agility %+5
		*set Dominance %+1

*goto friends

*label friends
When working with friends to get something done, who gives the orders?
*fake_choice
	#Me. I can handle the resposibility of managing a team.
		*set Dominance %+5
		*set Vigilance %-5
	#Me and one other person. We work together to make sure everyone does their part.
		*set Dominance %+1
		*set Vigilance %-1
	#Not me. I'll let someone else do the ordering around, thanks.
		*set Dominance %-5
		*set Vigilance %+1
	#Ha! "Group project"? I always end up doing most of the work!
		*set Passion %+1
		*set Dominance %+3
		*set Vigilance %-5

CHOICESCRIPT_STATS

*stat_chart
   opposed_pair Passion
     Peacefulness
   opposed_pair Dominance
     Submission
   opposed_pair Agility
     Brute Strength
   opposed_pair Vigilance
     Confidence

I would also advice you run some of the tutorial projects in the IDE. They are very insightful.

3 Likes

Thank you so very much.

1 Like

You’re welcome

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the @moderators.

I am getting the error below. It does not tell me what line to fix.
“ReferenceError: stats is not defined”

This is my code:

*title Choice of the Guardian
*author Blazing Shadows
*scene_list
    originstory
    test
    reveal
    personality
    
*create Passion 50
*create Dominance 50
*create Agility 50
*create Vigilance 50
*create Loner 50
*create Booksmart 50

*create V "woman"
*create W "girl"
*create X “she”
*create Y “her”
*create Z “hers”
*stat_chart
   opposed_pair Passion
     Peacefulness
   opposed_pair Dominance
     Submission
   opposed_pair Agility
     Brute Strength
   opposed_pair Vigilance
     Confidence
   opposed_pair Loner
     Teammate
    opposed_pair Booksmart
     Streetsmart
     
    This is my first game, so it may seem choppy. I'm a pretty good storyteller because I imagine  everything my characters would do,so I hope that Choice of the Guardian is as good as I wanted it to be. This book is also set in a rather Medieval time period, just so you know.

*page_break I'm Sure It's Fine!
    
*label originstory

    Long ago, before the time of The Curse and during the time of the Garden of Eden, back when the world was perfect, dragons roamed and ruled the Earth. There were four main kinds of dragons; the proud fire dragons with their flaming breath and bright, metallic, iron-hard scales. The earth dragons that spat scalding acid and had deadly stinging tails, not to mention a vastly territorial nature. The wind dragons who glided on the winds, having no wings of their own, and able to fire bolts of lightning. And last, but not least in any way, the sea dragons with their immense size and strength, the biggest of all the dragon kinds, they preferred the water over flying, though the occasional flight was not out of the ordinary.
 
*line_break
    
    When The Curse was inflicted apon Mankind,The dragons at first tried to continue living on the Earth, but they found that after three thousand years of trying to coexist, their race was dwindling. Mankind hunted them for sport, took over their homes, and stole their prey. Little by little, they began to realise that there was no longer a place for them among Mankind. Inherently magical creatures, the dragons tore a rift, a portal,  between an empty, safe world, and this one. Then, down to the last dragonette, they vanished through it.
 
*page_break

Well, all except four.
 
*page_break

    A represenative from each tribe, the copper-colored fire, the pearl-scaled wind, the saphire-plated sea and the verdelite earth, each gave up their power to four worthy individuals, the sons and daughters of Shem and Japeth, sons of Noah, that spread to each corner of the world: modern-era Canada, Australia, Peru, and  Japan. Each of these people became the first Guardians, gifted with unbreakable bones, the power to control their respective elements, a specific set of abilities to match, and a fantastic healing  allowing them to live in the nature of five, sometimes six hundred years.
    
    But perhaps their greatest ability is to be able to transform into the dragons of old.
 
*page_break Cool

    Their fame was so great, it spread throughout the world in the form of a short and mysterious poem pondered over generations:

[i]Find drink in the island of deserts,[/i]

[i]Warmth in the blistering cold.[/i]

[i]The powers of earth where the cherry trees bloom,[/i]

[i]And storms in the Land of Gold.[/i]

*page_break

    Now one of the Guardians' lives has neared its end, and he has passed the dragon's power to you, a young . . .
*choice
    #Girl
    *goto_isee
    #Boy
     *set V "man"
     *set W "boy"
     *set X “he”
     *set Y “him”
     *set Z “his”
    *goto_isee

*label isee

I see.

    So you, as a very young ${W}, recieved the Dragon's Gift. The ancient Guardian who gave it to you died as soon as the last rays of the sun faded from the sky. You don't remember him at all.

*page_break

What is your name, Guardian?
    *imput_text name
    *goto_manifestation

*label manifestation

    You near the teen years, and your powers begin to manifest.

    Now, let's find out what Gift you were given.

*page_break

*label test

    If someone were to look for you, what would they most likely find you doing?
*choice
    #Watching the flames in the hearth writhe and dance.
     *set Passion %+5
    *goto_Q2
    #High in a tree, staring at the birds flying above me.
     *set Passion %-5
    *goto_Q2
    #Working in my flower/vegetable garden.
     *set Agility %-5
    *goto_Q2
    #Skipping rocks in the lake.
     *set Agility %+5
    *goto_Q2

*label Q2

    When working with friends to get something done, who gives the orders?
*choice
    #Me. I can handle the resposibility of managing a team.
     *set Agility %-5
     *set Booksmart %+10
    *goto_Q3
    #Me and one other person. We work together to make sure everyone does their part.
     *set Passion %+5
     *set Loner %-5
     *set Booksmart %+5
    *goto_Q3
    #Not me. I'll let someone else do the ordering around, thanks.
     *set Passion %-5
     *set Vigilance %+1
    *goto_Q3
    #Ha! "Group project"? I always end up doing most of the work!
     *set Loner %+5
     *set Agility %+5
     *set Booksmart %+10
    *goto_Q3

*label Q3

    I can respect that.

    Tell me, ${name}, if you could change one thing about your body, what would it be?
    #My body's shape. (It doesn't have to just be your figure, either. It could be that you're like me and just think that your knees are too knobbly.) 
     *if boy
        *set Agility %-5
     *if girl
        *set Agility %+5
     *set Vigilance %+1
    *goto_Q4
    #I want big, feathery wings sprouting out of my shoulder-blades!
     *set Passion %-5
    *goto_Q4
    #My mind. I'm too scatterbrained.
     *set Passion %+5
     *set Dominance %+5
    *goto_Q4
    #Nothing. I like me.
     *set Vigilance %-5
     *set Passion %-5
    *goto_Q4

*label Q4

    I am about to tell you a hypothetical situation.

    You are walking down the hall of wherever you go to school, and you see that a fight seems to be brewing between a bully and their victim, who has had enough tormenting and had finally stood up for themselves. It looks like things are about to get nasty; what do you do?
    #Shoulder between them, putting on my meanest scowl and broadening my shoulders to look bigger and tougher. I can take that stupid lump of spam on a sick day.
     *set Agility %-5
     *set Vigilance %-10
     *set Dominance %+10
    *goto_Q5
    #Size up the oppressor and determine if I can handle them. Then make my move.
     *set Vigilance %+10
     *set Booksmart %-10
     *set Passion %+5
    *goto_Q5
    #Settle this with smoothe words and quick thinking, pointing out all the teachers nearby who may see what happens, then say that it's not worth the risk of getting caught.
     *set Agility %+5
     *set Booksmart %-5
     *set Loner %+5
    *goto_Q5
    #I have some Jolly Ranchers in my bag. I walk up and tell them to hold out their hands. While I am placing the candy into the bully's hands, I subtly motion for the victim to get out of there.
     *set Booksmart %+5
     *set Passion %-5
    *goto_Q5

*label Q5
    
    Which of these quotes speaks to you most?
*choice
    #"Follow your heart, but take your brain with you." - Anonymous
     *set Booksmart %+5
     *set Vigilance %+5
     *set Agility %+5
    *goto_Q6
    #"No man can win every battle, but no man should fall without a struggle." - Peter Parker
     *set Agility %-5
     *set Booksmart %-5
    *goto_Q6
    #"Just because you're the best there is at what you do doesn't mean you have to do it." - Wolverine
     *set Passion %-5
     *set Loner %+5
    *goto_Q6
    #"Fairy tales are more than true: not because they tell us that dragons exist, but because they tell us that dragons can be beaten." - Neil Gaiman
     *set Booksmart %+5
     *set Passion %+5
    *goto_Q6

*label Q6
    
    Given the opportunity to travel, where would you go?
*choice
    #Alaska. I want to see the beautiful mountains and the Lights dancing in the sky.
     *set Dominance %-10
     *set Agility %+5
     *set Booksmart %+1
    *goto_reveal
    #Australia. I admire the feirce nature of every plant and animal that lives there.
     *set Passion %+5
     *set Vigilance %+5
    *goto_reveal
    #Nowhere. I like home, and am perfectly content to stay right here.
     *set Agility %-5
     *set Loner %+3
    *goto_reveal
    #I want to travel the world. I don't have a specific place I want to see.
     *set Passion %-5
     *set Booksmart %-5
    *goto_reveal

*label reveal
    *if Passion >=75
      You are the Fire Guardian, the "warmth in the blistering cold" from the riddle; you live in Canada. Your eyes glow, in both dragon and human form, like two dying flashlights, due to the power inside you. You can bend fire making it fly from your palms or from the soles of your feet. Flames cannot harm you and you can breathe oxygen-deprived air as easily as you are breathing now. Smoke does not sting your eyes or bother your lungs. You do not tire easily, for the flame within your marrow can fuel you for days, like a constant internal supply of coffee. You could live on an active volcano.
    
    In addition to all that, you can transform into the great, copper dragon that granted the first Fire Guardian their power. In this form, your metallic scales are nigh impenetrable, you have flowing copper fur along your spine and a thin tuft of fur at the end of your tail and you can breathe fire. Your feathery wings span two-and-a-half football fields. Your tapering, spiraling horns are as thick as a man's arm. You are as tall at the shoulder as two school busses. Your chest spans the breadth of a garbage truck, the skinniest part of your neck is like the back of a fat bull, and your back is like an elephant's. Your four legs are as the trunks of jungle trees, your talons twenty times the size of an eagle's. You are truly formdible, and those who lay eyes apon you tremble and quake.
    *else
      goto_test

*goto_personality

    *if Passion <=25
      You are the Wind Guardian, the "strorms in the Land of Gold" from the riddle; you live in Argentina. Your eyes glow, in dragon and human form, like two dying flashlights, due to the power inside you. You can push and pull the air around you with hand and foot, can leap great distances, run extremely fast without being out of breath. You can summon storms, from a light rain to a typhoon. You can bid lightning to fall out of a clear blue sky. You can even steal the breath from another's throat, suffocating them to death. Thank God you are of a peaceful nature, and would rather stop a fight than take a life.

      Your dragon form resembles that of an Asian dragon, without the tusks and strange glowing orb. Your pearlecent scales imperfectly reflect the storm clouds as you glide through the sky. You can fire bolts of lightning from your mouth. At its thickest, your long, serpentine body is as thick as the trunk of an ancient tree, and tapers down to a tufted tail. The fur along your spine is long and milk-white. Your talons are so sharp, they sing through the air as you fly. None who meet you will ever forget it.
    *else
      goto_test

*goto_personality

    *if Agility >=75
      You are the Water Guardian, the "drink in the island of deserts" from the riddle; you live in Australia. Your eyes glow, in both human and dragon form, like two dying flashlights, due to the power inside you. You can bend the water from streams, oceans, and rivers, in plants . . . and in living creatures. You can turn water into ice, snow, fog, or steam. You can breathe underwater and withstand water pressure that would kill a normal human being. You have mild night vision, and can see clearly underwater.
    
      Your dragon form is the biggest and strongest of all. In your dragon form, your scales are irridecent blue, intricately detaled with all the hues the ocean can provide. A pale blue crest graces your spine. Your wings, though not made for flying extremely long distances, are perfect, however, for whisking through the sea. You spray scalding, steaming water from your mouth. Your body, nose to tail-tip, is fully three hundred and fifty feet long. Your wingspan is nearly one-and-a-half times that. Your four legs are as thick at the ankles as a tree, and your enourmous, serrated claws are ideal for tearing the meat off whale carcasses. Bioluminecent stripes accent your body, giving you an eerie glow at night. You are the thing that sailors tell tales about, the dread sea monster on the ancient treasure maps left by pirates.
    *else
      goto_test

*goto_personality
    
    *if Agility <=25
      You are the Earth Guardian, the "power of earth where the cherry trees bloom" from the riddle; you live in Japan. Your eyes glow, in both human and dragon form, like two dying flashlights, due to the power inside you. You are sturdy as a rock, and are not easily knocked over in a fight. You control the earth beneath your feet, can make it bend to your will, which requires strength and a will of iron. You love being outside with the plants and trees, and spend most your time barefoot. You can see in the darkest of nights as if it were day, and have infrared vision that requires some focus to use.
    
    Your dragon form is like that of a wyvern. You spit clear, deadly acid that can melt through nearly anything organic. Only you can touch it safely. Your tail ends in a vicious stinger with a venom potent enough to kill three bull elephants and sharp enough and strong enough to pierce a cast-iron pan. Your scales glitter metallically in the sun, and are delicately accented with all the greens of the Amazon rainforest. Your bat-like wings span a football field, and your two legs are thick as smaller-sized tree trunks. Your serrated talons are twelve times the size of an eagle's. You are most formidible in a fight, being the smallest of all the dragons, you are able to manuever and strike quickly. Those who've angered you are lucky to have lived to tell the tale.
    *else
      goto_test

I’m looking through the code, one sec. (side note, use more page breaks or line breaks so you don’t have walls of text.

You have stat_chart in your start up file this should be in choicescript_stats file…

Just put the italics creator at the very beginning and at the very end. You don’t need the others.

it should be *input_text name

see if that fixes it