Does Twine variables differentiate between capitalised and non caputalised letters?

Harlowe 3

I’m trying to add a sort of system to my game, where a sort of code is created for the player to discover, and put into an array. The thing is, if harlowe doesn’t differentiate capitalised letters, it’s going to make it harder for me to do it.

So, does it?

Yes, variables in Twine are case sensitive. So $KEY, $Key, and $key would be three different variables.

That said, I should mention that it’s generally bad practice to have multiple variables with the same name, but different capitalization, since they can easily be confused by us humans. :stuck_out_tongue_winking_eye:

Sorry, I think that was horriblew wording on my part.

I don’t really know how to put it, but let’s try again. If I want to save a string of letters in an array and put that into a variable, fo the capitalization of the letters in the string matter?

I want the code to have a certain number of possible variations, and I have found out that I can’t do that by just varying the lenght of the code or having more/less possible letters.

Yes, the letter casing of letters within a String value matter when you are comparing one such value with another. eg. “J” is not equal to “j”, thus “Jane” is not equal to “jane”.

In situations where you want to compare two Sting values, in a way that ignores the casing of the letter(s) contained within the two values (like comparing a entered password), one common technique used is to temporary convert both string values into the same letter casing.
(untested code)

(set: $string1 to "A")
(set: $string2 to "a")
(if: (lowercase: $string1) is (lowercase: $string2))[The two strings contain the same letter.]
(else:)[The two strings don't contain the same letter.]

note: In situations when you know the letter case of one of the values then you only need to convert the casing of the other.

Thank you! I made it work. Maybe someone in the future will need to know I used the unless: function, so future IF writer, you’ll want to use it to make sure the uppercase “J” and the uppercase “F” don’t confuse twine and you end up with two solutions to your game of color codes.

Just make sure the “Unless:” is put before the “if:”, like this:

(unless: $array’s 2nd contains “J”)[
(if: $array’s 2nd contains “F”)[
(set: $var to “black peg”)

I’m sleepy, so you may not understand what I’m saying. But I’m sure others will help you.