ANSWER TO EXERCISE 2 | |
Object medicine "guaranteed child-proof medicine bottle" cupboard with name "medicine" "bottle", description "~Antidote only: no preventative effect.~", openup [; give self open ~locked; "The bottle cracks open!"; ], has container openable locked;Any other code in the game can send the message medicine.openup() to crack open the bottle. For brevity, this solution assumes that the bottle is always visible to the player when it is opened -- if not the printed message will be incongruous. |