Using alt names in game responses

steve the gaming guy
19 Jul 2005, 20:48
As always, I read over the Quest Help section and have come to some close conclusions but what I am looking for specifically does not seem to be in there.

Let's say you have an object called "box" and it's alt names are "red box, wooden box, old box, box of pencils, pencils"

If the player says "take pencils", I want Quest to say, "You don't need the pencils"
Or if command "take box of pencils", "You don't need the box of pencils."

And so on.

I'm using QDK and what I was doing was going into the Take tab and just saying print message "You don't need the #object#" but naturally, that does not work.
I was thinking maybe I have to set the variable "object" as whatever alt name the player decides to use and then printing the return message.

Do you understand what I'm saying and is it possible?

MaDbRiT
19 Jul 2005, 21:11
Steve

There's no way to read an ALT name to make a decision based on it, but why not just use this for the box's 'take' tag.

take {
if ($instr(#quest.command#;box)$>0) then msg <You don't need the box of pencils.>
else msg <You don't need the pencils.>
}


That way if the player mentions 'box' in his take command, it'll respond with

"You don't need the box of pencils."

if he doesn't mention the box he'll get

"You don't need the pencils."

That do it?

Al (MaDbRiT)

paul_one
19 Jul 2005, 22:28
You could also use the #quest.originalcommand# variable (correct?). I know #quest.command# is valid, but I think the alt names are replaced in #quest.command#, while #quest.originalcommand# is what is inputted by the player.

ANYWAY, use the $mid(5;#quest.originalcommand#)$ and you should have a string returned that is all that the player inputs AFTER 5 characters.

Of course, if you have multi-input support (#command1#,#command2#) then I think that may screw it up... So some other parsing would be in order (checking to see if it had an ',' I suppose) and then using:
$mid(5;%length%;#quest.originalcommand#)$
NOTE: Not sure on this... I might be wrong and #quest.originalcommand# get's over-written by the multi-command that I have previously given out as an example.

... Just incase you have other objects which don't have a common word like Al suggested, etc.
I personally would just refer to the whole object, seeing as how the display name is (I presume) 'box of pencils'?

MaDbRiT
20 Jul 2005, 22:30
Tron wrote;

You could also use the #quest.originalcommand# variable (correct?). I know #quest.command# is valid, but I think the alt names are replaced in #quest.command#, while #quest.originalcommand# is what is inputted by the player.



Logically speaking, you ought to be right there Tron, but in my experience, the alt names are not replaced in #quest.command# the way synonyms are - so #quest.command# & #quest.originalcommand# seem to be identical in this scenario :shock:

ANYWAY, use the $mid(5;#quest.originalcommand#)$ and you should have a string returned that is all that the player inputs AFTER 5 characters.



Yes indeedy, I can't argue with that!

Of course, if you have multi-input support (#command1#,#command2#) then I think that may screw it up... So some other parsing would be in order (checking to see if it had an ',' I suppose) and then using:
$mid(5;%length%;#quest.originalcommand#)$



A minor problem here would be if the player had typed "take the pencils" rather than "take pencils".

$mid(5;#quest.originalcommand#)$ would return 'the pencils' instead of just 'pencils', so

msg <You take the $mid(5;#quest.originalcommand#)$.>


could display the delightful;

"You take the the pencils"

Another little condition test would sort it out, but you see what I mean I'm sure. :lol:

I don't know if you've tried your way of doing multiple commands on one line extensively, but I suspect it isn't going to work reliably with the (very likely) usage of 'it' in the second part of the command. e.g.

>Take the book and examine it

Will I think (sometimes) generate:

You take the book.
I don't know what 'it' you are referring to.


If you look at the book first I suspect it WILL work... something like

>Look at the book
It is a heavy, bound volume.

>Take the book and examine it
You take the book
It seems to be written in a language you don't recognise.


What I think will cause a problem is that 'it' seems to be set to the object referenced in the last command completed, and in the second example above, the LOOK is what sets it=book, so that the "Take the book and examine it" will work. Wthout this prior 'look', I think the 'it' will refer to whatever object was referred to in the previous command (or be undefined if no object was mentioned) and not the book.

Essentially I think the 'it' is only assigned at the end of a 'player turn' and as the multiple command idea is really just one player turn, 'it' won't be assigned 'book' by the 'take book' first part.

I may well be wrong on this as I've not actually tried it - but its worth checking out I think.

I personally would just refer to the whole object, seeing as how the display name is (I presume) 'box of pencils'?



So would I!

Al (MaDbRiT)

paul_one
21 Jul 2005, 10:11
You are quite correct Al.
I think I will go away, and add that feature in. All I need to do is get the (first) object from the last command and put it into #quest.lastobject#.

Only problem comes from what object they are referring to in multiple -object actions (eg, throw spear at caveman over rock, get it... refering to caveman/spear/rock?). Gonna have to add a choice selector too, so that'll be fun :D .

steve the gaming guy
21 Jul 2005, 15:10
MaDbRiT wrote:Steve

There's no way to read an ALT name to make a decision based on it, but why not just use this for the box's 'take' tag.

take {
if ($instr(#quest.command#;box)$>0) then msg <You don't need the box of pencils.>
else msg <You don't need the pencils.>
}


That way if the player mentions 'box' in his take command, it'll respond with

"You don't need the box of pencils."

if he doesn't mention the box he'll get

"You don't need the pencils."

That do it?

Al (MaDbRiT)



So you are saying there are two choices of responses? So I can't say
-You don't need the box of pencils
-You don't need the pencils
-You don't need the wooden pencils
-You don't need the broken pencils
etc...

It's ok. I just thought it would be a nice little touch. It's not a big deal though.

MaDbRiT
21 Jul 2005, 18:27
Steve wrote

So you are saying there are two choices of responses? So I can't say
-You don't need the box of pencils
-You don't need the pencils
-You don't need the wooden pencils
-You don't need the broken pencils
etc...



No I'm not saying that at all!

I'm saying you can't do it easily , i.e. by reading 'ALT' names - because it doesn't work like that. :lol:

My code snippet shows how you can vary the response to 'take' with a conditional test, I chose to keep it simple and just give a reply mentioning the box if the player does and not mentioning it if he doesn't.

If you want to to code more possibilities, you certainly can elaborate on the test and have pretty much any number of different responses you want - if you have the patience to code them.

It's ok. I just thought it would be a nice little touch. It's not a big deal though.



If you feel its worth the time to implement - go for it!

Al (MaDbRiT)