STAC Programming by Jean Childs I enjoy working with STAC as I find it very versatile and, on the whole, easy to use. Sometimes I have trouble when trying something a little complex, but I struggle with it for a while trying different methods until I find a routine that will handle it. Some of these `routines' I have reproduced here, but I am certainly not saying that they are the only ways, or the best ways, to handle these problems. They are here as a guide to help those people new to STAC or those who may have trouble with a similar problem. They may save someone some time, but if you know a better way - send it to SynTax. Unfortunately there is an error in the STAC manual, for which I thank James Judge for reminding me about as I had forgotten about it. If you read the "Tricks and Tips" in the manual where it introduces the idea of using `noun1', you will see it says:- if verb "get" and noun1 > 0 and noun1 < 11 then get noun1 ok Chapter 6 gives a small adventure for readers to try but in lines 7,9 and 11 of Low Priority Conditions, using the same technique, it omits the "if noun1 > 0". Here is line 7:- if ( noun1 < 5 ) and verb "get" then get noun1 ok Now when testing the game, what happens if you use the verb "get" and an unknown noun? - the program crashes. This is because, when processing the players command, an unknown noun is given the value of 0. So, noun1 will equal 0 thus qualifying for the first part of the condition. However, the "get noun1" will try to get object 0, and of course there isn't one. The same applies to line 9 (the drop condition) and line 11 (the examine condition). "Examine" is the verb that gives programmers the most work. Even if you can't get an item, or use it in some way, you should be able to examine it. There is nothing more aggravating than the player being told "You are standing on a beach by the sea", but when he/she tries to examine the sea, is told "You can't do that". So get poetic and describe the sea, even though it may play no part in the game. But what if you want a beach at the north, south, east and west of your map? You could use the following line in the Low Priority Conditions:- if verb "examine" and noun "sea" then message 10 wait This would save repeating the condition in the Local Conditions for each `room' with a sea, but means that in the middle of a forest the player could still examine the sea. Don't allow your players to have such good eyesight. What I do is to map out the entire game before I start any programming. I then give each room a letter for identification. (Yes, a letter not a number.) I make a list for each room, of the things that can be examined that I know will recur in other rooms. I then reverse the list to show the items and which `letters' they occur in. It takes a little time and study, but I can then number the rooms so that those with duplicate items to examine can run concurrently. Let me give you an example:- The Sea - rooms A B C D E G Trees - rooms F G I A wall - rooms A H I J A B C D E F G H I J 2 3 4 5 6 8 7 1 9 10 The Sea - rooms 2 3 4 5 6 7 Trees - rooms 7 8 9 A wall - rooms 1 2 9 10 The sea and trees conditions can be entered as follows:- if ( room > 1 ) and ( room < 8 ) and verb "examine" and noun "sea" then message 10 wait if ( room > 6 ) and ( room < 10 ) and verb "examine" and noun "trees" then message 11 wait The rooms containing the wall do not run concurrently. This I have done on purpose as you can't get them to do so every time. if ( room > 0 ) and ( room < 3 ) and verb "examine" and noun "wall" or if ( room > 8 ) and ( room < 11 ) and verb "examine" and noun "wall" then message 12 wait I only use this for things that happen to be there but I don't want to spend too much memory on. Some programmers may like to have a different description for every tree, every piece of wall and every different view of the sea. In many adventures you have to give an item to a character in order to proceed in the game. So in the Local Conditions, in the room where the character is, you might like to use:- if verb "give" and noun "coin" then drop 5 5 to 0 message 13 set 7 wait There are a few points I would like to make here, mainly for the benefit of the beginner. Firstly, you do not have to check if the coin is being carried. This is because having checked the conditions "give" and "coin", the program will next try to drop the coin. If you are not carrying it, the message "You're not carrying that" will appear, and the rest of the line will be ignored. This only works if you make sure that "drop 5" is the first action to be taken. The next action will move object 5 to room 0. If you didn't use "drop" first, you would have to include "if carried 5" in your conditions and also moving object 5 to room 0 straight from the player, would not alter the weight. In other words, the player would not have the coin but would still be carrying the weight of it. Message 13 could be the character saying "Thanks mate!" and set 7 could be what you have achieved, such as allowing access to another room. You will note that I am assuming the reader has some knowledge of STAC, and I am not going into too much detail on the basics. However, if you are a real beginner and cannot follow what I am saying on any one point, then write to me about it. You'll find my name and address in the Help section. The above condition used alone would handle the giving of the coin. But what if you also had a œ5 note and tried giving that. It would say "You can't do that". Then the player would think the character was a real nutcase. In my games, if I allow the player to "give", I like to let them give anything away. It's bad luck if they need it later in the game. Wicked aren't I? Still, this is how I do it. I give each character a room number, separate from the room number they are in. Lets have, at room 10, a wizard and give him room 400. Under the Local Conditions for room 10 we could put:- if verb "give" and noun1 > 0 and noun1 < 6 then drop noun1 noun1 to 400 message 13 wait Object (noun1) has been dropped and sent to room 400, not to room 0. The reason for this is in case the player wants to try and take it back. Imagine giving the character a spade which is about 4ft long. If the spade went to room 0 and the player's command was "get spade", the result would be "You can't see that". What has the character done with it? Put it under his hat? But if it has gone to room 400, we could then put:- if verb "get" and noun1 > 0 and noun1 < 6 then if noun1 in 400 then message 14 wait Message 14 could say "He won't let you have it back now". If you wanted the player to be able to get it back you would have to use a Special Command similar to the one I used for taking things out of a boat. But more on that later in the article, for now we will assume you can't take it back. We could also use this:- if verb "examine" and noun1 > 0 and noun1 < 6 then if noun1 in 400 then objlng noun1 wait This would enable you to examine something the character had previously been given, (assuming he hadn't put it under his hat). You would have to include separate conditions for things such as lit torches and other objects that `share' a noun. Again I am assuming the reader is familiar with object numbering and the use of things such as lit torches, which is well covered in the manual. This applies to the "give", "get" and "examine" conditions, and remember to place them BEFORE the "noun1 > and <" conditions. Here it is for all three verbs with object 8 being a lit torch (as an example) and the coin being the `key' item, and message 15 saying "He now lets you pass":- if verb "give" and noun "coin" then drop 5 5 to 400 message 13 set 7 message 15 wait if verb "give" and noun "torch" and carried 8 then drop 8 8 to 400 message 13 wait if verb "give" and noun1 > 0 and noun1 < 6 then drop noun1 noun1 to 400 message 13 wait if verb "get" and noun "torch" and 8 in 400 then message 14 wait if verb "get" and noun1 > 0 and noun1 < 6 then if noun1 in 400 then message 14 wait if verb "examine" and noun "torch" and 8 in 400 then objlng 8 wait if verb "examine" and noun1 > 0 and noun1 < 6 then if noun1 in 400 then objlng noun1 wait I have recently released an adventure called "Excuse Me - Do You Have The Time? (PLUG!). During one part of this game, the player has the use of a small boat. I wanted the player to be able to do the following:- - To move from location to location while in the boat, but be able to drop things in the boat and still be able to see or get them having moved to another location. - To be able to see and get things from the boat, when the player is not in the boat but in the same room as the boat. Each location was described as being in the boat, i.e. you couldn't swim there. Direct room connections were not used and were replaced with Local Conditions such as:- if verb "south" then 47 setcntr 11 message 163 message 165 special 23 goto 47 wait if verb "west" then 500 setcntr 11 message 163 message 162 special 23 37 to 38 goto 38 wait In the first condition counter 11 is used to record the next room number. Message 163 reads "Tom, Dick and Harry paddle the boat" followed by message 165 "south". Special 23 calls up Special Condition 23 which is:- [1] 1 setcntr 10 [2] repeat [3] if here counter 10 then counter 10 to counter 11 [4] inc 10 [5] until 40 = count 10 This uses counter 10 to equal 1 through to 40, each time checking to see if object (counter 10) is here. If it is, it moves it to the next room (counter 11). In the second condition, to go west would take you to the beach and out of the boat. Therefore counter 11 is set at 500 (the boat's room number). Message 162 reads "up onto the sand and once again you put your feet on dry land". Special 23 moves any objects to counter 11 (set at 500 and therefore into the boat's room number). The boat as an object (object number 37) is then moved to the beach (room 38), as is the player. Now the player is on the beach with the boat (not in it), but as it is a small open boat, the player should be able to reach in and get any object that is in it (subject to weight restrictions). This is done under Low Priority Conditions as the boat could be in a variety of rooms:- if ( noun1 > 0 ) and ( noun1 < 40 ) and verb "get" and here 37 then special 24 wait "Here 37" checks to see if the boat is here. Then special 24 calls up Special Condition 24 which is:- [1] if ( ( weight noun1 + amount ) < 26 ) and noun1 in 500 then bring noun1 get noun1 message 140 objsht noun1 return [2] if noun1 in 500 then message 9907 return [3] get noun1 message 9905 Line one checks that the weight of the item the player wishes to pick up plus the player's current load, does not exceed the maximum weight the player is allowed to carry. Then, providing the item is in the boat (and noun1 in 500), the object is taken with the message "You reach into the boat and take " followed by the short description of the object. If this condition was actioned without the weight check, the object could take the player's current load above the maximum. The "get noun1" would then be followed by "You are carrying too much already", and the object would be brought to the location and not left in the boat. If the conditions are not met in line 1, then line 2 again checks to see if the object is in the boat and, if it is, says "You are carrying too much already". However, as it doesn't bring the object, the object remains in the boat. Line 3 is left to cover objects that are not in the boat. Also I allow the player to examine the boat and, if there are any objects in it, to list them:- if verb "examine" and noun "boat" and here 37 and cntobj 500 > 0 then objlng 37 lf message 139 lf list 500 wait Message 139 reads "In the boat you can see :-". Of course, this condition has to be placed BEFORE the condition that would examine the boat anyway. The last problem that I am going to cover is one concerning the use of High Priority Conditions. Suppose you want the player to move from room 1 to room 2, but having moved you want to print something or do something (e.g. sudden death) before they enter their next command. Under High Priority Conditions you might use:- if at 2 then message 10 While message 10 is being displayed, which might be some descriptive means of death due to entering room 2, the status bar at the top still shows room 1. This is due to the fact that the status bar is only updated when the "What Now?" prompt appears. To get round this try:- if at 2 then special 27 message 10 Enter a Special Condition (I have used 27) to be line 2 only of Special Condition 13 (see QSTART file in the manual). Well, that's all folks! I have some programming to do.