Choicescript features - ideas

I was searching for a thread for this, but I didn’t manage to find one. If there is one, please send me there! :heart:

I’m sure we all have little things that we have stewed on that would just make all our writing or coding a little easier.

My current one is this:

Let’s say we have a ${variable}, that prints “variable”
Then it happens very often that I use the $!{variable} to print “Variable”.

And while doing research on this, just now, to see that what im looking for doesnt already exist, I did find that my idea for implementation already existed but in a different way…

$!!{variable} apparently prints “VARIABLE”
which is interesting. But not what I need, and has yet been needed in my game.

What has been needed in my game (when I finally learnt exatly how english handles all types of title capitalisations) is a function to capitalise all the words in a longer string.

For example, what I’d like is a thing that:
${twoWords} prints as “two words”
$!!!{twoWords} prints out “Two Words”.
And you’ll perhaps think this is never useful, but with titles and such, how I understand it it varies a lot how you capitalise things like “my lady” depending on if a name comes right after or not. And so a variable that does sir/my-lady suddenly requires quite a few variation.

In general, more ways to work with strings would be lovely, in my opinion :rose:

9 Likes

Some way to force lowercase would be great too! Maybe even capitalize case (first letter of every word becomes uppercase)

7 Likes

Hmm. Are you saying that you want CS to capitalize each starting letter of a string?

Okay. Yes, I’m pretty sure it only capitalizes the first letter in a multi-word sentence. If you use $!{twoWords}.

I agree. It’s either typing in both words separately and combining them with concatenation. Or, use a complex index system and still have to concatenate.

3 Likes

Another thing I hope will be implemented some day: Better Arrays.

Arrays that let you easily check for multiple values at once. I know it from Twine’s Sugarcube and let me tell you, especially for immersion it has been a blessing. Personal example is using it to check if the MC has the same/similar sounding name as an NPC.

With how CS works right now, it’d look something like this:

*if ((((((((((("$!!{name}" = "ELIZABETH") or ("$!!{name}" = "ELISABETH")) or ("$!!{name}" = "ELISABET")) or ("$!!{name}" = "ELIZABET")) or ("$!!{name}" = "LISSY")) or ("$!!{name}" = "LIZZY")) or ("$!!{name}" = "LISSIE")) or ("$!!{name}" = "LIZZIE")) or ("$!!{name}" = "BETH")) or ("$!!{name}" = "BETTY")) or ("$!!{name}" = "BETTIE"))

meanwhile in sugarcube it’d look like this

if $arlizzy.includes($name.toLowerCase()

with arlizzy being an array that contains all the various spellings/varieties, looking like this in twine sugarcubes equivalent to startup:

<<set $arlizzy to ["elizabeth", "elisabeth", "elizabet", "elisabet", "lissy", "lizzy", "lissie", "lizzie", "beth", "bettie", "betty"]>>

I think adding this type of array could help with clutter and doing some shenanigans more easily

6 Likes

Hard. Agree.

Not to mention that since CS can only check pairs, you have to make sure each parentheses is a closed pair within a closed pair. It becomes dizzying.

5 Likes

JavaScript’s string methods already include some useful abilities which would be handy, adding something like ${toLowerCase myVar} or *set myVar slice myVar 1 3. Where ‘toLowerCase’ and ‘slice’ are new keywords accepting following parameters. It should be fairly straightforward to implement, and easy enough for users to learn.

I would also love it if, in multi replaces, an empty string parsed as false and any other string as true. But this might just be me.

3 Likes

This is a really petty one, but I would desperately love more support for different formatting options for the stats menu (namely, being able to give different stat bars different colours and format styles). My game has a number of different magics and I would love the stat bar for each one to have a different colour.

I know Choice of Magics does it via some JavaScript shenanigans, but I’m not sure that other games are allowed to replicate that method?

It would also be really cool being able to use different types of charts and bars and graph options, but I don’t care so much about that one.

3 Likes

I’m not sure why you think this is petty. Colors and formatting can draw attention to the importance of stats when done well.

You would use Javascript and CSS to do this. (Possibly HTML too). Unless you mean a native way of doing it, such as a button or CS code?

When I was playing Sense & Sorcery by Zodac, I also thought it would be very helpful to have different colors for the multitude of stat bars. It made everything seem important and therefore overwhelming.

CSS can also be used to change formats, such as length or font.

code rambles

Somehow, you’d need to declare each stats bar type an object, which I’m not sure is possible? Once you declare, you’d use CSS to code each class of stat bar separately.

Now you’ve got me curious to see if individual coding of stat bars is even possible…

2 Likes

That’s fair - I worried it would be a niche concern, hence downplaying it, but it’s very good to know that other people feel that this could be helpful too.

I think that right now the only way to do it is via *Script and pushing Javascript via that, but I understand that might have been an exclusive thing for Choice of Magics (as in it’s possible for anyone to do it if they can code, but I don’t know if COG or HG would publish a game with that functionality)

I think there’s another way to do it (by counting star bars) - but it breaks badly if your menu has a dynamic number of stat bars (e.g. if some start off invisible) - which most menus these days do, mine included!

I would be fine with it being confirmed that it was OK for us to do the same on our own games and it wouldn’t interfere with publishing - I’m rusty with JS but I can pick it back up easily enough - but it would definitely be even better if we could do it natively…

2 Likes

Mmm! I’d like that option, yes! Then I could have all my current variables as lowercase (except maybe names etc). But in general just more ways to work with strings would be lovely :blush:

1 Like

Omg yes, this would be so great :head_shaking_vertically:
Better arrays is now on the top of my list, above more String functions :laughing:

2 Likes

I think my full wishlist would look like:

  • Return values from gosubs
  • An actual array object
  • Dictionary objects
  • Native string and math library

Whilst you can code your way around all of these in vanilla CS, it does feel a lot like reinventing the wheel, and are often awkward to implement.

To throw a suggestion in, the aforementioned better arrays in practice could look like this, maybe:

*create arlizzie ["ELIZABETH", "ELISABETH", "ELIZABET", "ELISABETH", "LISSY", "LIZZY", "LISSIE", "LIZZIE", "BETH", "BETTIE", "BETTY"]

and 

*if ("$!!{name}" = "§{arlizzie}")

or something

plus maybe a way to say ‘if the value is in the array unless it is this specific value’. A ‘but/unless’ operator maybe?

*if (("$!!{name}" = "§{arlizzie}") but/unless ("$!!{name}" = "BETH"))

so that the *if only triggers if the value is in the unless it’s a specific value from the array

Is there a use case I can’t think of, where having a specific unless operator would be useful instead of just doing the in_array only if the variable isn’t that specific value?

I’d personally do something like *if (("!!$name != "BETH") AND ("!!$name" IN arlizzie)) (pardon my syntax, my programmer brain isn’t on) unless the plan would be to go full database query style.

1 Like

Going with an example from my stuff, there’s a specific situation in which a specific spelling of a surname had to be excluded from the check.

Another case I can imagine would be an inventory where it checks if you have a specific item that’s on the array except for one specific one or somesuch

Maybe it could keep in line with other functions like not(X) or length(Y)

Like
*if ($!!{name} arlizzie("ELIZABETH", ... ETC)?

-EDIT-
Thinking about it further, if this function could return more than simply a true/false, if it could tell you exactly which string it matches. That would be a lot more useful. A sort of inverse multireplace

E.g.
@[name | ELIZABETH | ELISABETH | ELIZABET | ELISABETH | LISSY | LIZZY | LISSIE | LIZZIE | BETH | BETTIE | BETTY]
If name matches any it returns the index number, if not it could return 0 (which JS treats as false when used as a boolean)

This could resolve the BETH thing you mentioned

I mean, yes, I understand what you’re trying to achieve. I just don’t understand the benefit of the way you’re trying to achieve it with. But I guess if it makes more sense to you than the alternative, that’s a benefit enough.