There are five things you really need to know then: variables, if statements, labels/goto, the choice command, and what the hell all those files that came with the game are.
I’ll start off with the files. Games are in the web folder. When you downloaded choicescript, you got a free “demo game” thingy. You can find that in the folder mygame, which is in the folder web. You also got a mygame.js, an “index” thingy, and a scenes folder filled with text documents. The index thingy is how you access the game - double click it to start playing. Your story is pretty much located in the scenes folder, since that’s where you put your scenes. The mygame.js holds bunches of preliminary “before we get started” stuff. Basically it serves two purposes: storing important variables and telling everything in the game about them so you can throw them all over the place without the program getting mad, and storing a list of the various parts of your story in the order that they should happen so things chapter 1 happens before chapter 7. To edit your mygame.js, right click it and select “edit”. Below the highly unimportant copyright stuff you should see this:
`// Specify the list of scenes here, separated by commas, with no final comma
nav = new SceneNavigator([
“startup”**********
,“animal”
,“variables”
,“gosub”
,“ending”
,“death”
]);
// Specify the default starting stats here
stats = {
leadership: 50**************
,strength: 50
};
// Specify the stats to use in debug mode
debugStats = {
leadership: 50
,strength: 50
};
// or just use defaults
// debugStats = stats`
Except I added a bunch of asterisks/stars. The first place where there are a lot of stars is where you tell the game what order to read your text files in the scenes folder. The second is where you put your stats and other variables. Try to follow the syntax - if they have a comma before everything but the first one, do that.
And now for variables. A variable remembers a value. If I say *set this_is_my_variable_name 8
, then this_is_my_variable_name stores the value “8”. Later I can ask it to recall the value I gave it earlier, and it’ll tell me “8”. Later you can tell the variable to hold/be “9”, and then it’ll give you “9” whenever you ask it what it has. That is what a stat is - a variable that can hold information. If you want a variable to hold strength, name it strength. You can name it variable1 or asdi3ohsa7wjpoz or something, but then you you’d forget what it was supposed to be. Then you can set strength to 1 for weaklings and 1,000,000 for strong guys (*set strength 1,000,000
).You can also increase or decrease variables without knowing what they are. If the variable “increase_me” is 10, and I say *set increase_me +1
, then increase_me will start storing 11. Can also do minus 1, times 108, and divided by negative 20. You can also use another variable in place of those wacky random numbers I just used. If you already have a variable called “meaning”, and it is, say, set to the value “42”, then you can say *set increase_me +meaning
, or set it to directly equal meaning with no plus sign, or whatever. You can also set variables to hold strings of letters (called strings). Example: *set name "Gerblah"
. Make sure to use those quotation marks - if you don’t it will think you want to set name to the value held by the non-existant variable Gerblah, and then the computer will throw a hissy fit. Or give you an error message. There’s a special place made to display your stats in a nice way: the choicescripts_stats.txt in your scenes folder. You may recognize it as that one place that the game sends you to when you press that one button at the top-left in every choice game. If you open it up, it looks like this:
*stat_chart percent Leadership opposed_pair Strength Weakness text Leadership text Strength
I didn’t add any stars/asterisks this time. Before showing stats, say *stat_chart. Cause why not? But seriously, for some reason you need to do that to get the game ready to show stuffs. Then you can use the percent command, opposed_pair command, or text command to show off the value held by any variable (though you are more likely to use this to show someone “intellect” than “flirting_with_jacob” or “safe_unlocking_combination”). Percent gives you the number as a percent of 100. If tthe variable’s value is 50, then it will show a half-filled bar with the text “50%” on it. Opposed_pair is what they had in Choice of Dragon, where high brutality is synonymous with low finesse. In that weird opposed_pair case, it uses one variable. A low value for that variable means awesome brutality (or finesse) but terrible… the other one. Text is the most straight-forward one - it displays text. It is also the only one that can use text-y variables, like “player_name”.
And finally, the if statement. It is basically you telling the computer “here’s a bunch of stuff, but skip over it unless something is true”. Example:
*if peglegpenguin = "awesome" *set ending "good_ending" This is text that would be displayed if this was a real game! *if peglepenguin = "stupid" *set ending "great_ending" The old ghost town seems empty. Your friend does not seem to be happy that she is here.
Depending on what value I am equal to immediately before this part of the code, you’ll either end up with the variable “ending” set to “good_ending” or “great_ending”. Also, different text will be displayed. Totally forgot to mention that text without a command before it is just displayed as text. Anyway, take note of the indentations. The stuff between the two if statements is indented, meaning that it is inside of/belongs to/is “nested within” the thing above it that isn’t as indented. So that *set ending “good_ending” belongs to that first if statement, and won’t be read unless the if statement’s condition of me being equal to “awesome” is met. The other if statement does not belong to the first, and so it will be read regardless. It owns its own stuff, including that *set ending “great_ending” and that ghost town text. If statements can be nested into each other, and that means you add more indentation. Just make sure you are consistent in how many spaces you use to indent nested things, and how then how many spaces you use to indent nested things within nested things, ect. Other things use indentation too - if you look back I used it bunches of times before.
Now for labels. Labels are like bookmarks made of binary. Except completely different. You can place a label somewhere in the code with “label whatever_the_label_is_called”, and then jump from wherever you are straight to that point by saying “*goto whatever_the_label_is_called”.
And finally the choice command. Here’s one of them:
What is your name? *choice #Albert Foxwolf *set name "Albert Foxwolf" Awesome name! *goto next #Princess Tutu *set name "Princess Tutu" Very awesome name! *goto next #Velociraptor *set name "Velociraptor" Bad name. You die. *goto die
You need labels and gotos to get out of commands for some reason. Except that is a lie since there are ways to make choices that don’t need labels using the fake_choice command. I advise that you read about advanced commands like that. Anyway, this code should be self-explanatory. Indentation rules and when to use “#” should also be self-explanatory when making choice commands. Also, pretend I had labels somewhere else in my game called “die” and “next”.
I hope this helped, and that I didn’t forget to include anything massively important (though I probably did). Again, I really advice that you read on in the advanced command section - stuff like *gosub and *elseif aren’t necessary but they are pretty darn nice.