From: dmb@case.ai.mit.edu (David Baggett)
Newsgroups: rec.games.int-fiction
Subject: Re: TADS fragment & moaning
Date: 15 Nov 1992 22:31:14 GMT
Organization: MIT Artificial Intelligence Laboratory
NNTP-Posting-Host: case.ai.mit.edu

In article <1992Nov15.163222.3799@starbase.trincoll.edu> Russell L. Bryan <rbryan@Mail.trincoll.edu> writes:
>In article <1992Nov15.150116.23785@kth.se> Tommy Nordgren,
>f85-tno@nada.kth.se writes:
>>	For an example, try implementing the following commands, based on
>>infocoms Enchanter.
>>	Frotz cup.
>>	Cast the frotz spell on the cup.
>>	Enchant the cup with the frotz spell. 
>
>Although I haven't tried the above myself, I do know of one person who
>attempted to write an Enchanter-like magic interface.  He found it
>exceptionally difficult.

It shouldn't be hard; I posted some code here a few weeks ago that
outlined one way to do it.  It's just a matter of defining a bunch of
new verbs.

>In particular, the command "gnusto frotz" (inscribe something into
>your spell book) was inaccessible because it required a word to be
>referred to as both a verb and a noun, which is not, as far as I know,
>acceptable to TADS, even after modifying ADV.T.

As far as I know there is no problem with having verbs and nouns be
identical.  I just tried it with TADS 2.0 and it works fine, and I
don't recall it being a problem with earlier versions.

There is a bug in some versions of TADS 1.2, however, that disallows
the player from referring to items that aren't reachable.  An easy way
to solve the "gnusto frotz" problem (even under the buggy TADS 1.2)
would be to have a floating decoration like the following:

frotzspell: decoration
	canbecast = nil	// can't be cast until learned
	sdesc = "frotz spell"	
	ldesc = "Frotz is a spell, and exists only in the mind of the
		caster."	// catch "examine frotz"

	locationOK = true	// tell compiler OK for location to be method
	location = { return Me.location; } // always where the player is

	noun = 'frotz' 'spell'
	adjective = 'frotz'

	/*
	 * Write spell into spellbook
	 */
	verDoGnusto(actor) = {
		// disallow action here under game-related circumstances,
		// e.g., until the player finds the related scroll.
	}
	doGnusto(actor) = {
		"You write the spell into your spellbook.";
		self.canbecast := true;
	}

	/*
	 * Cast spell
	 */
	verDoCast(actor) = {
		if (not self.canbecast)
			"You don't know the frotz spell yet.";
	}
	doCast(actor) = {
		// code here for frotz not directed at a particular object
	}

	/*
	 * Cast spell on something
	 */
	verDoCastOn(actor) = { self.verDoCast(actor); }
	doCastOn(actor, io) = {
		// code here for casting frotz on object "io"
	}

	/*
	 * A synonym for "cast X on Y" is "enchant Y with X"
	 */
	verIoEnchantWith(actor) = { self.verDoCast(actor); }
	ioEnchantWith(actor, do) = { self.doCastOn(actor, do); }

	// We also need to define verDoEnchantWith and doEnchantWith
	// methods in thing to go along with this.
;	

Then you can say any of the following:

>gnusto frotz (spell)
>cast frotz (spell)
>cast frotz (spell) on <X>
>enchant <X> with frotz (spell)

regardless of whether you have a verb with corresponding vocab 'frotz'.
If you did add a frotz verb, you'd just forward all the actions to
the frotz object.  So you could also say:

>frotz		[frotzVerb would call frotzspell.doCast(actor)]
>frotz me	[frotzVerb would call frotzepll.doCastOn(actor, Me)]

You will probably want to make some changes to the thing class in ADV.T
in the course of all this.  I usually put my extentions to the thing
class in a separate file, and add an include directive to adv.t at the
end of the (thing class) definition.  This makes the changes easy to
propagate to new versions of adv.t.

Dave Baggett
--
dmb@ai.mit.edu           MIT Artificial Intelligence Laboratory                  
ADVENTIONS: interactive fiction (text adventures) for the 90's!
dmb@ai.mit.edu *** Compu$erve: 76440,2671 *** GEnie: ADVENTIONS