I had a condition in the name property of my NPC that would return a different string depending on whether the NPC had the attribute "special". In the after property routine, I specified an ASK topic that would have the NPC reveal her name, thus changing the name property by giving the NPC the "special" attribute.
Somehow, this code was apparently causing the name property to be displayed after every turn when the NPC was in the location! At least, that's what it looked like. For instance, a wait command would result in something like "young womanTime passes."
I have no idea why the name property was being called every turn. However, when I changed the code to a much more logical solution -- simply changing the value of the name property in the after routine -- everything worked. I'm glad I thought of the better way, but why does putting a condition in the name property produce such bizarre results? Are all name properties called every in their location?
Just a topic for discussion/consideration. :-)
Name property
Moderators: Ice Cream Jonsey, joltcountry
-
- Posts: 2256
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee
Thought I'd code this up just for kicks:
There are probably better ways to do it.
Code: Select all
character girl "girl"
{
article {
if self is special
return false
else
return "the"
}
noun "girl", "sally"
after
{
object DoAsk
{
select xobject
case girlname : {
if self is special
{
"\"I told you my name is Sally.\""
return true
}
else
{
self.name = "Sally"
self is special
"\"My name is Sally.\""
return true
}
}
}
}
in STARTLOCATION
is not transparent
}
object girlname "name"
{
adjective "her"
noun "name"
is known
}
In the example above, of course, you can take out the "is not transparent" line. That's some legacy code from when I was trying to put the girlname object in the girl character since I figured Hugo might understand "ask girl about her name" without any help. It seems that assumption might be wrong, but in any case, it bugged me that the hypothetical player could then do things like >X NAME so I changed it.
Also, I should have made girl a female_character, of course. So yeah.
Also, I should have made girl a female_character, of course. So yeah.
-
- Posts: 151
- Joined: Fri Jul 09, 2010 8:59 am
That code is laid out very similarly to the way my code originally was, but it gives no problems when I compile it in a a test shell. What might be informative would be to add this test character into my game, into the same room, and see if the problem I encountered reoccurs. However, I'm reluctant to do that, because I don't want to mess anything up.
I seem to be able to kill Hugo even when it ordinarily should know what it's doing! :-\
I seem to be able to kill Hugo even when it ordinarily should know what it's doing! :-\