Pocket code and inv_desc
Posted: Thu Jun 27, 2013 2:37 pm
In the first Hugo game that I made and never released or debugged a few years ago, I had a coat with a component object representing the coat pockets. The code worked for taking things out of the pockets and putting them back in again, but the inventory listing was a problem.
Today I revisited the code. I got rid of the component object, merging everything into the coat. It's still not perfect, because I can't get both the coat objects inv_desc and contains_desc properties to be displayed on inventory. Inv_desc seems to override contains_desc. I can still see the contains_desc when I explicitly type "LOOK IN COAT," but I want it to appear for the inventory list as well.
I was thinking this might be a good one for the "Quick Code Samples" thread, but it's still not quite right, so I'll post code here anyways:
And here's the portable object that begins in the coat pocket:
Today I revisited the code. I got rid of the component object, merging everything into the coat. It's still not perfect, because I can't get both the coat objects inv_desc and contains_desc properties to be displayed on inventory. Inv_desc seems to override contains_desc. I can still see the contains_desc when I explicitly type "LOOK IN COAT," but I want it to appear for the inventory list as well.
I was thinking this might be a good one for the "Quick Code Samples" thread, but it's still not quite right, so I'll post code here anyways:
Code: Select all
object coat "coat"
{
is clothing, worn, container
in you
nouns "coat", "jacket", "windbreaker", "pockets", "pocket"
adjective "synthetic"
article "your"
long_desc
{
"An inexpensive synthetic windbreaker with two large pockets."
}
inv_desc
{
"You are ";
if self is worn
{
print "wearing ";
}
else
{
print "carrying ";
}
print Art(self); ".";
}
contains_desc
{
"Inside the coat's pockets ";
if Children(self) > 1
{
print "are";
}
else
{
print "is";
}
}
capacity 10
}
Code: Select all
object keychain "keychain"
{
in coat
nouns "keychain", "chain", "keyring", "ring", "fob", "keys", "attachments"
adjectives "plastic", "key", "miscellaneous"
article "your"
}