Adding grammatical sub-features for variables (e.g. plurals, a vs. an)? #780
lulamorashi
started this conversation in
General
Replies: 2 comments 2 replies
-
I'd like to be able to extend this functionality beyond a vs. an to things
like pronouns, e.g. for a character whose gender can variably be "Man",
"Woman", "Non-binary person", the sentence "{Character.they} opened
{character.their} eyes" could print "He opened his eyes"; "She opened her
eyes"; or "They opened their eyes" depending on the variable "gender".
I know how to do this with a very tedious:
{ -gender == "man": He <> -gender == "woman": She <> -else: They <> } <>
opened <> { -gender == "man": his <> -gender == "woman": her <> -else:
their <> } <> eyes.
But obviously this is pretty unsustainable for a long piece! Any tips or
advice
This is a great opportunity for a function:
{They(gender)} opened {their(gender)} eyes.
== function They(gender)
{ gender:
- "man": He
- "woman": She
- else: They
}
=== function their(gender)
{ gender:
- "man": his
- "woman": her
- else: their
}
And if you only have one character whose gender is assignable this way, you
don't even need to pass it as a parameter, so can just write
{They()} opened {their()} eyes.
|
Beta Was this translation helpful? Give feedback.
1 reply
-
You can be really clever here using the string contains string operator ? :
I put {a("cat")} and {a("ape")} into {a("old box")} with {a("elephant")}.
=== function a(x)
~ temp stringWithStartMarker = "^" + x
{ stringWithStartMarker ? "^a" or stringWithStartMarker ? "^A" or
stringWithStartMarker ? "^e" or stringWithStartMarker ? "^E" or
stringWithStartMarker ? "^i" or stringWithStartMarker ? "^I" or
stringWithStartMarker ? "^o" or stringWithStartMarker ? "^O" or
stringWithStartMarker ? "^u" or stringWithStartMarker ? "^U" :
an {x}
- else:
a {x}
}
prints
I put a cat and an ape into an old box with an elephant.
Message ID: ***@***.***>
… |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello! I'm trying to work out how to change the associated words with a variable, e.g. a vs. an.
As an example, if my variable is "job" and this can be set throughout the game as "actor", "builder" or "cartoonist", is there a way that I can make it so that this sentence:
"I am {job.a} {job}."
Can print out:
"I am an actor"; "I am a builder"; "I am a cartoonist" depending on the variable "Job".
I'd like to be able to extend this functionality beyond a vs. an to things like pronouns, e.g. for a character whose gender can variably be "Man", "Woman", "Non-binary person", the sentence "{gender.they} opened {gender.their} eyes" could print "He opened his eyes"; "She opened her eyes"; or "They opened their eyes" depending on the variable "gender".
I know how to do this with a very tedious:
{
-gender == "man": He <>
-gender == "woman": She <>
-else: They <>
}
<> opened <>
{
-gender == "man": his <>
-gender == "woman": her <>
-else: their <>
}
<> eyes.
But obviously this is pretty unsustainable for a long piece! Any tips or advice?
Beta Was this translation helpful? Give feedback.
All reactions