ChoiceScript Full Tutorial (finished!)

So, *selectable_ifs in *fake_choices won’t work once it’s published, even if they do during testing? That’s good to know.

I found some more things… I hope you don’t mind if I list them as I go through this!

(Never mind what was here–thanks Vendetta!)

I think it’s also worth explicating the two types of *if statements which exist. (Maybe on the Variables (General) page.)

  • The first type is the single block, without an *else (or an *elseif). This type can end with a terminal command, but if not, gameflow simply falls through to the next line after the block.
  • Then there’s the multi-conditional block (*if/*else or *if/*elseif/*else). Every one of these blocks, including the *if block, must end with a terminal command.

The FishingVillage example in Variables (General) has a typo: the *set and *goto lines aren’t indented enough under their #option.

You taught me something new! I did not realize you could nest *if statements, or use *else blocks, inside of *choice blocks. I almost don’t want to, but it would improve legibility of some of my code…

Variables can, in fact, change kinds. You can’t perform mismatched calculations, so you can’t add 1 to a string or *if a number, but you can set a text variable to 1.
*temp num 50 *set num "OK"
is perfectly valid. (You shouldn’t do this, but you can…)

Text Variables (Strings) lacks the third printing option. $!!{varname} capitalizes every character in the string.

Not entirely accurate. The following will work just fine -

*hide_reuse *selectable_if (var = 1) #This option is perfectly valid

It’s just a matter of using them the right way around. I’ve never used *disable_resuse in the same way but I wouldn’t be surprised if it also works.

3 Likes

Ah, thanks! I must have been trying to mix *ifs and selection line effects, way back when, and came to the wrong conclusion thanks to the finicky nature of same-line *ifs. Or else I just had them in the wrong order.

So; it looks like you can have one (or no) selection line modifier, followed by one (or no) *if or *selectable_if statement, per #option.

2 Likes

Please do go through them! I love all the tricks you know about, and it’s really helpful rounding this out. Finding typos is especially valuable. The raw code for this guide isn’t easy to copy-paste into a file and test it.

I’m working on updates today, I’ll let you know when it’s updated.

All that said, I think I’m going to keep “change variable kinds” under “break the game”. Even if it’s technically possible, it almost shouldn’t be. <_<

1 Like

I didn’t know that. I’d been using the boonlean trick too. Thanks for letting me know! I’ll work on that update.

1 Like

Almost… bear in mind it’s still possible to impose an overriding *if condition on one or more *selectable_if (or *hide_reuse, etc.) options, as follows:

*choice
    *if (var1 > 50)
        *selectable_if (var2 = 1) #This is a valid option only if both conditions are true
6 Likes

Yes, you’re right, of course—I should have said “on the same line.” *ifs can always be placed standalone on the line before.

3 Likes

I updated the program! Lots of updates, thanks to @Chris_Conley and @Vendetta.

  • Added an Inventory template page ( Hope this helps you, @Sovereign2Lilith ! )
  • Added 2 template pages explaining how to have stat tests reference variables instead of static numbers. (“Managing Game Difficulty”)
  • The *fake_choice page now mentions that you can use *if statements (maybe someone wants to double-check I got the description correct.)
  • The Randomtest page mentions that it won’t catch the error of using *selectable_if on a *fake_choice
  • *choice now has an example for using multiple commands on the same line of selection line.
  • *The Quicktest page explains an error code that can appear from using multiple commands on the same *choice selection line incorrectly.
  • Text Variables page got $!!{}
  • Text Variables page got info on how to type special characters
  • Expanded on how *else / *elseif chains change an *if statement (in Variables (General))
  • Fixed typos

Thanks for all the help improving this guide!

4 Likes

That’s one tutorial neatly put together! I wish I had this when I started. :stuck_out_tongue:

It’ll be a huge help to those new to CS, and even those who are not. Great job!

4 Likes

Just a quick update that the page now has use of the Back button, and each page has its own unique URL. These aren’t as useful as I’d like, because each click counts as opening a new page, and the unique URLs aren’t pretty, but I still think it’s useful.

To celebrate, here are some especially useful quicklinks:

Visualizing ChoiceScript
- how to visualize ChoiceScript’s formatting.

Design Templates - learn (and even download, if you want) basic reusable templates.
Design Strategies - learn how to approach ChoiceScript game design.

7 Likes

Also useful:

Quicktest troubleshooting
Randomtest troubleshooting

Stats page help (Note that there is another Stats Page example with the Design Templates page.)

6 Likes

I’m pretty proficient at this, despite being relatively new to it, because I know a handful of other scripting languages.

HOWEVER this looks like an immensely helpful tool that I will have bookmarked for reference if/when I come across any issues.

Thank you so much! :two_hearts:

3 Likes

Nice! The lack of internal URLs/bookmarkability was my main complaint about this resource. I was worried you wouldn’t be able to add that without revamping the whole thing, which is why I didn’t mention it.

Once people get to grips with the tutorial elements of your site they might ask ‘what’s next?’

You might wish to consider a section linking forum demos demonstrating innovative coding with choicescript (or even if you’re up for it, a hyperlink to one of the game’s scene files so they can immediately review the code)

These could be assembled under simple headers, like

  • introducing external instructions (for saving / multiplayers)
  • using advanced inventories
  • highly graphical games
  • advanced randomisation
    that kind of thing

I only mention it because I thought of your site when I wanted to find a quick way of viewing innovative ways of using choicescript :blush:

2 Likes

I like that idea, especially since the sheer volume of the forum tends to overwhelm me. Although, since it can be overwhelming, I think it’s that much more important to help sort it out! I just finished doing some moving stuff, so I think I’ll start looking into it. If you have suggestions for specific forum posts though, everything helps!

4 Likes

@jeantown’s Guenevere has a *restore_password function that’s useful to look at - but I believe it requires adding a line of script to the game files

@Lordirish does pretty good examples of inventory systems - there’s one in Norif I: The Lost Raven but he might be able to say which is the best example for code

@aetheria did a great job with visuals in Lunchtime at St. Expeditus

I don’t think there’s anything available to look at yet from Chronicles of Mornland - which has some kind of multiplayer function.

: )


I’ve been trying to find games with developed code around randomisation, grammar matching etc. (I offer my mini game Wilson until a better example is suggested)

3 Likes

Seems I’m a bit late to the CS Tutorial fest! @Lglasser Amazing work here :clap: Being a more interactive and visual learner, this tutorial would have worked wonders for learning.

At least now I have something to get me back into the flow of things if ever I take a long break. Thanks for such a grand contribution. :smiley:

1 Like

Typo

*create (Create a permanemt variable)

4 Likes

Thanks a bunch! Fixed! :smiley:

3 Likes