Page 1 of 1

Name property

Posted: Sat May 21, 2011 7:24 am
by Bainespal
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. :-)

Posted: Sat May 21, 2011 5:16 pm
by Roody_Yogurt
I'd have to see the code. It sounds like something is wrong, yeah.

Posted: Sun May 22, 2011 1:56 pm
by Roody not logged in
Thought I'd code this up just for kicks:

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
}
There are probably better ways to do it.

Posted: Mon May 23, 2011 1:13 pm
by Roody still not logged in
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.

Posted: Thu May 26, 2011 3:24 pm
by Bainespal
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! :-\