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.)
Lysander wrote:Here's what I want ot do.
-player starts out with handle in inventory, and suitcase in the starting location
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.
-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.
Having the handle as a separate object from the suitcase handles this.
-The player cannot walk away from the suitcase while he holds the handle; wherever he goes while holding the handle, the suitcase will follow
You could use attachables, it seems. Here is another example (without using attachables):
Code: Select all
class newLocation
{
inherits room
after
{
location DoGo
{
if (handle in player and suitcase in old_location)
{
move suitcase to location
}
}
}
}
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.
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.)
[quote="Lysander"]Here's what I want ot do.
-player starts out with handle in inventory, and suitcase in the starting location[/quote]
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.
[quote]-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.[/quote]
Having the handle as a separate object from the suitcase handles this.
[quote]-The player cannot walk away from the suitcase while he holds the handle; wherever he goes while holding the handle, the suitcase will follow[/quote]
You could use attachables, it seems. Here is another example (without using attachables):
[code]class newLocation
{
inherits room
after
{
location DoGo
{
if (handle in player and suitcase in old_location)
{
move suitcase to location
}
}
}
}[/code]
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.