Error when using *create

"Error: startup line 3: Invalid variable name, must start with a letter"

I’m getting that error when I put *create at the very top of my code. When I removed it I get:

TypeError: this.verifySceneFile is not a function

There’s nothing in my code that uses verify, scene, or file so I’m confused about what this error means.

Any help?

Which text file are you putting *create in? Also, what is your variable called?

the index file that pulls up the basic ChoiceScript editor.

There is no variable attached to the *create at the very top. In all the sample code there was just a line that said *create at the very top. Should there not be?

You don’t edit index.html, it’s .txt files that you do your coding in (starting with startup.txt which is where all of your creates should be).

Can you copy and paste exactly what you’re typing in?

1 Like

file:///C:/Users/NAME/Documents/Choice%20of%20Games%20Choice%20Script%20Download/editor/index.html

that is the link to where I am typing. everything is also saved in a .txt wordpad file.

We can’t actually access files saved onto your own hard drive. However, the index.html file is not where you want to be doing any editing work. If you open up the scenes folder, in there you’ll see a number of txt files, including startup.txt which is the files you want to edit.

Also, you want to use a text editor not wordpad for writing code. I like Notepad++

1 Like

So, do I just delete all the text in the startup.txt and replace it with my own?

I’m really new to this, and while I think I have all the code written and indented correctly I’m just confused about how to get it actually online and functioning. Hahaha.

I’d suggest downloading choicescript again, that way you’ll have a fresh index.html file. Then once you do, replace all the txt in your startup.txt file with your own. You can delete everything else in that folder, apart from the choicescript stats file, (which is the only other file you need to edit.

I’d also suggest looking at Choice of the Dragon to see how things work. https://www.choiceofgames.com/dragon/scenes/ (ignore the .js and .json files since you won’t have those just the txt ones) and in particular https://www.choiceofgames.com/dragon/scenes/startup.txt

Ok, I did that. What do I do next?

I actually used CoD to look at the indentation and stuff while writing it! So I THINK my code should work.

I suggest looking at the wiki. It’s got some extremely helpful advice on how to get things working.

1 Like

That helps so much! Thank you!

I didn’t know there was a wiki or I would have looked there first!

Edit: I bookmarked the wiki because it’s rediculously helpful for a newbie like me thank you again!!

1 Like

In case you’re still a bit stuck, as I had trouble working out where to place files and such:

Open your game’s folder. Followed by web, mygame. In the mygame folder, the index file there is what you use to actually run/test your game. However, to actually write it, go into the scenes folder from there. Open up startup.txt. That should be your first port of call. In there, you store all of your variables and switches, made by the *create command. Only use those those for ‘permanent’ switches and variables though. For variables and switches that you only use for a scene or two, as in one .txt file, you can use the *temp command to create them in the individual files.

We tend to use Dropbox to share works in progress. If you’re a new user though, you need to pay for the public folder, I believe. If I may also make a suggestion, try using Notepad ++. It’s free and it has very handy indent features, which is great as indenting is very important when coding with choicescript.

Also, in the first folder you open for your game, you’ll find ‘randomtest’ and ‘quicktest’. Very handy. Randomtest, if you tell it to show full text and line coverage, it’ll tell you how many words were seen each playthrough at the bottom. Helps you to gauge how long each read will be and how much of the content is being missed by readers if they only read once.

Finally, though it’s possibly something you won’t want to bother with for now, there’s a way to prevent stats going over 100 and below 0. By using % before the + or - sign, you tell choicescript to use fairmath. With a + and a score of 50, telling it to increase by 50 will give 25 points. So, let’s say you have a stat called corrupted, you’d type:

*set corrupted %+50

You also want to make sure that switch and variable names have no spaces. Same with file titles.

That should about cover some basic things anyways. Later, when you get the hang of it, the gosub and gosub_scene commands can be very useful if you look into them.

(You might also want to do a search for ‘choicescript ide’ which allows you to edit your stories online, but I don’t use it myself.)

1 Like

Fairmath works for this, or you can cap it by hand. If you write a script like so:

*if kara_relationship<0
   *set kara_relationship 0
*if kara_relationship>100
   *set kara_relationship 100

You can send the code to it after each change with gosub_scene stat_capping, put a *return command at the end of the stat_capping scene, and it keeps your variables in line without fairmathing.