TypeError: window.onerror is not a function

Oh, okay. Thanks, @poison_mara

Sam – in the example you gave, it would be best to use else, not elseif. The else will capture all non-red options.

Elseif comes into play when you’re juggling more than two options; and its usefulness is most obvious with numbered stats, not Booleans.

*if nose_inches > 7
  Epic!  You have the longest nose in nasal history.
  *goto next
*elseif nose_inches > 5
  You occasionally impale people on your nose without meaning to.
  *goto next
*elseif nose_inches > 3
  People comment on your unnaturally long nose.
  *goto next
*else
  There is nothing particularly notable about your nose length.
  *goto next
*label next

Using this code, someone with a 6 inch nose will see the line about impalement and none of the others. To accomplish that without elseif, you’d need to have “*if (nose_inches < 8) and (nose_inches > 5)”, etc. Elseif automatically assumes that any earlier *if or *elseif conditions don’t apply; so when you want different text for different ranges of a numbered stat, it can be a lot easier to use elseif.

And I also remember when I learned that *if red = false can be written *if not(red). It was a happy day.

@Havenstone
Every time I use *else, it tells me that I need to have it end in *goto or *finish, even though it does T.T

Good point. I just edited the code in my last post, as what I’d had before wouldn’t have worked. In an if/elseif/else cascade, you need to end each line in a *goto.

@Havenstone
It sucks, cause I usually just use them for customized sentences or customized stat effects. For that, would I use *elseif? like


*if mythril
     *set health -1
*elseif
     *set health -2

The only time you have to use *else is in customized choices where all the choices depend on some stat or another. I don’t think Quicktest will pass otherwise. E.g. I’m pretty sure I can’t have just

*choice
  *if charisma > 1
    #Use my overwhelming charm.
      *goto next
  *if charisma = 1
    #Use my moderate charm.
      *goto next
  *if charisma < 1
    #Use another trait.
      *goto next

– Quicktest will want me to substitute “else” for the “if charisma < 1” (for reasons explained here: see “Fake Bugs in Quicktest”).

But even in a case like that, you don’t need to use *elseif. Quicktest will want the series to end in an *else, but the other choices can all be *if. And for customizing sentences or stat effects, you never need to use *else or *elseif. You can get by just fine with

*if mythril
     *set health -1
*if not(mythril)
     *set health -2

or

*if mythril
     *set health -1
     *goto next
*set health -2
*label next

or

*if mythril
     *set health -1
*if iron
     *set health -2
*if cheese
     *set health -8

(One thing that won’t work is the example you gave. If you say “elseif” and don’t put some condition, I’m pretty sure ChoiceScript does the equivalent of saying, “else if… what?” You’d just use *else):

*if mythril
     *set health -1
     *goto next
*else
     *set health -2
     *goto next

It doesn’t really suck that much. You can get by just fine in customizing text without ever using them. Most of the customization in my game uses *ifs.

In situations where you’re working with ranges of numbered stats, as I mentioned above, you may find that using *elseif/*else and pasting “*goto label_name” at the end of each line is a lot less hassle than using *ifs – and less likely to lead to a screwup where you accidentally leave people getting no text at all. (The main point of elseif/else is to make sure that people will always get one of the options on offer).

Edit: just tweaked a couple of the above bits of code, think they all say what I meant them to now. :slight_smile:

@Havenstone
I always use


*if mythril
     *set health -1
     *goto next
*set health -2
*label next

But it gets really tedious in fight scenes. I think I’ll switch to *if not(mythril)

The if not works really fine, I use it all time and *ifs . Elseif and else options, only when each option goes to a different label or scene, if they go same label i use ifs or if not you could rid useless code using that

Yeah, I have a ton of tedious labels like the one in my previous post xD now I’ll go back and replace them with *if not

So, this chunk of code seems to be the culprit. I still can’t find how to fix it though. Do any of you guys see anything wrong with this?


After a moment, you decide to
*choice
	*selectable_if ((transformations_eagle) and (mana > 2)) #Discover the answer another way, with ${boggart}'s help
		*set relationship %+ 10
		*set stealth %+ 10
		*set eagle true
		*set charisma %+ 10
		A smile spreading across your face, you say kindly,
		
		"Dear troll, before I tell you the answer to the riddle, would you like to see a birdie?"
		
		His eyes lighting up, the monster giggles ecstatically, bobbing his head and saying,
		
		"Yes, yes, please!"
		
		Taking the hint, your boggart quickly changes into a majestic eagle, chirping helpfully. His jaw dropping, the monster squeals,
		
		"He's a PRETTY birdie!"
		
		"Would you like to pet him?"
		
		At this, your companion gives you a look of annoyance, clicking his beak distastefully, but you give him a meaningful look, jerking your head towards the troll. Rolling his eyes, ${boggart} alights onto the troll's shoulder.
		
		Elated, the troll begins to pet your boggart gently, cooing things like 'I've never seen an owl!' and 'He's got such strange fur...' Smiling despite yourself, you let him go on for a moment longer, before politely asking,
		
		"So, would you like to hear the answer to the riddle?"
		
		Looking at you absent-mindedly, the goofy grin still on his brutish face, the troll responds wist-fully,
		
		"What? What's it talking about...? Oh! The riddle. Yeah."
		
		Checking the words written on his palm again, the monster unknowingly gives ${boggart} an opportunity to read the answer. Looking up at you, your companion relates the answer to you in a series of chirps, inciting more adoration from the troll. Giving a small nod,
		*goto answer

	#Try to figure out the answer to the riddle yourself
		You believe that the answer to the riddle is: (type the answer in all lower case letters)
		*input_text riddle
		*if riddle "nothing"
			*set cunning %+ 10
			You 
			*label answer
			reply confidently,
			
			"The answer to the riddle, of course, is 'nothing.'"
			
			His knobbly face lighting up, the troll claps excitedly, laughing,
			
			"You're right! Oh, this is so much fun! Uh...too bad Callidy said I gets to eat you whole even if you get the riddle right. Sorry, friend."
			
			With surprising speed, the monster kicks the fire, scattering burning branches and embers, but his words prepared you for his attack. Diving deftly to the side, you 
			*goto defeat
		*set cunning %- 10
		*set health -2
		You reply hesitantly,
			
		"The answer to the riddle is...'${riddle}.'
			
		His ugly smile falling, the troll responds,
			
		"Aw...that's no fun! Now I eats it whole!"
			
		With surprising speed, the monster kicks the fire, scattering burning branches and embers into your face. Yelping in pain, you stagger back, swinging your staff wildly to ward him off, but to no avail. 
			
		Dodging your weapon, the troll swings his fist into your torso, sending you careening through the air before skidding across the tunnel floor.
		*if health < 1
			*goto_scene death2
		Groaning in pain, you stagger to your feet as the monster swiftly approaches, his gnarled hands outstretched to wrap around your throat. Reacting quickly,
		*goto defeat

*if riddle “nothing”

You missed out the = sign :slight_smile:

@CJW
You’re a genius :smiley: yay! It worked.

Good find - should hopefully make it much easier for @dfabulich to correct the error message code currently resulting in the ‘typeerror’.

I still can’t reproduce the “window.onerror is not a function” part of this. Randomtest reports a reasonable error when I put in a line like *if leadership "nothing" in startup.txt on the latest ChoiceScript. I’ve tested it in Firefox on OS X and Windows 8.

I’m using Windows XP. Could that be why that error is popping up?

Well, I got that errors and I never use a PC at all , so I don’t think is a windows problem

@dfabulich
It’s quicktest, not randomtest.

@Samuel_H_Young
Using your above code it also happens for me on Win7.

Aha!

Win7 Firefox? I still don’t repro it. :frowning:

@dfabulich
You do need to copy his code to a T, just slapping a random *if something “somethingelse” anywhere doesn’t work, that throws the standard expected operator error. It’s some combination of circumstances that are causing it, not just that line.

Here’s sam’s code with some added variable definitions that I used to get the error:


*temp transformations_eagle true
*temp mana 3
*temp relationship 30
*temp eagle true
*temp stealth 30
*temp charisma 30
*temp cunning 30
*temp health 20
*temp boggart "lol"
*temp riddle ""

After a moment, you decide to
*choice
	*selectable_if ((transformations_eagle) and (mana > 2)) #Discover the answer another way, with ${boggart}'s help
		*set relationship %+ 10
		*set stealth %+ 10
		*set eagle true
		*set charisma %+ 10
		A smile spreading across your face, you say kindly,
		
		"Dear troll, before I tell you the answer to the riddle, would you like to see a birdie?"
		
		His eyes lighting up, the monster giggles ecstatically, bobbing his head and saying,
		
		"Yes, yes, please!"
		
		Taking the hint, your boggart quickly changes into a majestic eagle, chirping helpfully. His jaw dropping, the monster squeals,
		
		"He's a PRETTY birdie!"
		
		"Would you like to pet him?"
		
		At this, your companion gives you a look of annoyance, clicking his beak distastefully, but you give him a meaningful look, jerking your head towards the troll. Rolling his eyes, ${boggart} alights onto the troll's shoulder.
		
		Elated, the troll begins to pet your boggart gently, cooing things like 'I've never seen an owl!' and 'He's got such strange fur...' Smiling despite yourself, you let him go on for a moment longer, before politely asking,
		
		"So, would you like to hear the answer to the riddle?"
		
		Looking at you absent-mindedly, the goofy grin still on his brutish face, the troll responds wist-fully,
		
		"What? What's it talking about...? Oh! The riddle. Yeah."
		
		Checking the words written on his palm again, the monster unknowingly gives ${boggart} an opportunity to read the answer. Looking up at you, your companion relates the answer to you in a series of chirps, inciting more adoration from the troll. Giving a small nod,
		*goto answer

	#Try to figure out the answer to the riddle yourself
		You believe that the answer to the riddle is: (type the answer in all lower case letters)
		*input_text riddle
		*if riddle "nothing"
			*set cunning %+ 10
			You 
			*label answer
			reply confidently,
			
			"The answer to the riddle, of course, is 'nothing.'"
			
			His knobbly face lighting up, the troll claps excitedly, laughing,
			
			"You're right! Oh, this is so much fun! Uh...too bad Callidy said I gets to eat you whole even if you get the riddle right. Sorry, friend."
			
			With surprising speed, the monster kicks the fire, scattering burning branches and embers, but his words prepared you for his attack. Diving deftly to the side, you 
			*goto defeat
		*set cunning %- 10
		*set health -2
		You reply hesitantly,
			
		"The answer to the riddle is...'${riddle}.'
			
		His ugly smile falling, the troll responds,
			
		"Aw...that's no fun! Now I eats it whole!"
			
		With surprising speed, the monster kicks the fire, scattering burning branches and embers into your face. Yelping in pain, you stagger back, swinging your staff wildly to ward him off, but to no avail. 
			
		Dodging your weapon, the troll swings his fist into your torso, sending you careening through the air before skidding across the tunnel floor.
		*if health < 1
			*goto_scene death2
		Groaning in pain, you stagger to your feet as the monster swiftly approaches, his gnarled hands outstretched to wrap around your throat. Reacting quickly,
		*goto defeat
*label defeat

I am actually using chrome/webkit when I get this, but I can only assume Sam is using Firefox.

EDIT: Removing the ‘*input_text riddle’ line makes it throw the standard error, so is it something to do with that?

EDIT2: So for some reason after the *input_text line it tries to throw the error as an alert via the window.onerror method (which is null as it’s never defined??), whereas if you don’t include the *input_text line it logs it like it should.