Script Error Help


#1

My code is as follows:
*choice
#Approach the castle! Onward! Why wait and make this longer?
*choice Time to officially start! You approach the gates. The gate is absolutely huge. How do you intend to open it?
#KILL IT WITH FIRE! Fire always solves your problems.
*finish
#Introduce the gate to Jack Frost. Freeze it, then kick it open!
*finish
#Look around the area around in the gates. There might be something good.
*choice You found a random chest with a sword in it! Who leaves dangerous weapons where people are? They might get hurt. Anyway, we’ve got to move on.
#Yeah, let’s.
*goto Gate
#Nah… I hate this game.
*goto_scene death
Why exactly do I get “script error”? I’m quite new here and at coding in Choicescript. Any help would be appreciated.


#2

Except with the proper indentations. For some reason whenever I post, It takes out the spaces.


#3

Something like this? In particular, note that you should not (usually) have anything else on a *choice line.

*choice
#Approach the castle! Onward! Why wait and make this longer?
----Time to officially start! You approach the gates. The gate is absolutely huge. How do you intend to open it?
----*choice
------#KILL IT WITH FIRE!
--------Fire always solves your problems.
--------*finish
------#Introduce the gate to Jack Frost.
--------Freeze it, then kick it open!
--------*finish
------#Look around the area around in the gates. There might be something good.
--------You found a random chest with a sword in it! Who leaves dangerous weapons where people are? They might get hurt. Anyway, we’ve got to move on.
--------*choice
----------#Yeah, let’s.
------------*goto Gate
----------#Nah… I hate this game.
------------*goto_scene death

If you use Internet Explorer for testing it will give you accurate error messages, and always use a text editor capable of showing you the correct line numbers (something like Textpad or Notepad++), then you’ll know precisely where the error is occurring.


#4

In these forums use < code> before and </ code> after your choicescript code, and it will keep formatting (I added an extra space before code just to display it).


#5

@JimD Yea, but it appears that that < code> is slightly broken. It’ll maintain the first space, and even maintain all the spaces for a half hour, but after that half hour ends (the same amount of time you have to edit a post after posting it), it’ll erase all but the first space in each line marked as < code>. Example:
This line has no spaces. This line has one space. This line has two spaces.
For the moment, it’s probably best to stick with - representing spaces.

@LeBacon As Vendetta said, using Internet Explorer, and posting the error you get from IE, will help in figuring out your problem.


#6

Using IE is slightly against my religion, but I tried it. It comes up as the example game, not the game I made. When opened in Firefox, it opens correctly. What is going on, exactly? Google is absolutely no help for once in my life :open_mouth:


#7

I know precisely what you mean–I installed IE again purely to use for testing purposes, but now that’s open all the time I do tend to use it for some browsing . . . (eek!). It’s not quite as bad as it used to be.

I have IE opening my game as default “Homepage” for testing. You do this through Tools–>Internet Options (in this version at least) by pointing to the exact file. Mine looks something like this (replace ‘Vendetta1’ with ‘mygame’ if you never changed it to your game name):

…/ChoiceScript/dfabulich-choicescript-9d41d23/web/Vendetta1/index.html


#8

I tried it, and it comes up as the default Choicescript index. I used it and changed it up to meet my specifications, so it shouldn’t show it. When I opened it in Firefox, it came up regularly. Would this work?
*label Gate
*choice
#Approach the castle! Onward! Why wait and make this longer?
----*choice
------Time to officially start! You approach the gates. The gate is absolutely huge. How do you intend to open it?
------#KILL IT WITH FIRE! Fire always solves your problems.
--------*finish
--------#Introduce the gate to Jack Frost. Freeze it, then kick it open!
--------*finish
#Look around the area around in the gates. There might be something good.
----*choice
------You found a random chest with a sword in it! Who leaves this kind of stuff just sitting around? Somebody might get hurt!
------#Yeah, let’s.
--------*goto Gate
------#Nah… I hate this game.
--------*goto_scene death
Is this acceptable? I get the same old “Script error.”


#9

I’ll italic the few bits you had slightly wrong: don’t use upper case letters in any *label (or variable) names, and the text result to a particular option always comes before the next *choice. Your indentation on the “#Introduce the gate to…” line was also slightly out.

*label gate
*choice
#Approach the castle! Onward! Why wait and make this longer?
----Time to officially start! You approach the gates. The gate is absolutely huge. How do you intend to open it?
----*choice
------#KILL IT WITH FIRE! Fire always solves your problems.
--------*finish
------#Introduce the gate to Jack Frost. Freeze it, then kick it open!
--------*finish
#Look around the area around in the gates. There might be something good.
----You found a random chest with a sword in it! Who leaves this kind of stuff just sitting around? Somebody might get hurt!
----*choice
------#Yeah, let’s.
--------*goto gate
------#Nah… I hate this game.
--------*goto_scene death

Not sure why you’re still getting the IE problem, other than to say that logic suggests it’s pointing to the wrong index.html . . . It depends how you’ve set up your game files, whether you copied the entire /web folder at the start (to preserve the originals) or simply started editing those original ones.


#10

Just a design note:

–*hide_reuse #Look around the area around in the gates. There might be something good.

On that line I’ve added the *hide_reuse command. This means that once the “look around” choice has actually been used by the player, he /she won’t see that option again. You would use *hide_resuse in this instance because under there you have “*goto gate” option. However, the player will now see only the initial “#Approach the castle!” option once they have already looked around the gates.

It’s not essential–you can leave them able to go in a circle if you want-- but since somewhere in there you have them finding something in the chest (e.g. *set goldcoins +100) you don’t really want them to search the chest over and over again, gaining 100 more gold each time… *hide_reuse simply prevents them seeing the chest again after the first time.


#11

Thanks a lot. As you can tell, I’m quite the noob right now. How do I change the “My First Choicescript Game” heading? Is that the site opening it, or is there something I can change that I haven’t found?


#12

Open the index.html file with your text editor. The bits you want to change are easy enough to find in there; just be careful not to change anything else before saving.

Change the page Title near the top, the gameTitle about halfway down, and (if you like) the name of the showStats button a little bit past that, near the end.

As for being a noob, that was me a little over two months ago–and I’m hardly a quick learner when it comes to this sort of stuff . . . If I can do it, anyone can. :wink:


#13

Finally found it. It’s embedded pretty deep in the index file. I’m about like you- but with probably less programming experience. When I first played CoD on my iPod, I was surprised how simple it was. I looked into it, and here I am.


#14

Hehe. My own programming ‘experience’ is limited to working with programmers on something I’ve designed and trying to make sense of their explanations for how something actually works behind the scenes (most of which just goes straight over my head, of course). I suppose I might have picked up some basic stuff over the years, but mostly I just think ChoiceScript itself is very intuitive, with a simplified logic even I can (slowly but surely) grasp. But a programmer I most definitely am not–pretty much the opposite, in fact! That’s the beauty of this system, IMO.


#15

Does the *choice after *label [name] need an indent? I’m getting a script error.


#16

No it doesn’t. If you look at the error message, it will say “indent was 2, expected 0.” (or something similar). This means you have an indent when you shouldn’t.


#17

No, the *choice command under a particular section should never be indented more than the line immediately preceding it (but all of the actual options under that *choice should be indented farther, as in the example above).

If you’re having no luck solving it, post the actual error message here.

Edit: one thing to watch out for though, are indents after what you have on that line, which can sometimes occur when you’re not careful enough in copy-paste-editing sections of code to reuse. Everything will look perfectly fine visually (unless you turn on the appropriate setting, which in Textpad is View–>Visible Spaces, which then shows spaces / tabs before and after your text . . . no idea if Notepad++ has a similar feature?), but ChoiceScript seems to treat such indents as being on the next line, so can still result in the error andy mentions above even when everything looks perfectly fine at a glance.


#18

Exact error: Script Error.
No there wasn’t anything else. I did *label and when I tried to *goto it, I get a script error.
Does this work, in theory?
*goto postfight
*label postfight
*choice

Is this worthy of a herpderp answer my noob status is preventing me from seeing?


#19

Heh, I don’t think I’ve ever seen such an unhelpful error–there’s usually something to suggest what might be wrong, and even a specific line number.

There’s certainly nothing wrong with those three lines in and of themselves (although the *choice would of course error without any options following it, but I take it that’s not what you mean). The indentation is correct as well (i.e. none for those lines).

I’ll PM you an email address, just in case you want to send me a sample of what you have, to take a closer look.


#20

I should have emailed last week, but it’s quite hard to focus on anything but R&R during spring break.