Here's what I want ot do.
I want to make a suitcase that contains a handle. Therefore, I want the following actions to result in the following reactions:
-player starts out with handle in inventory, and suitcase in the starting location
-when player holds the handle, he does not in fact hold the suitcase but in fact only holds the handle, whereas the suitcase remains in the current room of the player.
-The player cannot walk away from the suitcase while he holds the handle; wherever he goes while holding the handle, the suitcase will follow
-when the player types "get suitcase," the handle disappears as part of the suitcase and can be examined and whatnot but is not referred to in the inventory list (I.E: "you are carrying a suitcase, attached to which is a handle.")
-make the act of opening the suitcase while the suitcase is not in the player's inventory cause the handle to disappear inside the suitcase again.
-make the suitcase unopenable while the suitcase is in the player's inventory.
What code could I use to make this work?
Suitcase
Moderators: Ice Cream Jonsey, joltcountry
-
- Posts: 119
- Joined: Fri Jun 27, 2003 12:10 pm
I'm actually just quickly passing through, but until I get a chance to look at or think about this in more depth, one thing I might suggest is to implement this with a handle object based on the 'attachable' class. The attachable class should look after pulling the suitcase object after you, etc. You will have to write some custom code however to handle things like the opening-prevention, hiding the handle upon picking up the suitcase, etc.
-
- Posts: 1693
- Joined: Tue Jul 08, 2003 12:39 pm
- Location: East Bay, California.
That's what I figured, but I couldn't get the attach code to work. I assume I need to do something in routine init or routine main to "activate" the attachable class? Or is there a third library file I need to include? Or possibly a mutant combination!?!
paidforbythegivedrewbetterblowjobsfundandthelibertyconventionforastupidfreeamerica
-
- Posts: 55
- Joined: Wed May 05, 2004 4:35 am
- Location: Chicago, IL
- Contact:
Re: Suitcase
This is interesting. Please note that I think I found a few discrepancies in the Hugo Manual about attachables. (Check objlib.h if you want to make sure of things.)
So here I have set things up such that if the player moves from any room that is of type newLocation, then a check will be made: (1) do they have the handle in their possession and (2) is the suitcase in the location they moved from.
If so, move the suitecase to the new location that they moved to.
That is just one possible way. (I think. I tried this out and it seems to work for at least up to this level of what you want to do.) Let me try working with the other specifics that you gave.
Okay, so that is simple enough. You can just code the handle object as being in the player object at the start and the suitcase in the starting location.Lysander wrote:Here's what I want ot do.
-player starts out with handle in inventory, and suitcase in the starting location
Having the handle as a separate object from the suitcase handles this.-when player holds the handle, he does not in fact hold the suitcase but in fact only holds the handle, whereas the suitcase remains in the current room of the player.
You could use attachables, it seems. Here is another example (without using attachables):-The player cannot walk away from the suitcase while he holds the handle; wherever he goes while holding the handle, the suitcase will follow
Code: Select all
class newLocation
{
inherits room
after
{
location DoGo
{
if (handle in player and suitcase in old_location)
{
move suitcase to location
}
}
}
}
If so, move the suitecase to the new location that they moved to.
That is just one possible way. (I think. I tried this out and it seems to work for at least up to this level of what you want to do.) Let me try working with the other specifics that you gave.
-
- Posts: 55
- Joined: Wed May 05, 2004 4:35 am
- Location: Chicago, IL
- Contact:
Re: Suitcase
Okay, so for this, how about something like this:Lysander wrote:-when the player types "get suitcase," the handle disappears as part of the suitcase and can be examined and whatnot but is not referred to in the inventory list (I.E: "you are carrying a suitcase, attached to which is a handle.")
Code: Select all
object suitcase "suitcase"
{
in emptyroom
noun "suitcase"
long_desc { "A basic suitcase." }
inv_desc { "a suitcase" }
before
{
object DoGet
{
move handle to suitcase
return false
}
}
after
{
object DoDrop
{
move handle to player
return false
}
}
}
I think the before/after properties could help you with the other elements on your list as well. In other words, you can dictate how the suitcase will respond to being opened, for example, or when it is allowed to be opened.
I am not sure if this is all the "best" way to do this (probably not) but does it help? A little? Sorta?
-
- Posts: 1693
- Joined: Tue Jul 08, 2003 12:39 pm
- Location: East Bay, California.
Yes. Much. Thank you. I'll add this in... er... whenever I get a chance, which probably won't be for a little while, and see what else needs doing. Basically i'm trying to make everything act as "real-y" as possible for hte purposes of learning the various ins and outs of the language.
paidforbythegivedrewbetterblowjobsfundandthelibertyconventionforastupidfreeamerica