@~Two TADS articles this issue, one from Grimwold on functions and @~daemons, and one from me on writing your own verbs. If any other @~TADS users would like to contribute help, I'll be very pleased @~to hear from them. (a) Tads Article - More on functions and Daemons by Grimwold Now and again, when you're writing a game you might want something to happen after a set number of turns. I've done this with Tupperware Salesman in that there is a large help area available that contains the storyline, certain verbs, history etc. I don't want the players to miss all this and although I put a message in the title screen I thought an extra message might not go amiss. Now, all you need to do is look for a function (or Daemon) that is called every turn. One such function is TURNCOUNT. This is called after every turn and redisplays the status bar and adds 1 to the turn count. Of course, there is no reason why you can't create your own function to do something similar, but be warned that the more functions or Daemons the game accesses every turn, the slower that game runs. This gets very noticable towards the end if you have notified (woken) various non-player-characters along the way and not turned them off again. Anyway, for this example it is quite simple. List through ADV.T until you come to the following: ----------------------------------------------------------------- turncount: function( parm ) { incturn(); global.turnsofar := global.turnsofar + 1; scoreStatus( global.score, global.turnsofar ); } ----------------------------------------------------------------- This increases the turn (incturn function) and reviews the status line. Now, change this to: ----------------------------------------------------------------- turncount: function( parm ) { incturn(); global.turnsofar := global.turnsofar + 1; scoreStatus( global.score, global.turnsofar ); if (global.turnsofar = 15 and (not Me.ishelped)) { "\n\(Have you typed 'HELP' to read the game information yet?\)\n"; } } ----------------------------------------------------------------- This does the same as the first example, but if the turn count (global.turnsofar) equals 15, then it displays the message "Have you typed 'HELP' to read the game information yet?" in bold characters. The "\n" statements at the front and end of the line are needed to make sure the message arrives on a line of its own, rather than added to another message. The condition "(not Me.ishelped)" is set to true "Me.ishelped:= true;" if the player types "HELP" before this message is displayed, that way the message isn't shown if the player has already been to the help screen. I just put the "ishelped" onto "Me" as it was convenient - you can put such a condition on any object or room in the game, it doesn't have to be present. You could use as many examples of this, by adding more conditions so that if "global.turnsofar = 50", for example, you could print another message or even perform an action. ------------------------------------------------------------------ (b) TADS Help - Verbs From Sue I have had terrible problems writing my own verbs using TADS; not verbs just using a direct object (eg 'smell flower') but ones using both a direct and indirect object. For one of the verbs I was trying to add, 'dip brush in paint', the brush starts off dry. The first time the player enters 'dip brush in paint' the program would say, okay, and put paint on the brush. The second time the player would just be told there was already enough paint on the brush. But when I ran the program, inputting 'dip brush in paint' the first time gave the response that the brush had enough paint on it, and when I checked, yes, it DID have paint on it. Something wasn't right ... I tried creating other verbs using the same system and the same problem arose each time. I was told that had already been done. I was mystified. After several weeks of frustration, I wrote to Mike Roberts, who programmed TADS, asking where I was going wrong and enclosing my code. As I suspected I had missed one vital bit of logic to do with which bits of code should be put into the direct and indirect objects' code. Essentially TADS goes through the verDoAction code twice, the first time with its output hidden. The way I had written my code it was changing the condition I was checking on its first pass so that on its second pass it was giving the 'already been done' message. The easiest way to explain this is to give a full example. First, create the dip verb thus: dipVerb: deepverb verb = 'dip' sdesc = "dip" ioAction( inPrep) = 'DipIn' prepDefault = inPrep ; Then create the brush. I gave mine an ispainty condition, set at nil to start with because the brush is dry. When it is dipped in the paint, ispainty becomes true, stopping the player dipping it twice. paintbrush: item sdesc = "paint brush" noun = 'brush' adjective = 'small' location = mist ispainty = nil ldesc = { "It's a basic brush you made yourself."; if (paintbrush.ispainty=nil) { " The bristles are dry."; } else {" There's yellow paint on the bristles.";} } ; Now the paint tin. I haven't bothered with things like checking if it's open or closed. painttin: item sdesc = "tin of yellow paint" noun = 'tin' 'paint' adjective = 'small' location = mist ldesc = "It's a tin of yellow paint." ; The brush is the direct object so under the brush code, add the following. verDoDipIn(actor,iobj) = { if (not paintbrush.isIn(Me)) "You aren't carrying the paint brush."; else if (paintbrush.ispainty=true) "There's already enough paint on the brush."; } And under the tin code, the indirect object, add this code: verIoDipIn(actor)={} ioDipIn(actor, dobj) = { if (dobj = paintbrush) { "You dip the paintbrush in the tin and pick up some yellow paint on the bristles."; paintbrush.ispainty:=true; } else {"You decide <> looks better without paint on it.";} } Thus the action of dipping the brush is kept separate from the code where the ispainty condition is checked. This is essential if it is to work properly. I also added a bit of code to stop the player dipping other things into the paint. This stops the automatic response by the program of dipping the brush if the player is carrying it and just types 'dip'. It is worth also adding similar code for the paint tin so that if the player types 'dip brush' and the tin is in that location, the program doesn't automatically respond with (in the tin). Have fun! - o -