FANDOM


As a ChoiceScript programmer, you will definately encounter errors, sooner or later, while testing your game. If you encounter errors, a popup box will appear, telling you what line the errors occurs on, and as well what the error is. Below, you will find solutions for some of the errors you may encounter. (N.B. Most of these errors only appear correctly for Mozilla Firefox.)

Browser and OS related errors

{}

The error simply named "{}" occurs only while using Google Chrome to play your game (note: your game must be uploaded on a website for the game to work on Google Chrome!). It only occurs sometimes; it is recommended that you try obtaining the same error with another browser, which will specify the error properly.

Invalid argument type.property

This error will only occur in Internet Explorer, and it will only occur with the *input_number function; try using another browser (this can't be fixed so that it works in Internet Explorer from your code, but it works in any other browser).

Invalid Character

The invalid character error is believe to come from Windows 7 (and possibly Vista) "blocking" the javascript files from functioning. Redownload the zip file containing ChoiceScript, right click on it, open Properties and at the button of the properties window there should be a button that says Unblock. Click it, then select okay. Finally, extract the zip file as normal. It may also be possible to individually unblock every file in the zip file after it has already been unzipped, but this is not recommended.

*choice related errors

Expected option starting with #

If you encounter this error, it means you have forgotten a "#" sign at the beginning of a choice. Here's what will cause this error:

What do you want to do?

*choice

    #Go to the park.

        You go to the park.

        *finish

    Stay home.

        You decide to stay home.

        *finish

As you can see, the choice "Stay home." doesn't have a "#" in front of it; adding one will fix the error.

Expected choice body

This error occurs if you've written down a *choice command and there are no choices; for example, doing this:

Hello!

*choice

*finish

will get you this error; there are no "#" choices under *choice.

Invalid intent, expected at least one 'choice'

This error happens when the options under a *choice are not properly indented, and are on the same level as the *choice command. This is solved by adding a space/tab before each of the *choice options.

Error:

*choice
#Option 1
 Text
 *goto label

Solution:

*choice
 #Option 1
  Text
  *goto label


No selectable options

This error occurs when a *choice loops back to the beginning and each choice has a *disable_reuse or *hide_reuse condition that prevents the player from having any selectable options available once they go through every choice once. Make sure to leave an option that is always selectable for the player to escape the loop.

Error:

*label choice

*choice

   *disable_reuse #Option 1

       *goto choice
 
   *disable_reuse #Option 2

       *goto choice

Solution:

*label choice

*choice

   *disable_reuse #Option 1

       *goto choice

   *disable_reuse #Option 2

       *goto choice

   #Option 3

       *goto next_part

*label next_part

In the example above, we used *disable_reuse, but the error can occur, as stated above, with *hide_reuse as well.

*selectable_if is another culprit for this error, since the player might not meet any of the requirements:

*choice

   *selectable_if (strength > 30) #Lift some weights.

       You pump iron to stay in shape.

       *finish

    *selectable_if (partner_name = "Jill") #Go jogging with Jill.

       You go jogging with Jill to stay in shape.

       *finish

    *selectable_if (lazy) #Nuke some popcorn and watch TV.

       You do your impersonation of a Couch Potato.

       *finish

In this example, if the player's strength is 20, their partner_name is "John" and the lazy variable is false, the player is left with no options to select. This can be fixed by simply adding an option, as above, that has no requirements, or removing a *selectable_if condition from one of the options.

Variable related errors

Non-existent variable var

If you're encountering this error, it means you've tried to use a variable that doesn't exist (i.e. is not defined in mygame.js or created with *temp). You must first define the variable (info on defining variables in the mygame.js article).

Trying to use a variable means doing these:

*set var 10

*set var + 10

*if var = 10

*delete var

*set var round(2.5)

This error also occurs if the variables you define in mygame.js have uppercase letters or spaces and then you try using them; never use uppercase letters or spaces for variable names in mygame.js.

Variable exists but has no value

You've created a variable using the *create or the *temp command (don't use the *create; use mygame.js for creating variables!). Here's what would get this error:

*temp var

*if (var > 10)

    var is higher than 10!

    *finish

As you can see, var has no value at all, and the game tries to check if var is higher than 10, which is not possible; this is what would fix it:

*temp var

*set var 20

*if (var > 10)

    var is higher than 10!

    *finish

*label related errors

Bad label

This error occurs if you've used *goto to go to a *label that does not exist; for example, doing this would make this error happen:

*temp var

*set var 100

*if var > 99

    *goto NextPage

*label Next_Page

As you can see, the *goto should take you to the label named "NextPage"; the only problem would be there is no label named as such; as you can see, the label is named as "Next_Page", which is entirely different.

Uncaught error: label already defined on another line

You'll encounter this error if you make two labels the same in the same scene ; if you do this:

*label NextPage

*label NextPage

in the same scene, you will encounter that error. Just remove one of the labels or change the name of one of them.

Misc. errors

Invalid *return; *gosub has not been called yet

This error happens if you use the *return feature before *gosub has even been hit; here's how you encounter it:

*temp var

*set var 100

*if var > 99

    *return

As you can see, there's only a *return , and no *gosub ; *return is used strictly in relation with *gosub (read move about them in the *gosub article).

Invalid expression, couldn't extract another token

If this error occurs, it means you've used characters that don't exist in the English language. Note that most programming languages require you to only use alphanumeric characters that exist in the English language (which means if you use the "alpha" character from the greek alphabet, you'll encounter this error).


Non-existent Command

If you try using a command that doesn't exist, you'll encounter this error (for a full list of all commands, check the index). For example, writing this line:

*stat

Will give you an error, non-existent command "stat", because "stat" isn't a command.


Couldn't load scene file

This error happens when Choicescript cannot find the scene referenced in the code. This is usually due to a *goto_scene, *goto_random_scene or *gosub_scene command.

  • Make sure that your scene .txt file is in your game's scene folder (..\web\mygame\scenes)
  • Make sure that the scene name is spelled exactly the same in the scene folder and in your code. The names must be identical.

Note that:

*goto_scene chapter1.txt

will result in the same error. In the code, you must ommit the .txt at the end of the scene name:

*goto_scene chapter1

Fixing most of the mygame.js errors

Note: As of 2013, the things that used to be done in the mygame.js file are now done in the startup.txt. Authors that don't modify mygame.js won't encounter these errors.

Here you will find how to fix most mygame.js errors; below you will see all the conditions you must accomplish; each followed with a code sample that is wrong purposely, so you see what you should NOT do in mygame.js).

The first name in either list should never be preceded by a comma:

stats = {

    ,var: 50 (var should NOT be preceded by a comma because it's the first stat in the list)

    ,var2: 50

};

The last name in either list should never be followed by a comma:

stats = {

    var: 50

    ,var2: 50, (var2 should NOT be followed by a comma because it's the last stat in the list)

};

Don't use ANY UPPER CASE letters in scene or variable names; only use LOWER CASE letters:

stats = {

    Var: 50 (Var shouldn't have an upper case "V" letter; instead, it should be a lowercase "v")

    ,var2: 50

};

Don't include the ".txt" extension in the scene names list (in the sceneNavigation at the top):

nav = new SceneNavigator([

    "startup.txt" (startup.txt should NOT have the ".txt" extension)

    ,"ending"

    ,"death"

    

]);

Don't use any spaces in scene or variable names (although underscore_is_fine):

stats = {

    v a r: 50 (v a r shouldn't have spaces in it; instead, it should be var or v_a_r)

    ,v_a_r_2: 50 (this works just fine, because underscores are allowed)

};

Every variable name must be followed by a colon, a single space, then a default value:

stats = {

    var: 50 

    ,var2: 0 (this however is followed by a : , a single space and then a default value)

    ,var3: "" (this is also right as it has a default value, even if they're only two quotes)

    ,var4: false (this is also right as it has a default value, even if it's false)

};

Don't use any extra spaces after each scenes or variable entry, on the same line:

nav = new SceneNavigator([

    "startup"         (note that there are a lot of spaces after "startup"; they should be avoided)

    ,"ending"

    ,"death"

]);

Above all, don't edit anything else other than the actual list of scenes or variables; do not edit these lines:

nav = new SceneNavigator([

]);

stats = {

};

debugStats = {

};

Note: You are allowed to edit the last two lines mentioned above if you replace them and every stat between them with a single line, that is the same as this:

debugStats = stats;


Other errors you've encountered that are not mentioned here

Let us know in the comments! Tell us which errors you've encountered, and under which circumstances. We will add it to the list along with a solution!

Back to the index.

Related Articles:

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.