Axe Software Forums
  Quest Developer Forum
  Question regarding Al's q3ext library===>


Author Topic:   Question regarding Al's q3ext library===>
Mega posted 30-10-2001 21:40 GMT     
I decided to try out the new "container" object type. However, I soon found that it wasn't complete. Although it does store one object inside another, it doesn't allow for manipulation of the container's contents.
Say, for example, you were in the same room as a "bag" object, and the bag had as its contents a "coin". Because the bag's contents need their own room (bag_inventory), Quest thinks that the coin is in a completely different room than you. So typing "take coin", "look at coin", etc. results in "I don't see that here." In fact, a list of the bag's contents aren't even displayed anywhere; looking at the bag simply prints the bag's description. Therefore, you have to write your own code to display the contents, to look at each item in the bag, to take each item, etc., each time you make a new container object. This really defeats the whole idea of having a nice, convenient Container type in the first place.
Computer Whizz posted 30-10-2001 23:54 GMT          
Think logically!

What do you do to see inside a bag? You don't walk into a room and IMMEDIATLY know what is inside the bag, nor do you SEE what is in the bag..... what do you do?

Look in bag

then to use things inside, the things are STILL in the bag. So when you want to get the money, the money isn't inside the ROOM, nor is it IMMEDIATLY accessable.... you have to:

get money from bag

to look at it you'd have to effectivly get it, then look at it - but I suppose you could put:

look in bag at coin

just wondering if these work - if not I suggest that this would be nice for the library!

Computer Whizz

MaDbRiT posted 31-10-2001 11:31 GMT          
Mega - it sounds like you are not using my library properly, it certainly DOES provide most of the obvious functions of a container without having to write any extra code!

Here's a bit of game output, the bag is a container set up as per my instructions...

quote:

> examine locker
The heavy locker door hangs open on badly worn hinges.
It contains a pair of panties, a bra, a pair of jeans, a T-Shirt, a pair of shoes, a pair of socks, a skirt, a pair of tights, a dress, a jacket, a pair of gloves, a hat and a Mystique Boutique carrier bag.

> take bag
You take the bag out of the locker.

> x bag
The bag is huge, a girl could put all her unworn clothes in it.


> take gloves
You take the gloves out of the locker.

> put gloves in bag
You put the gloves in the bag.

> look at bag
The bag is huge, a girl could put all her unworn clothes in it.

> examine bag
The bag is huge, a girl could put all her unworn clothes in it.
Currently it contains a pair of gloves.

> drop bag
You drop it.

> take gloves
You take the gloves out of the bag.


While I agree 'look at' doesn't list contents, that's because I deliberately set it up that way - 'look' being a casual once over, 'examine' being used to give a more detailed examination that shows the contents. If you want a 'look' to show the contents - just set up an override command and force use of examine instead - it's quite simple.

As you can see, manipulating objects (here the gloves) by putting them in the bag and taking them out etc is all dealt with quite automatically, so I don't really understand your comments.

Obviously the library cannot deal with EVERY eventuality, but it does provide useful default behaviour to use 'as is' or develop for more sophisticated contianer objects.

Al

MaDbRiT posted 31-10-2001 11:36 GMT          
Oh yes.. obviously the locker is also a container object in the above extract.

Without ANY extra code, you can manipulate ALL the objects in the locker, it's contents list etc are all automatically managed.

Obviously I have no idea what you are trying to do with the code so I can't comment on why you seem to be having trouble with it.

Al

Mega posted 31-10-2001 17:36 GMT          
You're right, my apologies. The problem seems to be conflicts with the various procedures. Basically, in order to do verb synonyms ("look at ball" and "look ball" doing the same thing) I wrote several procedures, one for each of the common verbs (look, go, get, open, close, etc), and one last procedure called "miscproc" for any leftover or unusual verbs. That's worked great so far, until I tried the Container class. Because it has special code for "examine" that's different from "look", it screws something up in my code. Depending on what I've changed in my debugging, "examine bag" either tells me 'I don't see that here' or prints the normal "look" description without listing the contents. Here's all the code from my game that is relevant to the problem.
'--------------------------------------------
'in game definiton block:
command <look at #verbtarget#> do <lookproc>
command <look #verbtarget#> do <lookproc>
command <look> exec <look;normal>
command <examine #verbtarget#> do <examineproc>
command <#miscverb# at #verbtarget#> do <miscproc>
command <#miscverb# to #verbtarget#> do <miscproc>
command <#miscverb# on #verbtarget#> do <miscproc>
command <#miscverb# in #verbtarget#> do <miscproc>
command <#miscverb# with #verbtarget#> do <miscproc>
command <#miscverb# #verbtarget#> do <miscproc>

...................................

define room <southeast courtyard>
alias <castle courtyard>
north <east courtyard>
west <south courtyard>
description msg <You are standing by the southeast tower of Mordrok's castle.>

define object <castle8>
alias <castle>
type <scenery>
action <look> msg <The southeast tower looks just like the other three: evil, dark, and scary.>
end define

define object <skeleton>
properties <buried>
action <look> {
if property <skeleton; buried> then {
msg <The skeleton looks to be many years old. It is half-buried in _
dirt, so you cannot see much of it.>
}
else {
msg <The skeleton lies on the ground, twisted into a grotesque position. You _
cannot imagine what might have killed this poor soul, but it must not have been _
pleasant.|n|nThere is a small handbag clutched in the skeleton's hand.>
}
}
action <uncover> doaction <dirt; clear>
action <unbury> doaction <dirt; clear>
end define

define object <dirt>
invisible
action <look> msg <The dirt is partially covering the skeleton.>
action <clear> {
if property <skeleton; buried> then {
msg <You kneel on the ground and, cupping your hands, clear the dirt off the old _
bones.>
hide <dirt>
show <handbag>
property <skeleton; not buried>
}
else msg <The skeleton is already unburied.>
}
action <move> doaction <dirt; clear>
end define

define object <handbag>
hidden
type <container>
action <look> msg <It's a small, leather handbag.>
action <take> msg <Even in death, the skeleton does not seem to want to let go of the _
handbag. You can't pry it loose from the bony fingers.>

end define

end define

define room <handbag_inventory>
prefix <The handbag contains >

define object <hairpin>
take
look <It's a small wire hairpin.>
end define

end define

'relevant procedures:

define procedure <lookproc>
if ( #resolved# = ) then {
set <resthing; $resolve$>
if ( #resolved# = ) then msg <I can't see that here.> else {
if not action <#resthing#;look> then {
exec <look at #resthing#; normal>
set string <resolved;>
}
else {
doaction <#resthing#;look>
set string <resolved;>
}
}
}
end define

define procedure <examineproc>
if ( #resolved# = ) then {
set <resthing; $resolve$>
if ( #resolved# = ) then msg <I can't see that here.> else {
if not action <#resthing#;examine> then {
exec <examine #resthing#; normal>
set string <resolved;>
}
else {
doaction <#resthing#;examine>
set string <resolved;>
}
}
}
end define

define procedure <miscproc>
if ( #resolved# = ) then {
set <resthing; $resolve$>
if ( #resolved# = ) then msg <I can't see that here.> else {
if action <#resthing#;#miscverb#> then {
doaction <#resthing#;#miscverb#>
set string <resolved;>
}
else {
'msg <I don't understand your command.>
exec <#miscverb# #resthing#; normal>
set string <resolved;>
}
}
}
end define

'And finally, the Resolve function:

define function <resolve>
set <resolved;>
for each object in <#quest.currentroom#> {
if exists <#quest.thing#> then {
set string <display;$displayname(#quest.thing#)$>
set <display; $lcase(#display#)$>
if ( $instr(#display#;#verbtarget#)$ > 0 ) or ( $instr(#quest.thing#;#verbtarget#)$ > 0 ) then set <resolved;#quest.thing#>
}
}
for each object in <inventory> {
if exists <#quest.thing#> then {
set string <display;$displayname(#quest.thing#)$>
set <display; $lcase(#display#)$>
if ( $instr(#display#;#verbtarget#)$ > 0 ) or ( $instr(#quest.thing#;#verbtarget#)$ > 0 ) then set <resolved;#quest.thing#>
}
}
return <#resolved#>
end define


'-------------------------------------------
If I turn off the commands at the top that call miscproc, then examine works correctly, but "clear dirt" does not. And vice versa.

Sorry for such a long code snippet :-)

MaDbRiT posted 31-10-2001 21:07 GMT          
Hi Mega..

Well I looked through your code briefly, and although I've not actually tested it, I'm sure the problem lies with the fact you are adding 'look' and 'examine' routines that effectively replace those my library adds - this means mine won't ever get called of course, which makes the library code sort of redundant!

If you want to have your routines 'pre-parse' the input before passing the results to my library so that containers get dealt with, I think that rather than call exec <look;normal> etc. you need to experiment with calling my library's procedures instead.

I'm probably missing the point, but why are you writing code to handle 'look at' and 'examine' at all? Is there something in Quest's default way of dealing with these that doesn't work for you? My library obviously has to 'tweak' these because of the requirements of containers and clothes, I presume there is some conflicting requirement in your game?

Al

MaDbRiT posted 31-10-2001 21:19 GMT          
Hmmm...

It occurs to me that my library could (and probably should) automatically deal with the 'look at ball / look ball' issue, I deal with it in my external ASL code at present, but it would be a doddle to make q3ext.qlb deal with this internally.

One for the 'fix' list for the next release - LOL.

Al

Mega - if I tweak the lib to sort the 'look at ball/ look ball' issue, would you like to test drive it and see if it helps you?

Mega posted 31-10-2001 21:36 GMT          
Absolutely! Writing all those procedures gets annoying REAL fast :-)

Of course, it can't JUST be 'look/look at'. We also need 'go/go to', 'sit/sit on', and any other miscellaneous verb that might need an extra word tacked on. And also, the 'look' verb actually has THREE parts: 'look at something', 'look something', and just 'look' on its own.
But if you can figure out how to do this stuff, I'd be glad to test it for you! :-)

MaDbRiT posted 01-11-2001 07:36 GMT          
quote:
Of course, it can't JUST be 'look/look at'. We also need 'go/go to', 'sit/sit on', and any other miscellaneous verb that might need an extra word tacked on. And also, the 'look' verb actually has THREE parts: 'look at something', 'look something', and just 'look' on its own.
But if you can figure out how to do this stuff, I'd be glad to test it for you! :-)

Yes I did 'get' that part of the equation...

I'm likely just to deal with all the things my library uses, so that there's no need to modify / amend code that might cause problems to it, but obviously the same principle can be extended to deal with the other areas.

My lib should deal with look/ look at (etc) ALL objects in the game that you want handled normally. i.e. there should be no need to write specific look /look at commands for any objects except those you want handled differently from normal.

The trick here is that my lib provides default 'catch all' functionality, if you want to add a specific handling routine you have to put it a lib and include that AHEAD of the lib so that Quest checks your specific before dropping through to my 'catch all' code.

Al

Mega posted 01-11-2001 19:41 GMT          
No no, that's not what I meant. For the most part, I won't need specialized look/get/go functions. What I want is simply for the compiler to recognize 'look object' and 'look at object' as the same command (and different from simply 'look'), 'go place' and 'go to place' as the same command, etc, and then to execute that command as it normally would.
MaDbRiT posted 04-11-2001 09:56 GMT          
quote:
that's not what I meant. For the most part, I won't need specialized look/get/go functions. What I want is simply for the compiler to recognize 'look object' and 'look at object' as the same command (and different from simply 'look'), 'go place' and 'go to place' as the same command, etc, and then to execute that command as it normally would.

As of release 5 of my library - I have added the required tweaks to do exactly the above. You can now expect look object, look at object, look at the object even look the object to work 'normally' - that is as my library would funtion with "look at object". I have also tweaked 'examine" a bit ('look inside of' now equating to examine and so on) and the 'go /go to' - though strictly speaking that last one has nothing to do with my library at all :-)

Hope this helps...

Al

MaDbRiT posted 04-11-2001 10:03 GMT          
Oh yeah...

Because my lib doesn't deal with sitting on things - I'd rather not have it pre-guess how others would want to deal with coding the commands to deal with those possibilities.

However I have e-mailed you an example of how I'd code a command and set of synonyms to deal with the possibles in sit/ sit in /sit on etc.

Al