If options in text?

JenniferKline
24 Jun 2017, 13:27

Heya

Just wondering if there's a way to use an If style command in messages. My issue is more trying to call say, player attributes but not necessarily just have the word come up. Like I have player.sex "female" but when I use "you are a {player.sex}" it's going to come up with female rather than say "woman".


hegemonkhan
24 Jun 2017, 14:22

there's the built-in 'gender' and 'article' String Attributes for handling 'he/she/it' and 'him/her/it', and here's the links of it:

http://docs.textadventures.co.uk/quest/attributes/gender.html
http://docs.textadventures.co.uk/quest/attributes/article.html

which is controlled by the built-in 'male' and 'female' (and etc, see link below) Object Types:

http://docs.textadventures.co.uk/quest/elements/object.html (scroll down to the very bottom: object types defined by the core.aslx)

(there's a lot of coding involved, which I don't know, so there's a lot more going on than what I'm just trying to demonstrate and in giving an example of it)

<type name="male">
</type>

<type name="female">
</type>

<object name="joe">
  <inherit name="male" />
</object>

<object name="jane">
  <inherit name="female" />
</object>

// ----------------

msg ("Joe is a {joe.gender}.")
// output: Joe is a he.

msg ("Joe is a {joe.article}.")
// output: Joe is a him.

msg ("Jane is a {jane.gender}.")
// output: Jane is a she.

msg ("Jane is a {jane.article}.")
// output: Jane is a her.

however... I don't think there's any built-in stuff for doing 'man/woman/lady/gentleman/lord/mister/misses/mistress/etc/ma'am/boy/girl' and/or other such/like stuff

and to try to code in the handling of this stuff is very advanced coding... when/how do you tell quest/computer to use 'man' vs 'woman' ??? This is advanced coding stuff, beyond my ability. Alex and co coded in this advanced coding stuff for handling 'he/she/him/her/it' for us, but unless we're good programmers too, we can't program in our own handling for other such stuff (well probably Pixie and the other good programmers here can... but that's not me, lol).

grammer parsing coding, for example (I think this is true for the latin/romantic languages and maybe more languages too):

if name/word ends in an 'o', it's/return: "male"
if name/word ends in an 'a', it's/return: "female"

etc... though trying to code the parsing english grammer... is some complex stuff... lol

how would you tell quest to return "male" for "joe or joel" and "female" for "jane or joelle" for an example ???

well, maybe if you're an English Major and/or linguist, crafting the grammer parsing coding would be easy, lol... meh


so.... the easiest thing to do would to just make additional String Attribute(s) for each of them:

player.sex = "(male/female)"
player.adult_gender = "(man/woman)" // we don't want to use 'gender' as we'd be wiping out the built-in 'gender' that handles for us: he/she/it
player.minor_gender = "(boy/girl)" // we don't want to use 'gender' as we'd be wiping out the built-in 'gender' that handles for us: he/she/it
etc etc etc

an example:

player.alias = "HK"
player.sex = "male"
// player.gender = (quest's built-in coding sets it automatically for you, once you have the 'male' Object Type be an Inherited Attribute of the 'player' Player Object, either via code or through the GUI/Editor's options/controls)
// same as the above for 'player.article'
player.adult_gender = "man"
player.minor_gender = "boy"

msg ("{player.alias} is a {player.sex}. {player.gender} is a {player.adult_gender} and a {player.article}.")
// output example: HK is a male. He is a man and a him.

msg ("{player.alias} is a {player.sex}. {player.gender} is a {player.minor_gender} and a {player.article}.")
// output example: HK is a male. He is a boy and a him.


player.alias = "HK"
player.sex = "female"
// player.gender = (quest's built-in coding sets it automatically for you, once you have the 'female' Object Type be an Inherited Attribute of the 'player' Player Object, either via code or through the GUI/Editor's options/controls)
// same as the above for 'player.article'
player.adult_gender = "woman"
player.minor_gender = "girl"

msg ("{player.alias} is a {player.sex}. {player.gender} is a {player.adult_gender} and a {player.article}.")
// output example: HK is a female. She is a woman and a her.

msg ("{player.alias} is a {player.sex}. {player.gender} is a {player.minor_gender} and a {player.article}.")
// output example: HK is a female. She is a girl and a her.


if you need help with anything, I'll try as best as I can, but I don't really know too much into this built-in handling of this type of stuff as it's probably beyond my ability.


hegemonkhan
24 Jun 2017, 14:32

P.S.

also, in the GUI/Editor (obviously can be done in code too... but this is actually a situation where I know how to do something in the GUI/Editor, but NOT how to do it in code, lol), you got the text boxes for adding a 'prefix' and/or a 'suffix' for a quick way of doing 'woman/female/man/male/boy/girl/etc'


and once you created your own/custom String Attributes:

player.sex = "(male/female)"
player.adult_gender = "(man/woman)"
player.minor_gender = "(boy/girl)"

you can then use them with the 'if' (normal or the text process commands) scripting:

(my example is using the normal scripting, but you can do the same with the text processor commands too)

if (player.sex = "male") {
  msg ("You are a male")
} else if (player.sex = "female") {
  msg ("You are a female")
} else {
  msg ("You are an it")
}

if (player.adult_gender = "man") {
  msg ("You are a man")
} else if (player.adult_gender = "woman") {
  msg ("You are a woman")
} else {
  msg ("You are an it")
}

if (player.minor_gender = "boy") {
  msg ("You are a boy")
} else if (player.minor_gender = "girl") {
  msg ("You are a girl")
} else {
  msg ("You are an it")
}

hegemonkhan
24 Jun 2017, 15:02

here's a link on trying to parse the grammer of human/"natural" languages with computers and/or coding (game making) software like quest:

https://en.wikipedia.org/wiki/Natural_language_processing

YIKES !!!! I got sooooo much more to learn... sighs...


The Pixie
24 Jun 2017, 15:16

Like this:

"You are a {if player.sex=female:woman}{if player.sex<>female:man}."


hegemonkhan
24 Jun 2017, 20:23

wow... was I over-thinking this stuff... laughs. Going straight to trying to craft a parsing system for the human english language, lol


JenniferKline
24 Jun 2017, 23:12

Yep, Pixie got it sorted! Great, thanks! But it's still an interesting read HK.

Another question that just came to my mind: is there a way to embed verbs in text like there is with {Command: Do this}?


The Pixie
25 Jun 2017, 07:37

The command directive just sends the text to the Quest parser, so it will handle verbs too. As long as Quest understands "Do this" when you type at thecommand bar, it can be used as you have.


Doctor Agon
05 Jul 2017, 21:56

Hi, trying to set this up as an alias for the 'object:log', but it doesn't seem to be working

{if log.quantity=1:1 log} {if log.quantity<>1: {log.quantity} logs}

{log.quantity} logs //this works
{if log.quantity=1:1 log} // this works
{if log.quantity=1: {log.quantity} logs} // this works

quantity is an attribute of the object with a maximum of 4.

Basically, I want to be at a location, and you see '1 log' or you see '2 logs'. Taking a log will reduce the figure by 1, you'll only be able to carry one log at a time due to weight. Cloning the object might be the way to go, but not sure about dropping the object at 4 different locations. Or integrating them back together at one place.

Just realised it doesn't print a number in the 'Inventory' or 'Places and Objects' panes.


The Pixie
06 Jul 2017, 07:04

When it displays an alias in the list of objects for a room, Quest does some trickery to be able to display links and verb menus, and I would guess that gets messed up if you put text processor directives in the alias. And as you say, the text processor is not even used for the panes on the right.

Better to change the alias as the number of logs changes (perhaps with a change script).