Constant Story "Container Contents"; Constant Headline "^An Inventory Property Example^"; Replace TakeAllSub; Include "Parser"; Include "Verblib"; Include "Grammar"; [Initialise; Banner(); location = PlainRm; lookmode = 2; print "^You are in a plain non-descript room with NO exits^ The only other object in the room with you is a blue bag.^^"; return 2;]; Object PlainRm "Plain Room" with description "A plain ordinary room with no exits.", cant_go "You are trapped in this non-exitable room!", has light ; Object -> ZipBag "Zippered Bag" with name 'zippered' 'zipper' 'bag' 'blue' 'leather', rocks 3, description "This indestructable bag is made out of blue leather and has the obligatory zipper on it.", describe "^There is an indestructable blue leather bag here with a zipper on it.", invent [; if (inventory_stage==2 && children(self)==0) " (which is empty)"; if (inventory_stage==2 && self.rocks==0) " (which is empty)"; if (inventory_stage==2 && self.rocks==1) " (with 1 rock inside)"; if (inventory_stage==2 && self hasnt open) " (which is closed)"; if (inventory_stage==2 && self.rocks>1) " (with " ,self.rocks, " rocks inside)";], before [; empty: if (self hasnt open) "But ",(the)self, " ain't open!"; if (children(self)==0) "The bag is already empty."; if (children(self)>0) {self.rocks=0; move HugeRock to player; move SmallRock to player; move TinyRock to player; "You remove all the rocks from the bag and are now holding them.";}; open: if (self has open) "The bag is already unzipped."; "The bag can only be unzipped."; close: if (self hasnt open) "The bag is already zipped shut."; "The Bag can only be zipped."; attack,damage: "Read the description again! ",(The)self," can NOT be damaged!"; receive: if (self hasnt open) "You need to unzip the bag before doing that."; UnZip: if (self has open) "But the bag is already unzipped."; give self open; if (child(self)==0) "You unzip the Bag revealing it to be totally empty."; print "You unzip the Bag revealing:^"; WriteListFrom(child(noun), INDENT_BIT + NEWLINE_BIT + TERSE_BIT + CONCEAL_BIT, 1); rtrue; Zip: if (self hasnt open) "But the Bag is already zipped!"; give self ~open; "You re-zip the Bag.";], has openable container ; Object HugeRock "Huge Rock" ZipBag with name 'huge' 'rock', description " A very large rock which barely fits in the bag.", invent [; if (inventory_stage==2) print " (weighing well over 100 pounds.)";], before [; insert: if (ZipBag hasnt open) "The Bag ain't open!"; zipbag.rocks++; move self to ZipBag; "You place the Huge Rock into the Zippered Bag."; take: if (self in ZipBag) {zipbag.rocks--; move self to player; "You take ",(the)self,".";}; if (self notin ZipBag) {move self to player; "You take ",(the)self,".";};], ; Object SmallRock "Smaller Rock" ZipBag with name 'smaller' 'small' 'rock', description "A much smaller rock which fits easily in the bag.", invent [; if (inventory_stage==2) print " (which is not quite as heavy.)";], before [; insert: if (ZipBag hasnt open) "The Bag ain't open!"; zipbag.rocks++; move self to ZipBag; "You place the Smaller Rock into the Zippered Bag."; take: if (self in ZipBag) {zipbag.rocks--; move self to player; "You take ",(the)self,".";}; if (self notin ZipBag) {move self to player; "You take ",(the)self,".";};], ; Object TinyRock "Tiny Rock" ZipBag with name 'tiny' 'rock', description " A Very tiny rock which also fits easily in the bag.", invent [; if (inventory_stage==2) print " (which weighs nearly nothing at all.)";], before [; insert: if (ZipBag hasnt open) "The Bag ain't open!"; ZipBag.rocks++; move self to ZipBag; "You place the Tiny Rock into the Zippered Bag."; take: if (self in ZipBag) {zipbag.rocks--; move self to player; "You take ",(the)self,".";}; if (self notin ZipBag) {move self to player; "You take ",(the)self,".";};], ; [DamageSub; if (noun == player) "Impossible!"; if (noun == HugeRock || TinyRock || SmallRock) "Good luck with that impossible feat.";]; [TakeAllSub; ZipBag.rocks=0; "You take all the rocks from the bag.";]; [UnZipSub; "You can't unzip that.";]; [ZipSub; "You can't zip that.";]; Extend 'attack' first * noun -> Damage; verb 'place' = 'insert'; Verb 'unzip' * noun -> Unzip; Verb 'zip' * noun -> Zip; verb 'damage' * noun -> Damage;