LCase and If
JenniferKline
24 Jul 2017, 21:54Heya all,
Thanks for all the help recently with my questions. Really I'm running out of functions I'm having difficulty with and more needing to just write, write, and write.
Then I add more utility and need help uwu.
Right! Here's the little pest that's screwing me up.
{if LCase player.ears=pointed: pointy}
Yeah, with this I'm just getting the stringy thing appear right in my text.
I also tried:
{if player.ears=LCase ("pointed"):pointy
which got me just as much nowhere.
Now, either I find a way to sort out how to LCase my ifs and buts when I'm doing them in text, or
Is there a way to make it so when I use get input
and then set the result as an attribute that I can force that attribute to become lowercase?
It's a new thing for me, so I'm not totally sure what I'm doing.
Thanks!

Richard Headkid
24 Jul 2017, 23:53The curly braces method is sensitive about some things.
Take it down to lower case when you get the input. (I saved it as a Boolean attribute in this example.)
If you check out line 10, you'll note that player.pointy
is created here, and it is true
.
So, now you can refer to it throughout the game as if (player.pointy)
.
That's a 'short-cut', which pretty much means if (player.pointy = true)
.
msg ("Enter Pointy.")
get input {
result = LCase(result)
if (result = "pointy") {
msg ("Yay, you entered \"" + result + "\".")
player.pointy = true
}
else {
msg ("Boo! You entered \"" + result + "\".")
}
}
Now, the curly braces inside of your text processor input field will play nice:
{if player.pointy: pointed.}
NOTE: When using the curly braces inside of the 'text' field (like in this example), DO NOT use the parentheses (in this instance) :
Doesn't work with the parentheses inside of the curly braces when entered into a text field:
Works without the parentheses:
{if (player.pointy): pointed}
will yield a FALSE
result, whereas {if player.pointy: pointed}
will actually check to see if player.pointy
is true or false. (Quest doesn't know what (player.pointy)
means inside the curly braces with the parentheses. (This, I assume, has to do with the way Quest utilizes expansion, but I'm not opening that particular can of worms!))
UPDATE: I had it where it set player.pointy
to True
either way, but it is fixed now.
Here's the entire sample game:
CLICK HERE TO VIEW THE CODE
<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="pointed ears">
<gameid>449f72a5-219a-4229-b247-496b3d652b1b</gameid>
<version>1.0</version>
<firstpublished>2017</firstpublished>
<start type="script">
msg ("Enter Pointy.")
get input {
result = (LCase(result))
if (result = "pointy") {
msg ("Yay, you entered \"" + result + "\".")
}
else {
msg ("Boo! You entered \"" + result + "\".")
}
player.pointy = true
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<description><![CDATA[{if player.pointy: pointy}<br/>]]></description>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>
this text is added to meet the character requirement when editing a post
The Pixie
25 Jul 2017, 07:07RH's first bit of code is great, the second...
You need both curved brackets, (
and )
and curly, {
and}
. The general format is the script command, followed by the parameters that it will use to decide what to do in curved brackets, followed by the code block that it will subsequently run in curly brackets:
script command ( control parameters) {
code block
}
So in this case:
if (player.pointy) {
msg("The ears are pointy
}
You also need curly brackets with LCase
, so that could mean two lots:
if (LCase(player.ears) = "pointed") {
msg("The ears are pointy
}

Richard Headkid
25 Jul 2017, 09:31Yep.
The general format is the script command, followed by the parameters that it will use to decide what to do in curved brackets, followed by the code block that it will subsequently run in curly brackets
This is how I do it as well. (Pixie taught me last week!)
Using the curly braces { }
shortcuts in the GUI's text processor input field is ... not very dependable, to say the least. I think Pixie said it couldn't handle things that are too complicated... may have been HK or someone else... my old mind is failing me...
But yes, I use Pixie's format. It's easier to read and easier to find flaws.
For instance, I think I always have to use LCase
up front to create a variable because I was trying to do this:
if (LCase(player.ears)) = "pointed") {
msg ("The ears are pointy.")
}
See how I have my apostrophes/curved brackets: (LCase(player.ears)) = "pointed")
?
Well, my extra )
behind player.ears
is apparently what's been defeating me this whole time!
See, I just put this line directly after getting the input:
player.ears = LCase(result)
So, from there on out, I didn't have to struggle with syntax when using LCase
.
That, my friends, is what they call: a dirty hack.
NOTE: One thing I do to test when things like this aren't working is add the msg
command just after getting the input.
Example:
msg ("Type something and press ENTER! HURRY!")
get input {
msg (result) //<-- THIS LINE FOR TESTING!
player.ears = (LCase(result)) //THIS LINE SAVES THE ATTRIBUTE
msg (player.ears) //<-- THIS LINE FOR TESTING!
}
When those two lines print out, that's when I usually start saying what some people may refer to as 'bad words', but, then I dive into the documents at <a style="color:white" href="http://docs.textadventures.co.uk/quest/ "http://docs.textadventures.co.uk/quest/">http://docs.textadventures.co.uk/quest/ "http://docs.textadventures.co.uk/quest/. If that doesn't help, I come right here. Eventually, someone straightens me out, and I'm off to create the next bug in the game!
The Pixie
25 Jul 2017, 09:37Sorry, I misunderstood. RH has pointed out you are using the text process. Which I should have realised...
The if
directive will not work with functions, so basically that will not work.
You can use either
(as of 5.7), which treats the condition as standard code (so strings need quotes, which can be an issue if you do this in code, rather than a text box).
You have{either LCase(player.ears)="pointed": pointy} ears.

Richard Headkid
25 Jul 2017, 09:47You can use either (as of 5.7), which treats the condition as standard code (so strings need quotes, which can be an issue if you do this in code, rather than a text box).
You have{either LCase(player.ears)="pointed": pointy} ears.
Shut the FRONT DOOR! Can I do that with msg ("You have {either LCase(player.ears)=\"pointed\":pointy} ears.")
?
The Pixie
25 Jul 2017, 10:04Yes.
hegemonkhan
25 Jul 2017, 10:39(filler for getting edited post updated)
(filler for getting edited post updated again)
(filler for getting edited post updated again2)
as has been stated, the text processor commands, are the easiest and quickest way to do basic text/string scripting, but they can't handle the full usage of scripting. So, you need to use the normal scripting for doing this stuff (you can then use the text processor commands once you got it into something that they can use from the normal scripting, as Pixie and Richard have shown above).
since, they covered most of this stuff already, let me cover the normal scripting, so you can see an example of how to use it, as I don't think that's been covered by Richard and Pixie in their posts above.
(String/text) Concatenation (literally putting strings together):
math addition:
5 + 5 = 10
55 + 55 = 110
vs
String/text Concatenation:
"5" + "5" = "55"
"55" + "55" = "5555"
"mama" + "mia" = "mamamia"
"mama" + " " + "mia" = "mama mia"
"mama" + "5" = "mama5"
"mama" + " " + "5" + " " + "mia" = "mama 5 mia"
using concatenation in normal scripting, an example:
msg ("Name?")
get input {
if (LCase (result) = "hk") {
string_variable = UCase (result) + " is an awesome person!"
} else {
string_variable = LCase (result) + " is an alright person."
}
string_variable = string_variable + " (This is a simple example of concatenation)"
msg (string_variable)
}
// output:
// if input = "hk", "hK", "Hk", or "HK": HK is an awesome person. (This is a simple example of concatenation)
// if not input = "hk", "hK", "Hk", or "HK": [input] is an alright person. (This is a simple example of concatenation)
we can make this as deep layered as want:
msg ("Name?")
get input {
string_variable = result
msg ("Sex?")
get input {
string_variable = string_variable + " is a " + result
msg ("Age?")
get input {
string_variable = string_variable + " " + result + " year old "
msg ("Race?")
get input {
string_variable = string_variable + result
msg ("Class?")
get input {
string_variable = string_variable + " " + result + "."
msg (string_variable)
// for showing use of this normal scripting and concatenation, with the text process commands:
game.my_string = string_variable
msg ("Welcome to my game, I hope you enjoy it! Here's your character that you created: {game.my_string} Now, let's begin the game!")
}
}
}
}
}
// (Name: "HK")
// (Sex: "male")
// (Age: "18") // I wish I was 18 still
// (Race: "human")
// (Class: "warrior")
// output for these inputs above: HK is a male 18 year old human warrior.
// output for the last part showing normal scripting and concatenation, used with the text processor commands:
Welcome to my game, I hope you enjoy it! Here's your character that you created: HK is a male 18 year old human warrior. Now, let's begin the game!
JenniferKline
26 Jul 2017, 20:50Whelp, this was above and beyond what I expected. Needless to say that I'm pretty much solid on the issue now. Time to post another question!