STAC Programming Part 3 Written by Colin Campbell of Creative Insanity The following two routines are by no means bug free but they do what I wrote them to do and that's all I want. Permission is hereby given for unrestricted non-commercial use of these routines provided a credit is given which states that I was the (originating) author. Clock Routine ~~~~~~~~~~~~~ I wrote this routine many many months ago and it works very well indeed. It looks quite complicated and, to be frank, it is. The routine will only function for one week then it will loop back so if your game lasts longer than one week then you'll have to include another counter to act as how many weeks have passed. Important note: this routine will only work correctly if you have left a 10 line gap in the top of the screen. To do this, go back to the main menu, press "B" and when you're asked about the space at the top of the screen typing in "10". I know it's obvious when you know about it but this part of STAC wasn't very well documented. This routine must be put in Special Routine 13. 1 \ "what now?" & clock 2 3 inc 3 \ 1 second passes.... 4 if counter 3 = 60 then inc 2 0 setcntr 3 \ next hour & reset minutes 5 6 if counter 2 = 25 then 1 setcntr 2 \ 1 am 7 if counter 2 = 24 and counter 3 = 0 then inc 8 \ new day 8 if counter 8 = 7 then 0 setcntr 8 \ day back to monday (from sunday) 9 lf message 9912 10 message 9923 descht room message 9924 \ move cursor & print loc desc 11 12 if counter 2 > 12 then print counter 2 - 12 13 if counter 2 < 13 then print counter 2 14 message 9925 15 if counter 3 < 10 then message 9936 print counter 3 16 if counter 3 > 9 then print counter 3 17 if counter 2 > 11 and counter 2 < 24 then message 9935 \before 12am 18 if counter 2 = 24 then message 9934 \ 12 am 19 if counter 2 < 12 then message 9934 \ morning 20 21 message 9944 22 message ( 9937 + counter 8 ) \ print day 23 24 message 9926 \ reset cursor position 25 26 if set? 33 then ramsave 1 27 if reset? 33 then ramsave 2 28 change 33 You can leave out lines 26-28 if you wish as this part of the special condition only provides part of the OOPS command. All the messages above are common to the quickstart adventure file except: Message 9923 = [SAVE][HOME][LARG][INVS][CLRL][HOME] Message 9924 = [TB10][LEFT][LEFT][LEFT] Message 9925 = : (one space on either side of the ":" only!) Message 9926 = [NORM][SMALL][REST] Message 9934 = am Message 9935 = pm Message 9936 = 0 Message 9937 = Mon Message 9938 = Tue Message 9939 = Wed etc Message 9943 = Sun Message 9944 = [HOME][TB10][LEFT][LEFT][LEFT][LEFT][LEFT][LEFT] [LEFT] Counter 3 is the seconds timer Counter 2 is the hours timer Counter 8 is the day timer Marker 33 deals with the OOPS command Multipurpose List Routine ~~~~~~~~~~~~~~~~~~~~~~~~~ This routine is much more complicated than the clock routine and it took me a while to get it to work. A similar idea (but not as useful) came to me from Matthew Conway through Adventure Workshop. He managed to get past a problem that I hadn't but at the expense of speed. I've managed to keep this routine as quick as possible but it's still quite slow when there are a lot of objects in your adventure. It might be advisable to ask the player at the start of the game if he wants fast list or a good looking one. It is quite simple to have both, the game swapping between them via a set marker. This routine must go in a completely blank special condition. I've used number 60 but you could use some other one if you wanted. 1 \ list inventory (carried) with "and" 2 3 4 if zero? ( firstob counter 29 ) and counter 29 = with then message 9916 message 9917 return \ no objects carried 5 if zero? ( firstob counter 29 ) and counter 29 = 9999 then message 1064 message 9917 return \ no objects worn 6 7 ( firstob counter 29 ) setcntr 30 \ what is 1st object? 8 ( cntobj counter 29 ) setcntr 31 \ how many objects here? 9 0 setcntr 45 \ objects dealt with 10 if counter 29 = room then message 9913 \ "you can see..." 11 if counter 29 = with then message 9916 \ "you are carrying.." 12 if coutner 29 = 9999 then message 1064 \ "you are wearing..." 13 14 reset 131 15 repeat 16 if counter 30 in counter 29 then ( 7999 + counter 30 ) mess$ 0 set 131 17 if set? 131 and counter 31 = ( counter 45 ) + 1 then 8997 mess$ 22 add$ 0 \ "." 18 if set? 131 and ( counter 31 - counter 45 ) = 2 then 9974 mess$ 22 add$ 0 \ "and" 19 if set? 131 and ( counter 31 - counter 45 ) > 2 then 9975 mess$ 22 add$ 0 \ "," 20 if set? 131 then print$ 0 inc 45 reset 131 21 inc 30 22 until counter 45 = counter 31 23 return Please note that my "worn" location is room 9999. Also note the following messages: Message 1064 = You are wearing (note space on end) Message 9913 = You can see (note space on front & end) Message 9916 = You are carrying (note space on end) Messages 8000 onward hold the object's short description (almost the same as the object description in option "O" from the main menu but without any punctuation!!). For example, if object 1 was an inflatable baboon then message 8000 would be "an inflatable baboon" (without the quotes, obviously). The following counters and markers were used: Counter 29 holds where the list is to be taken from (see later) Counter 30 holds the first object's number Counter 31 holds the number of objects where the list is to be taken from Counter 45 holds the number of objects "dealt with". Marker 131 tells the routine if an object has to be printed onto the screen. The most important thing in regard to calling this routine is to set counter 29! If you forget then something terrible will happen! if verb "inventory" then with setcntr 29 special 60 wait The above example will give a listing of what you are carrying using this routine. Notice the "with setcntr 29" bit as this is very important. If you wanted to deal with worn objects then the line would change to.... if verb "inventory" then with setcntr 29 special 60 lf 9999 setcntr 29 special 60 wait The above command sets counter 29 equal to what you're carrying, branches to the routine, then sets it to what you're wearing then jumps to the routine again. Remember, if the room that holds what you're wearing in your game is not 9999 then change the above command appropriately. You can list what's in your room on entry and upon "look"ing by modifying special conditions 14 and 15. So, instead of seeing... if firstob room then message 9913 list room message 9914 you'd see.... if firstob room then room setcntr 29 special 60 Simple, isn't it? The End ~~~~~~~ Yes, that's all for this issue. Next issue I hope to start on a beginners' guide to STAC, entitled (somewhat obviously) "The STAC Beginners' Guide". If you've any comments (i.e. "what on earth are you dribbling on about??") then you can send me a message on any F-NET BBS in the country or write to me at the following address: Colin Campbell, 21 Aldbury Mews, London N9 9JD.