New ChoiceScript features for programmers



OK, I've kinda fixed it in the latest version on github, but mostly not.

Quicktest now effectively skips *goto_scene and *gosub_scene lines that use {} or []. (Randomtest works fine.) If you have a file with a section that can only be reached using a curly referenced *goto_scene command, consider adding a section like this somewhere in your game, enumerating the possible destinations.

*if false
  *gosub_scene checkpoint chap1
  *gosub_scene checkpoint chap2
  *gosub_scene checkpoint chap3

Quicktest will "run" those lines to verify that the chap1, chap2, and chap3 labels exist in the checkpoint scene, and verify that those labels will be actually covered by Quicktest.


Thanks, Dan. It's working now.

I'm using arrays in ZE:Safe Haven, so I'll report any issues if they pop up.


These look like some great improvements! Thank you! : )


I'm still getting errors on quicktest using the ChoiceScript version downloaded today. I receive an error:
ERROR: couldn't open web/mygame/scenes/.txt

on this line:
*goto_scene {hold_scene} {hold_label}

The game runs fine but QT reports an error.


I can't reproduce that. This works:

*temp animal "animal"
*temp claws "claws"
*goto_scene {animal} {claws}

But I speculate you're getting tripped up on Quicktest's fake bugs, the tendency to "cheat" on *if statements. For example, this will fail in the manner you described.

*temp hold_scene ""
*temp hold_label ""

*if false
  *goto end
  *set hold_scene "animal"
  *set hold_label "claws"

*label end
*goto_scene {hold_scene} {hold_label}

In real life, it should be impossible to have an error in this code, because the *goto_end line should never be called. But Quicktest will cheat and run the *if false command as if it were true, resulting in the bug you see here.


I don't think it's the fake bug. It's when I set hold_scene in one scene, goto_scene, and then goto_scene {hold_scene}.

So in chapter 1, I do...

*set hold_scene "chapter1"
*set hold_label "ChapterChoices"
*goto_scene WeaponSelect

and in scene WeaponSelect...

*goto_scene {hold_scene} {hold_label}

that last section of code is not in an IF block.

It's not a big deal, since I am getting around it but wanted to report it.


Jim, I noticed you left the quotation open. Is that how you typed it?


Not in my actual code, just here smile


Whoops. Well I guess I wasn't any help. laughing


I still don't reproduce the issue. I just took the latest ChoiceScript and edited startup.txt and created WeaponSelect.txt.


*create leadership 50
*create strength 50

*create hold_scene "animal"
*create hold_label "claws"
*goto_scene WeaponSelect


*goto_scene {hold_scene} {hold_label}

This passes Quicktest and seems to work normally in play, too.


sorry again, but try this...

*create leadership 50
*create strength 50
*create hold_scene ""
*create hold_label ""

*set hold_scene "animal"
*set hold_label "claws"
*goto_scene WeaponSelect

This is where I'm stuck. I want to set the hold_ variables at different times and the error occurs.


OK, yeah, I reproduce this error now. Quicktest tests each scene in isolation; if you *create variables with invalid values without setting them to something valid within the current scene, a fake bug may occur.

But since my version works and yours doesn't, I think a reasonable workaround is to *create hold_scene "dummy" where there's an empty dummy.txt file to satisfy Quicktest.


The ability to dynamically create an array would be really nice, copying and pasting hundreds of lines and manually changing the number is a real pain.

Maybe something like...

*create_array varName amount defaultvalue ?

*create_array soldier_ranks 20 "Private"

I also think the fact that you refer to an array like this[5] could confuse people when the actual variable is named/defined like this_5.

Other than that, these are all very useful features, a definite step in the right direction.
I'm looking very forward to using them.


I would like to use the new Array Syntax, but, a tad apprehensive if the syntax will change in the future. Has a final decision been made to keep the array syntax?

I agree that manually typing out the index numbers can be painful and you have my vote for Dynamic Array support. I've been using Spreadsheet App (Open Office Calc) as the Editor of choice working with ChoiceScript. Works quite well with consideration to the indention rules and lack of dynamic arrays. All I'm missing now is Syntax Highlighting. lol.


Could someone please help me out with the new spacing rules? Why are spaces after *if statements no longer working?

Two *line_break commands kind of work, but create a bigger space than I want. One *line_break is a single carriage return with no blank space (the same as it was before.) Blank lines don't work at all. What's the solution to manufacture a single blank line between paragraphs if you're using *if statements?


I think you're looking for this topic?


Sorry for a little bit of a bump on this topic, but I've finally gotten around to using these features with a new project.

First off, again, I love these new features, but as others have said, the ability to either dynamically create an array, or do so with a one-liner like CJW suggested would be very useful. I had though I could compact things a little by using a loop, but since all the *create commands need to happen first, one can't use a loop to set up an array.


I've been trying out the array syntax with two dimensional arrays, and at first it seemed to work remarkably well (when printing values and even using two variables as the array indexes).
For some reason however the *set command seems to ignore the second pair of brackets?

Because whilst this works great:

*create twodimensionalarray_1_1 "Hello!"

This throws the error "Non-existent variable 'twodimensionalarray_1'"

*set twodimensionalarray[1][1] "Hello again!"

In fact it actually appears to be ignoring everything after that first bracket pair as the following line throws the same error as above:

*set twodimensionalarray[1]_2 "Hello again!"


Good catch! It should be fixed now in the latest version of ChoiceScript up on Github.


It seems the 'long' option of *input_text doesn't work anymore, was this an accident caused by these changes?