AGT Programming (4) - Turn that container into a room! by Bev Truter If you have played AGT games before, what's probably driven you mad with annoyance is typing "I" for Inventory, and getting a huge screenful of objects you are carrying, plus a listing of all objects in a container (eg rucksack, bag, suitcase) you might be lugging around with you. If the container can be closed, then that will avoid the list of things you've shoved into it for safekeeping being displayed on the screen; but then you have to continually "open bag/rucksack/whatever" if you want to delve around inside it to retrieve something. So here's how to create a container that's visually neater for the player to handle and more pleasing to the eye of the programmer. First of all, create a Noun in the .DAT file that you want to be a container, i.e. something that you can put objects into for storage or safekeeping, and preferably tote about with you. Eg. VELVET BAG, HEAVY RUCKSACK, etc., making it closed and closable. Then create a Room, which you can specify as the TREASURE_ROOM at the top of the .DAT file if you want the player to be able to retain the points for any treasures he puts in the bag or rucksack or suitcase or whatever. In the example below I've made ROOM 18 a velvet bag - anything you put into the NOUN velvet bag will get sent to Room 18 (Interior of Velvet Bag). I've made NOUN 201 a velvet bag which can be picked up and opened or closed by the player. The beauty of this type of container (i.e. the velvet bag as NOUN and ROOM) is that it can be used for carrying something very heavy, for example an iron bar with a weight of 100, because as soon as you put it in the bag it is sent to Room 18, resulting in you being able to stuff all your belongings into the bag, no problems with weight or size of objects, and no increasingly unwieldy inventory of things. Another nifty idea is to program the bag/suitcase/rucksack (i.e. the Room 18 above) so that you can enter it - after all, if it has a limitless size, you should theoretically be able to enter it as well as stuff all the bits and bobs you are carrying into it. But more of that idea in Article #5..... So, to create your container that is both a NOUN and a ROOM in the .DAT file, you could do something like the following: NOUN 201 BAG VELVET There is a tiny velvet bag here with a gold drawstring LOCATION 67 ;the bag's original location CLOSABLE CLOSED SIZE 99 ;size irrelevant - everything will be sent to room 18 WEIGHT 2 POINTS 10 ;assuming the bag itself is a treasure END_NOUN NOUN_DESCR 201 The bag has been sewn from bright red plush velvet studded with rubies, and has the slogan "Infinity Unlimited" embroidered in white silk across the middle. END_NOUN_DESCR ROOM 18 Inside Velvet Bag END_ROOM ROOM_DESCR 18 You are sitting inside the spacious interior of a magical bag. It is very comfortable, and you sink back against the plush quilted lining with a sigh of relaxation. END_ROOM_DESCR Then, to cope with putting things into the bag, you'll need a Command in the .CMD file which looks something like this: COMMAND PUT ANY IN BAG Present 201 ;velvet bag is in room or being carried IsOpen 201 ; bag must be open NOUNIsCarrying ;the item to be put in bag is being carried SendNOUNToRoom 18 ; put item in bag PrintMessage 34 ;You put the $noun$ into the velvet bag. DoneWithTurn END_COMMAND If you `examine' the bag you'll get the long description of the noun BAG, followed by a list of the bag's contents, if there is anything inside it. To do this, you'll probably need a Command something like the following in the CMD file: COMMAND EXAMINE BAG Present 201 ;velvet bag is in the current room, or carried SomethingInside 18 ;checks if there is currently something in bag DescribeThing 201 ;repeats description of bag PrintMessage 32 ;the red velvet bag currently contains: ShowContents 18 ;displays what's currently in the bag (room ;18) DoneWithTurn END_COMMAND If the bag (i.e. Room 18) is empty, then you will only see the bag description. If you want to take something from the bag, eg. a knife, you will need a Command in the .CMD file something like this: COMMAND GET ANY Present 201 IsOpen 201 NOUNIsLocated 18 ;the noun you want to get is inside the bag SendNOUNToRoom 1 ;you take the noun (Room 1 = the player) PrintMessage 36 ;You root around inside the bag until you ;find.. DoneWithTurn END_COMMAND And you'll need a similar Command for when the player is trying to remove something from the closed bag: COMMAND GET ANY Present 201 IsClosed 201 NOUNIsLocated 18 ;the noun you want is inside the bag PrintMessage 37 ;Can't take anything from a closed bag! DoneWithTurn END_COMMAND The advantage of having a room like this as a container is that it avoids the automatic AGT response of listing all the bag's contents whenever you enter `inventory' or `examine bag' followed by "...(in the bag)..." after every item. This way, when you enter `inventory' you only see a list of what you are currently carrying, and not the increasingly long (and often annoying!) list of the bag's contents, if you happen to be carrying the bag. And lastly, as a final touch, you can program the bag, suitcase, rucksack or whatever so you can enter it, i.e. room 18......See next exciting instalment in following issue of SynTax - if I can bribe Sue to publish it. Does ANYONE out there still program games with AGT??? @~I reckon more use TADS now ... Sue - o -