TADS Programming (2) Tips on TADS from Neil Shipman 1. General. (a) I use the DOS 5.0 Editor to write my files. This makes it very easy to cut and paste chunks of text and code either in the same file or between different ones. The search facility is also very fast. (b) Make liberal use of comments, especially alterations to the STD.T and ADV.T files, with // and /* comment */ (c) Longer files take longer to compile, so don't write too much descriptive text to start with. Keep it to a minimum and concentrate on your puzzles making sure you regularly compile and run your game to test them out. 2. Adding a routine to tell the player when their score has increased, plus the ability to turn this feature on and off. (a) In your STD.T file: Add the following line to global: object tellincscore = true // NRS added this - sysverb notify toggles // on and off (b) In your ADV.T file: Add to incscore: function( amount ) so that it reads incscore: function( amount ) { global.score := global.score + amount; setscore( global.score, global.turnsofar ); // NRS added the { // following if ( global.tellincscore ) { "\n\t[Your score has just gone up by "; say ( amount ); " points"; { if ( not Me.iswarned ) { ".\ Note:\ you can turn this feature \n\t\ on and off using the NOTIFY command"; Me.iswarned := true; } } ".\]"; } } } (c) In your ADV.T file: Add the following new sysverb notifyVerb: sysverb // NRS added this sysverb verb = 'notify' action ( actor ) = { if ( not global.tellincscore ) { "Okay, you will now be notified when your score changes."; global.tellincscore := true; } else { "Okay, you will no longer be notified when your score changes."; global.tellincscore := nil; } } ; 3. Want to give a standard smell to everything, then alter this for certain items? (a) In your ADV.T file: Add to thing: object verDoSmell ( actor ) = // NRS added this { "Phew!"; } (b) In your MYGAME.T file: Add to the item(s) which you want to smell different from this verDoSmell = {} doSmell = { "A delightful fragrance nearly makes you swoon."; } (c) In your MYGAME.T file: Add a new deepverb smellVerb: deepverb sdesc = "smell" verb = 'smell' 'sniff' doAction = 'Smell' action = { "You give a hesitant little sniff."; } ; [N.B. You'll see that for these entries in MYGAME.T I haven't bothered to include ( actor ) after verDoSmell, doSmell, doAction or action. If Me is the only actor in your adventure who is able to do things, ie you don't want to tell others to do things like FRED, FOLLOW ME then you don't need to include ( actor ) after your entries.] 4. Here's an extremely easy way to stop players from being able to EXAMINE ALL, THROW ALL, EAT ALL etc yet still retain the ability to GET/DROP ALL and PUT ALL IN CONTAINER. In your ADV.T file: Change the items recognised by doDefault in deepverb: object to return (nil) so it simply reads as follows doDefault( actor, prep, io ) = { // return( actor.contents + actor.location.contents ); NRS changed return ( nil ); // this to stop general recognition of all } 5. Because REMOVE is included in the default definition of TAKE then in order to remove clothing you have to TAKE OFF ITEM. Here's how you can change this. (a) In your ADV.T file: (i) Delete 'remove' from takeVerb: deepverb takeVerb: deepverb // This object defines how to take things verb = 'take' 'pick up' 'get' // NRS deleted 'remove' sdesc = "take" // but no other alterations [Leave the rest unchanged] (ii) Add 'remove' to removeVerb: deepverb removeVerb: deepverb verb = 'take off' 'remove' // NRS added 'remove' sdesc = "take off" doAction = 'Unwear' /* ioAction( fromPrep ) = 'RemoveFrom' NRS deleted this to prevent the response "I don't know how to take off the item". */ ; 6. If you PUT ALL IN CONTAINER then by default the items you are wearing will go in too. (They'll also be included in THROW ALL etc unless you've altered this as in 4 above.) Here's how to keep your trousers (and whatever else you choose) on! (a) In your MYGAME.T file: Give your clothingItem the property mustkeepon = true (b) In your ADV.T file: (i) Change the checkDrop method in class clothingItem: item so that it reads class clothingItem: item checkDrop = { if ( self.isworn ) // NRS { // if ( self.mustkeepon ) // { // altered "You keep << self.thedesc >> on to avoid embarrassment."; exit; // } // this if ( not self.mustkeepon ) // { "(Taking off "; self.thedesc; " first)\n"; } } } (ii) Change verDoUnwear( actor ) in class clothingItem: item so that it reads verDoUnwear( actor ) = { if ( ( self.isworn ) and ( self.mustkeepon ) ) // NRS { // "You keep << self.thedesc >> on to avoid embarrassment."; // altered } // else if ( not self.isworn ) // this { "%You're% not wearing "; self.thedesc; ". "; } } 7. Finally, to start your adventure with your player wearing something, simply make it a clothingItem with location = Me and isworn = true (and, if you want, mustkeepon = true).