Hide Command and Collections
JonathanD
30 Mar 2004, 01:26Hey, folks. Just trying out Quest. I like it a lot.
For some reason, I cannot get the Hide command to work correctly for me. Or, perhaps it's working correctly, and I'm just assuming it is supposed to function differently.
I have a start room, and an apple object. I created a food object type, with Edible and Nourishment properties. I also assigned an 'eat' action to the food object type. Then I gave the apple object the food object type. The 'eat' action of the food object type calls an ActionEat procedure. I also created a custom player command called 'eat'. When the player types 'eat <object>', the command calls the eat action of #quest.lastobject#, assuming an eat action exists for #quest.lastobject#. (This is checked via a conditional.) The eat action in turn calls the ActionEat procedure.
The ActionEat procedure uses #quest.lastobject# as well. It checks to see if the player is in possession of #quest.lastobject#. If not, it informs the player that they do not have that item to eat. If the player does possess the item, it checks to see if the item has the Edible property. If the item does not have this property, it informs the player that the item is not edible. If the item does have the Edible property, the player is informed that they have eaten the item. I then attempt to destroy the item by using the Hide Command. This is where I get confused.
The apple does not disappear. I can eat it multiple times. If I drop it after I eat it, it disappears, but I can still interact with it: pick it up, eat it, drop it again, ad infinitum. Anyone have any advice?
----------------
I was also wondering if it is possible to assess a group of objects, such as all of the objects within a room. Is it possible to cycle through only specific types? For instance, is there a way to create a GetFirstObjectInRoom function, and a GetNextObjectInRoom function, and a GetNumOfObjectsInRoom function? Could these be given parameters of object types, such as 'people', 'food', 'clothing', etc? I think these are called Collections, but I am a little rusty on my programming.
Thanks in advance for any replies.
For some reason, I cannot get the Hide command to work correctly for me. Or, perhaps it's working correctly, and I'm just assuming it is supposed to function differently.
I have a start room, and an apple object. I created a food object type, with Edible and Nourishment properties. I also assigned an 'eat' action to the food object type. Then I gave the apple object the food object type. The 'eat' action of the food object type calls an ActionEat procedure. I also created a custom player command called 'eat'. When the player types 'eat <object>', the command calls the eat action of #quest.lastobject#, assuming an eat action exists for #quest.lastobject#. (This is checked via a conditional.) The eat action in turn calls the ActionEat procedure.
The ActionEat procedure uses #quest.lastobject# as well. It checks to see if the player is in possession of #quest.lastobject#. If not, it informs the player that they do not have that item to eat. If the player does possess the item, it checks to see if the item has the Edible property. If the item does not have this property, it informs the player that the item is not edible. If the item does have the Edible property, the player is informed that they have eaten the item. I then attempt to destroy the item by using the Hide Command. This is where I get confused.
The apple does not disappear. I can eat it multiple times. If I drop it after I eat it, it disappears, but I can still interact with it: pick it up, eat it, drop it again, ad infinitum. Anyone have any advice?
----------------
I was also wondering if it is possible to assess a group of objects, such as all of the objects within a room. Is it possible to cycle through only specific types? For instance, is there a way to create a GetFirstObjectInRoom function, and a GetNextObjectInRoom function, and a GetNumOfObjectsInRoom function? Could these be given parameters of object types, such as 'people', 'food', 'clothing', etc? I think these are called Collections, but I am a little rusty on my programming.
Thanks in advance for any replies.
Anonymous
30 Mar 2004, 19:47I think you should look in the manual the difference between conceal and hide.
For removing an object from the player, you can use
lose <object>
conceal <object>
For removing an object from the player, you can use
lose <object>
conceal <object>
Anonymous
30 Mar 2004, 19:55About your second question, maybe this part of a code can help you :
for each object in <Home> {
if property <#quest.thing#; onTable> then {
msg <On the table there is |xn>
msg <a #quest.thing#.>
JonathanD
30 Mar 2004, 21:54Farvard:
lose <object>
Takes the specified object away from the player, if it is in their inventory, and puts it in the current room. If you want to take the object from the player and don't want it put in the current room, use hide instead.
That's from the manual. So too is the following:
hide <object name>
Hides the specified object so it does not appear and does not interact with the player.
But I'll try your method, and see what happens.
Guest:
For each... nice. I'll give that a spin. Thank you.
lose <object>
Takes the specified object away from the player, if it is in their inventory, and puts it in the current room. If you want to take the object from the player and don't want it put in the current room, use hide instead.
That's from the manual. So too is the following:
hide <object name>
Hides the specified object so it does not appear and does not interact with the player.
But I'll try your method, and see what happens.
Guest:
For each... nice. I'll give that a spin. Thank you.
JonathanD
31 Mar 2004, 12:24Well, the Hide Command problem really got to bugging me. For all intents and purposes, the behaviour I was seeing was too much like conceal for me to cry coincidence. Here's the gist:
It turns out that while the ASL reference uses the command word Hide for the behaviour I am seeking, the QDK does not. I was developing exclusively in QDK, and so did not see the discrepancy. Using the Hide an object command in QDK generates an ASL Conceal statement. Therein lies the confusion. Using the Make an object inaccesible command in QDK generates an ASL Hide statement. Thanks, Farvard, for hinting me in the right direction.
I hope this helps anyone else in the future who bumbles across the same frustration. With this cleaned up, and with the For Each functionality, Quest looks like a sure buy.
It turns out that while the ASL reference uses the command word Hide for the behaviour I am seeking, the QDK does not. I was developing exclusively in QDK, and so did not see the discrepancy. Using the Hide an object command in QDK generates an ASL Conceal statement. Therein lies the confusion. Using the Make an object inaccesible command in QDK generates an ASL Hide statement. Thanks, Farvard, for hinting me in the right direction.
I hope this helps anyone else in the future who bumbles across the same frustration. With this cleaned up, and with the For Each functionality, Quest looks like a sure buy.
Anonymous
31 Mar 2004, 19:42... I think the conceal function worked correctly for me, but maybe some bugs are lying around because of this...
To be honest, I often mix up the 2 functions because of their label. I can see now that in my game I used the "conceal" function as well. Sometimes I often used also a
property <object; not takeable>
in order to be sure the player can't pick it again...
And did you managed to do something with the second part of my code ? (about parsing multiple objects)
To be honest, I often mix up the 2 functions because of their label. I can see now that in my game I used the "conceal" function as well. Sometimes I often used also a
property <object; not takeable>
in order to be sure the player can't pick it again...
And did you managed to do something with the second part of my code ? (about parsing multiple objects)
JonathanD
02 Apr 2004, 03:08Farvard - you're also Guest?
I haven't tried using the For Each loop yet. I will soon, though. Did you offer this up as a theoretical afterthought, or have you actually used this in ASL? I ask this because I didn't see anything in the ASL documentation about For Each.
I haven't tried using the For Each loop yet. I will soon, though. Did you offer this up as a theoretical afterthought, or have you actually used this in ASL? I ask this because I didn't see anything in the ASL documentation about For Each.
Anonymous
02 Apr 2004, 19:02
Farvard - you're also Guest?
yes, I didnt log in with my usual name (like right now btw) and the second time forgot to write anything.
I'm using this piece of code in my game, and it's working, so you can try to use a similar code for what you achieve.
I can't find it again on this forum, but I think it's Alex who gave me those tips.