Trapping LookIn

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

Trapping LookIn

Post by Bainespal »

The LookIn action probably presupposes a container object with nested children. The DoLookIn routine in verblib.h supports this.

I'm just trying to catch this action on a scenery window that is not a container, and I'm having more trouble than I would have thought. A simple before property on the window object won't work; when the game is run, trying to look in the window produces the text "You can't do that with (the window)." The same happens when using the before of the room. Using react_before on the window object has strange results; without an "else" condition telling it to return false for other verbs, it freezes the whole room. It still won't work with the else condition, either.

Trapping LookThrough for the same window object worked as expected. I guess it's not a big deal for the default error message to be displayed when the player tries to look in the windows, but if anyone knows a way to work with DoLookIn on an object that's not container, I'd give it a try.

Thanks, as always. If I do write a Hugo game eventually, it'll be because of this forum. :-)

User avatar
Ice Cream Jonsey
Posts: 28923
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Post by Ice Cream Jonsey »

Okay, we are discussing this in the Hugo Love Bus *right now*

I have found that my ability to debug anything is awful at the moment, but I am not quite ready to ask for source code yet, Bainspiel!
the dark and gritty...Ice Cream Jonsey!

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

Post by Roody_Yogurt »

I think you can basically do two things-

1) declare this grammar line before verblib.g is included:

Code: Select all

verb "look", "l", "examine", "x", "watch"
* "in"/"inside" object		DoLookIn
The downside of that is that every object can be used with "LOOK IN" now, and you may have to replace DoLookIn with something with a little extra code to give a decent answer to those other cases.

2) The other route, of course, is to just make the window a container and then disallow all of the stupid container things an evil player might try to do with it.

There isn't really a correct answer with that.

There is a third* possibility, too, where you put something in PreParse that specifically looks for every variation of >LOOK IN WINDOW and then point it to the routine you want, but that method would be dumb.

Anyhow, yeah, it's always rough when the default grammar conflicts with what you want to do (since changing the grammar seems weird), but changing it is what you have to do. Er, unless you don't.

* There are most likely more than three possibilities.

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

Post by Roody_Yogurt »

Also, you can always get an answer on here within the day or two it takes for us to notice it (and it is nice for all of the MILLIONS of future Hugo authors who get to see the answer), but if you ever need a quicker answer, hop on to the ifMUD where I most likely am.

User avatar
Ice Cream Jonsey
Posts: 28923
Joined: Sat Apr 27, 2002 2:44 pm
Location: Colorado
Contact:

Post by Ice Cream Jonsey »

The ifMud is sometimes described as the Hugo Love Bus, iirc
the dark and gritty...Ice Cream Jonsey!

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

Post by Bainespal »

Thanks for the advice. There really is no satisfying solution, I guess. I'll postpone the decision as to whether to do one of those work-arounds until after I'm done implementing the whole game.
Roody_Yogurt wrote:Also, you can always get an answer on here within the day or two it takes for us to notice it (and it is nice for all of the MILLIONS of future Hugo authors who get to see the answer), but if you ever need a quicker answer, hop on to the ifMUD where I most likely am.
I made a character on the ifMUD a while ago... I wanted to attend the XYZZY awards, but I couldn't find them. I should logging in from time to time. It's a good thing that Hugo is being discussed there more than it is here, although it is good to know that my topics here will stand as a monument for future generations. ;-)

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

Post by Roody_Yogurt »

Ok, let's try to tempt you with a couple more options.

1) You could use the window class object from Kent Tessman's Future Boy! source. It goes the window-is-a-container route but has the advantage of someone-having already written the code for you:

Code: Select all

scenery window_object	! base class for (physical) windows
{
	is container
	is transparent
	react_before
	{
		if verbroutine = &DoJump and not object and location is inside
		{
			"Surely you don't mean out the window."
		}
		else
			return false
	}
	before
	{
		object DoJumpOff
		{
			Perform(&DoGo, self)
		}
		object DoLookIn
		{
			Perform(&DoLookThrough, self)
		}
		object DoLookThrough
		{
			"Perhaps your voyeuristic side can wait for another time."
		}
		xobject DoPutIn
		{
			Perform(&DoThrowThrough, object, self)
		}
		object DoHit
		{
			"Have a bit of the vandal in you, do you?"
		}
		xobject DoThrowThrough
		{
			"Wouldn't seem to be a big point to that, really."
		}
		xobject DoLoop
		{
			! >PUT X THROUGH Y grammar gets us here
			Perform(&DoThrowThrough, object, self)
		}
		object DoPush, DoPull
		{
			if self is openable
			{
				if self is open
					Perform(&DoClose, self)
				else
					Perform(&DoOpen, self)
				return true
			}
			return false
		}
	}
}
Go look here if you want more info on object classes.

2) Instead of my previous grammar suggestion, add the following before verblib.g is included:

Code: Select all

verb "look", "l", "examine", "x", "watch"
* "in"/"inside" (objectname)      DoLookIn
 
The downside to that is that you'll have to add that line for every instance of windows in your game, but hey, if you have just one window...

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

Post by Bainespal »

Roody_Yogurt wrote:2) Instead of my previous grammar suggestion, add the following before verblib.g is included:
Code:

verb "look", "l", "examine", "x", "watch"
* "in"/"inside" (objectname) DoLookIn


The downside to that is that you'll have to add that line for every instance of windows in your game, but hey, if you have just one window...
I do have just one window.... that's the perfect solution! :)

Thank you.

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

Post by Roody_Yogurt »

Glad to hear it! (I need to get around to writing a page about grammar tokens for HxE)

Post Reply