# New ChoiceScript features for programmers

**URL:** <https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423>\
**Category:** Announcements\
**Tags:** choicescript-updates\
**Created:** [March 30, 2015, 3:47am UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423 "2015-03-30T03:47:50Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [April 18, 2015, 10:39pm UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/21 "2015-04-18T22:39:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JimD](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/jimd/32/21672_2.png) [@JimD](https://forum.choiceofgames.com/u/JimD)\
**Post date:** [April 19, 2015, 5:58pm UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/22 "2015-04-19T17:58:10Z")

</div>

Thanks, Dan. It’s working now.

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

---

<div class="post-metadata">

**Author:** ![CJW](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cjw/32/111787_2.png) [@CJW](https://forum.choiceofgames.com/u/CJW)\
**Post date:** [April 19, 2015, 8:01pm UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/23 "2015-04-19T20:01:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JimD](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/jimd/32/21672_2.png) [@JimD](https://forum.choiceofgames.com/u/JimD)\
**Post date:** [April 26, 2015, 4:17pm UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/24 "2015-04-26T16:17:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [April 27, 2015, 4:39am UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/25 "2015-04-27T04:39:05Z")

</div>

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](https://www.choiceofgames.com/make-your-own-games/testing-choicescript-games-automatically/#fakes), 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
*else
  *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.

---

<div class="post-metadata">

**Author:** ![JimD](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/jimd/32/21672_2.png) [@JimD](https://forum.choiceofgames.com/u/JimD)\
**Post date:** [April 28, 2015, 1:08am UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/26 "2015-04-28T01:08:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TechDragon610](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/techdragon610/32/4016_2.png) [@TechDragon610](https://forum.choiceofgames.com/u/TechDragon610)\
**Post date:** [April 28, 2015, 1:13am UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/27 "2015-04-28T01:13:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JimD](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/jimd/32/21672_2.png) [@JimD](https://forum.choiceofgames.com/u/JimD)\
**Post date:** [April 28, 2015, 1:21am UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/28 "2015-04-28T01:21:04Z")

</div>

Not in my actual code, just here 😄

---

<div class="post-metadata">

**Author:** ![TechDragon610](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/techdragon610/32/4016_2.png) [@TechDragon610](https://forum.choiceofgames.com/u/TechDragon610)\
**Post date:** [April 28, 2015, 1:29am UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/29 "2015-04-28T01:29:28Z")

</div>

Whoops. Well I guess I wasn’t any help. 😆

---

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [April 28, 2015, 3:21am UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/30 "2015-04-28T03:21:14Z")

</div>

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

startup.txt:

```
*create leadership 50
*create strength 50

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

```

WeaponSelect.txt:

```
*goto_scene {hold_scene} {hold_label}

```

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

---

<div class="post-metadata">

**Author:** ![JimD](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/jimd/32/21672_2.png) [@JimD](https://forum.choiceofgames.com/u/JimD)\
**Post date:** [April 28, 2015, 9:36pm UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/31 "2015-04-28T21:36:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [April 29, 2015, 5:51am UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/32 "2015-04-29T05:51:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![CJW](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cjw/32/111787_2.png) [@CJW](https://forum.choiceofgames.com/u/CJW)\
**Post date:** [May 11, 2015, 10:00am UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/33 "2015-05-11T10:00:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![techlord](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/techlord/32/4152_2.png) [@techlord](https://forum.choiceofgames.com/u/techlord)\
**Post date:** [May 14, 2015, 7:05am UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/34 "2015-05-14T07:05:40Z")

</div>

> [@dfabulich](#):
>
> Experimental support for arrays. I don’t want anybody to rely on this syntax yet, because I may need to change it yet, but I would like feedback on it. (In other words, talk to us before submitting a HG or CoG game that uses arrays.)

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.

---

<div class="post-metadata">

**Author:** ![Sashira](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/sashira/32/2899_2.png) [@Sashira](https://forum.choiceofgames.com/u/Sashira)\
**Post date:** [May 31, 2015, 1:36am UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/35 "2015-05-31T01:36:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![RETowers](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/retowers/32/21477_2.png) [@RETowers](https://forum.choiceofgames.com/u/RETowers)\
**Post date:** [May 31, 2015, 1:39am UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/36 "2015-05-31T01:39:11Z")

</div>

I think you’re looking for this topic?

> [@Fixed a ChoiceScript bug: blank lines at the end of \*if](https://forum.choiceofgames.com/t/fixed-a-choicescript-bug-blank-lines-at-the-end-of-if/8836):
>
> There’s been an annoying bug in ChoiceScript forever, like this: Paragraph 1. \*temp maybe \*rand maybe 0 1 \*if maybe = 1 Maybe! Paragraph 2. If maybe = 1, then there’s a paragraph break between “Maybe!” and “Paragraph 2.” But if maybe = 0, then the paragraph break is skipped; the user sees “Paragraph 1. Paragraph 2.” all in one line. I’ve just pushed a fix to github, so there will now always be a paragraph break. Give it a try and let me know if it breaks anything. In particular, I know…

---

<div class="post-metadata">

**Author:** ![stainedofmind](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/stainedofmind/32/459_2.png) [@stainedofmind](https://forum.choiceofgames.com/u/stainedofmind)\
**Post date:** [June 30, 2015, 9:34pm UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/37 "2015-06-30T21:34:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![CJW](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cjw/32/111787_2.png) [@CJW](https://forum.choiceofgames.com/u/CJW)\
**Post date:** [July 10, 2015, 4:13pm UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/38 "2015-07-10T16:13:19Z")

</div>

@dfabulich  
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!"
${twodimensionalarray[1][1]}

```

This throws the error “Non-existent variable ‘twodimensionalarray\_1’”

```
*set twodimensionalarray[1][1] "Hello again!"
${twodimensionalarray[1][1]}

```

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!"
```

---

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [July 19, 2015, 5:20am UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/39 "2015-07-19T05:20:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CJW](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cjw/32/111787_2.png) [@CJW](https://forum.choiceofgames.com/u/CJW)\
**Post date:** [September 20, 2015, 10:17pm UTC](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423/40 "2015-09-20T22:17:58Z")

</div>

It seems the ‘long’ option of \*input\_text doesn’t work anymore, was this an accident caused by these changes?

[Previous page](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423.md?page=1)

[Next page](https://forum.choiceofgames.com/t/new-choicescript-features-for-programmers/8423.md?page=3)
