Trapping LookIn
Moderators: Ice Cream Jonsey, joltcountry
-
- Posts: 151
- Joined: Fri Jul 09, 2010 8:59 am
Trapping LookIn
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. :-)
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. :-)
- Ice Cream Jonsey
- Posts: 30184
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact:
-
- Posts: 2256
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee
I think you can basically do two things-
1) declare this grammar line before verblib.g is included:
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.
1) declare this grammar line before verblib.g is included:
Code: Select all
verb "look", "l", "examine", "x", "watch"
* "in"/"inside" object DoLookIn
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.
-
- Posts: 2256
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee
- Ice Cream Jonsey
- Posts: 30184
- Joined: Sat Apr 27, 2002 2:44 pm
- Location: Colorado
- Contact:
-
- Posts: 151
- Joined: Fri Jul 09, 2010 8:59 am
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.
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 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.
-
- Posts: 2256
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee
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:
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:
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...
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
}
}
}
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
-
- Posts: 151
- Joined: Fri Jul 09, 2010 8:59 am
I do have just one window.... that's the perfect solution! :)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...
Thank you.
-
- Posts: 2256
- Joined: Mon Apr 29, 2002 6:23 pm
- Location: Milwaukee