New features in ChoiceScript: change text size/color, hyphen spacing, @{} variable replacement

choicescript-updates

#8

So as far as usage goes, it’s looking like @{ would mostly serve as a streamlined replacement for clunky sets of *if clauses, correct? I could see this coming in handy for flavor text, especially.

I suppose you could even get it to work for longer ranges of numbers with judicious use of division. For example, a typical percentage relationship score, modified to give a range of 1-5…
@{((round(sandy/25))+1) Sandy hates me.|Sandy doesn’t like me much.|Sandy and I are neutral acquaintances.|Sandy and I get along well.|Sandy and I are best friends.}

This suggests to me that it could have interesting uses in a stats screen as well.


#9

Yeah; just convert your *creates into *temps and it’ll work as designed.


#10
*temp count 3
*temp mytest "There @{count is one thing|are two things|are three things} here."
*temp mytest2 "?"

Testing

There @{count is one thing|are two things|are three things} here.

mytest = ${mytest}

*set mytest2 {mytest}

mytest2 = ${mytest2}

Produces this error:


#11

I think the issue is here… ${mytest} would become “there are three things here” so it is checking whether the variable “mytest” matches the theoretical variable “there are three things here,” which doesn’t exist.


#12

Aha! Ok… more sorcery…

*temp count 3
*temp mytest "@{count one|two|three}"
*temp mytest2 "?"
*temp three 3

Testing

@{count one|two|three}

mytest = ${mytest}

*set mytest2 {mytest}

mytest2 = ${mytest2}

Produces this:

Testing

three

mytest = three

mytest2 = 3

#13

Or wait, no, that line wasn’t the issue, because it wasn’t an *if clause… it was just text displaying…

Let’s see, line 11 was here…

And that’s where it would be trying to set mytest2 to match “there are three things here.” So that’s where it was.
I’m not sure about the brackets here :confused: I think I’d be used to something like *set mytest2 “${mytest}”

But then that same line appears to work in your new version :confused:
I guess it’s working because you’d set mytest to become “three” rather than “there are three things here,” and it also worked because you’d created "three as a temporary variable. So that’s the difference here.
I’m just not sure why it works with plain brackets, which I don’t think I generally see in code… is there a change in how coding works with brackets for variables, or is this unintended behavior?

Edit: Wait, I see, this bracket use is a feature described here: New ChoiceScript features for programmers
That does make things smoother :thinking:
(And is indeed in the Advanced Choicescript Commands page under “Curly parens” and “Set by reference”… there we go. I think I’ve just been used to seeing it the other way around :sweat_smile:)


#14

And here is a very rough random “name” generator to play with.
(It works!)
Feel free to edit, improve, and use this in your own projects:

*temp count 1
*temp number 1
*temp name ""
*temp holder ""

*label myname
*if count < 8
 *rand number 1 26
 *set holder "@{number a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z}"
 *set name &holder
 *set count +1
 *goto myname
*if count = 8
 *set count 0
 *goto helloworld

*label helloworld

My randomized name is: ${name}


#15

I haven’t tested this, but how’s this for a random name generator to fit a fairly generic language. Could be modified to fit whatever sound system is desired… using the same principle, but separated into separate labels should allow for more structured and prettier words :smile:
Also modified to allow variable word lengths.
A further possible modification would be to make certain letters more common by repeating them.

*temp count 1
*temp number 1
*temp name ""
*temp holder ""

*rand count 1 6

*label myname
*label onset
*if count < 10
 *rand number 1 13
 *set holder "@{number m|n|p|t|k|b|d|g|s|h|w|l|y}"
 *set name &holder
 *set count +1
 *goto vowel
*if count = 10
 *set count 0
 *goto helloworld
*label vowel
*rand number 1 5
*set holder "@{number a|e|i|o|u}"
*set name &holder
*set count +1
*rand number 1 4
*if number < 4
 *goto onset
*if number = 4
 *goto coda
*label coda
*if count < 10
 *rand number 1 4
 *set holder "@{number n|l|i|u}"
 *set name &holder
 *set count +1
 *goto onset
*if count = 10
 *set count 0
 *goto helloworld

*label helloworld

My randomized name is: ${name}

#16

“…limited only by the vast, unstoppable power of your imagination…!”

Here’s a vast improvement to my original:

Code
*temp count 0
*temp number 1
*temp name ""
*temp holder ""
*temp limit 0

*label mainmenu
How long do you want your name to be (in letters)?

*choice
 #3
  *set limit 3
  *goto myname
 #4
  *set limit 4
  *goto myname
 #5
  *set limit 5
  *goto myname
 #6
  *set limit 6
  *goto myname
 #7
  *set limit 7
  *goto myname
 #8
  *set limit 8
  *goto myname
 #9
  *set limit 9
  *goto myname
 #10
  *set limit 10
  *goto myname

*label myname
*if count < limit
 *rand number 1 21
 *if count = 0
  *set holder "@{number B|C|D|F|G|H|J|K|L|M|N|P|Q|R|S|T|V|W|X|Y|Z}"
 *if count > 0
  *set holder "@{number b|c|d|f|g|h|j|k|l|m|n|p|q|r|s|t|v|w|x|y|z}"
 *set name &holder
 *set count +1
 *if count < limit
  *goto myname2
*if count = limit
 *set count 0
 *goto helloworld

*label myname2
*if count < limit
 *rand number 1 5
 *set holder "@{number a|e|i|o|u}"
 *set name &holder
 *set count +1
 *goto myname

*label helloworld
My randomized name is: ${name}

Do you want to keep this name, or pick another?

*choice
 #Pick Again
  *set name ""
  *set count 0
  *goto myname
 #Change the Length
  *set name ""
  *set count 0
  *goto mainmenu
 #Keep It
  *goto success

*label success
You have chosen to keep the name: ${name}

(Link to your code here.)

#17

And now for something Englishy…
It wouldn’t quite fit English exactly, but it should come close to giving the right vibe, assuming I coded it correctly.

*temp count 0
*temp number 1
*temp name ""
*temp holder ""
*temp limit 0

*label mainmenu
How long do you want your name to be (in syllables)?

*choice
 #1
  *set limit 1
  *goto myname
 #2
  *set limit 2
  *goto myname
 #3
  *set limit 3
  *goto myname
 #4
  *set limit 4
  *goto myname

*label myname
*rand number 1 4
*if number = 4
 *set name &"s"
*rand number 1 16
*set holder "@{number m|n|p|t|c|k|qu|ch|j|f|th|sh|h|v|z|}"
*set name &holder
*if holder = "qu"
 *goto qskip
*rand number 1 10
*if number < 5
 *set holder "@{number w|r|l|y}"
 *set name &holder
*rand number 1 9
*label qskip
*set holder "@{number a|e|i|o|u|ai|ee|oa|oo}"
*set name &holder
*rand number 1 15
*if number < 8
 *set holder "@{number m|n|ng|r|w|l|y}"
 *set name &holder
*rand number 1 20
*if number  < 12
 *set holder "@{number p|t|c|k|ch|j|f|th|sh|v|z}"
 *set name &holder
*rand number 1 4
*if number = 4
 *set name &"s"
*set count +1
*if count < limit
 *goto myname

*set name "$!{name}"

My randomized name is: ${name}.



Do you want to keep this name, or pick another?

*choice
 #Pick Again
  *set name ""
  *set count 0
  *goto myname
 #Change the Length
  *set name ""
  *set count 0
  *goto mainmenu
 #Keep It
  *goto success

*label success
You have chosen to keep the name: ${name}

#18

Error messages on all options :cold_sweat:


#19

What message? I’m on phone so I can’t check just now :worried:


#20


#21

That’s the line where I have a |} at the end, with the idea that it would just be blank if it reaches that number. Like in the dragon examples in the OP. Maybe that doesn’t work here? I’ll try snipping that.

Aaaand snipped. Does it work now?

Rereading, I… also missed most of the *set name& that was supposed to be there. But I don’t want to add them all in by phone, so this will have to wait. :disappointed:

Edit: On second thought, that was easy copy paste. So that part is fixed… is the error message still there?


#22

Yep, it looks like the line in question needs a variable inside the { } before the long list.
Same error.


#23

Oh, pah, that was a ridiculously simple error which I was overthinking. I blame the late hour. Of course it needed to actually reference “number.” :rolling_eyes: Okay, fixing everything now.

Thanks, added the actual variable everywhere now. Because the code can’t just tell what number to count by magic :stuck_out_tongue:


#24

startup line 24: Non-existent variable ‘s’

Edit: also this:
line 44: Invalid string, open quote with no close quote: "@{number p|t|c|k|ch|j|f|th|sh|h|v|z}

And now this:
startup line 52: Non-existent variable ‘squeeyv’
(the non existent variable changes every time I reload)


#25

This sounds great :slight_smile: …but now I’m super confused :confused: haven’t tried out any of the features yet, but if you can change text and colour to a few different options whilst playing the game, will these features just let you change the default, but still give the player the option to change colour and size on a game made using these features? As in assuming you have colour and size options different than the options currently say in choice of the dragon(have checked that out since the update) or can create different colours using hex or what not(that confuses me too :stuck_out_tongue: ) would that then be the the default when someone purchases the game, but the player would then have the option to choose text and colour options currently seen in choice of the dragon? Hope that was clear :stuck_out_tongue: .


#26

We can conclude from this that & requires quotation marks when followed by text rather than a variable. Good to know.

The last thing is because I got overzealous with unneeded brackets. The nonexistent variable is the randomly generated name… I accidentally referenced that as if it were a variable, when I really just wanted to set the name variable to the capitalized version. Lots of moving parts, here.
(Now hopefully fixed.)

We can also conclude from this that I should not post code from my phone without being able to test it, which would’ve saved a lot of back and forth :stuck_out_tongue: I thank you for your patience, anyway. Between us, I think we’ve rooted out the issues.


#27

startup line 44: invalid @{} at letter 1; ‘number’ is equal to 13 but there are only 12 options