Name property

This is a discussion / support forum for the Hugo programming language by Kent Tessman. Hugo is a powerful programming language for making text games / interactive fiction with multimedia support.

Hugo download links: https://www.generalcoffee.com/hugo
Roody Yogurt's Hugo Blog: https://notdeadhugo.blogspot.com
The Hugor interpreter by RealNC: http://ifwiki.org/index.php/Hugor

Moderators: Ice Cream Jonsey, joltcountry

Bainespal
Posts: 151
Joined: Fri Jul 09, 2010 8:59 am

Name property

Post 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. :-)

Roody_Yogurt
Posts: 2179
Joined: Mon Apr 29, 2002 6:23 pm
Location: Milwaukee

Post by Roody_Yogurt »

I'd have to see the code. It sounds like something is wrong, yeah.

Roody not logged in

Post 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.

Roody still not logged in

Post 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.

Bainespal
Posts: 151
Joined: Fri Jul 09, 2010 8:59 am

Post 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! :-\

Post Reply