/* Copyright (c) 2000 by Kevin Forchione. All Rights Reserved. */
/*
* TADS ADV.T/STD.T LIBRARY EXTENSION
* COMPASS.T
* version 1.0
*
* compass.t simulates the Inform compass. Directions are objects
* and also do double duty as walls, floor, and ceiling. Like
* the Inform compass this one can define WITHOUT_DIRECTIONS in
* the game source, which will remove the usual directions from
* the compass object.
*
*----------------------------------------------------------------------
* REQUIREMENTS
*
* + HTML TADS 2.4.0 or later
* + Should be #included after ADV.T and STD.T
*
*----------------------------------------------------------------------
* IMPORTANT LIBRARY INTERFACE AND MODIFICATION
*
* + Replaces checkReach() function.
* + Modifies deepverb validXoList() and validXo() methods.
* + Modifies inspectVerb validDo() method.
* + Replaces travelVerb definitions.
* + Defines parseErrorParam() method.
*
*----------------------------------------------------------------------
* COPYRIGHT NOTICE
*
* You may modify and use this file in any way you want, provided that
* if you redistribute modified copies of this file in source form, the
* copies must include the original copyright notice (including this
* paragraph), and must be clearly marked as modified from the original
* version.
*
*------------------------------------------------------------------------------
* REVISION HISTORY
*
* 20-Jun-00: Creation.
*/
/*----------------------------------------------------------------------
* THE COMPASS
*--------------------------------------------------------------------*/
class CompassDirection: decoration
ldesc = "%You% see nothing special about <<self.thedesc>>."
verDoGo(actor) = {}
doGo(actor) = {actor.travelTo(self.travelDir(actor));}
;
class SpecialCompassDirection: CompassDirection
dobjGen(a, v, i, p) = {
if (v != goVerb) {
"%You% can't see any such thing. ";
exit;
}
}
iobjGen(a, v, d, p) = {self.dobjGen(a, v, d, p);}
;
/*----------------------------------------------------------------------
* CHECK REACH MODIFICATIONS
*
* These modifications always add the compass contents to scope.
*--------------------------------------------------------------------*/
replace checkReach: function(loc, actor, v, obj)
{
if (obj == numObj || obj == strObj || obj.isIn(compass))
return;
if (!(actor.isCarrying(obj) || obj.isIn(actor.location)))
{
if (find(loc.reachable, obj) != nil)
return;
"%You% can't reach "; obj.thedesc; " from "; loc.thedesc; ". ";
exit;
}
}
/*----------------------------------------------------------------------
* DEEP VERB MODIFICATIONS
*
* These modifications always add the compass contents to scope.
*--------------------------------------------------------------------*/
modify deepverb // A deep-structure verb.
validDo(actor, obj, seqno) =
{
if (obj.isIn(compass)) return true;
return obj.isReachable(actor);
}
validDoList(actor, prep, iobj) =
{
local ret;
local loc;
loc = actor.location;
while (loc.location)
loc = loc.location;
ret = visibleList(actor, actor) + visibleList(loc, actor)
+ global.floatingList + compass.contents;;
return ret;
}
validIo(actor, obj, seqno) =
{
if (obj.isIn(compass)) return true;
return obj.isReachable(actor);
}
;
modify inspectVerb
validDo(actor, obj, seqno) =
{
if (obj.isIn(compass)) return true;
return obj.isVisible(actor);
}
;
/*----------------------------------------------------------------------
* TRAVEL VERB MODIFICATIONS
*
* (a) goVerb defines doAction = 'Go' for verb templates verDoGo() and
* doGo() defined by the compass direction objects.
* (b) Replace travelVerbs so that they redirect travel to the goVerb.
*--------------------------------------------------------------------*/
goVerb: travelVerb
verb = 'go'
doAction = 'Go'
/*
* Allowing multiple objects can cause erroneous sdescs
* (e.g. nObj.sdesc) to get printed.
*/
rejectMultiDobj(prep) = {
"You can't use multiple objects with this verb.";
return true;
}
/*
* Beside returning the compass contents as default objects this
* method sets the important global.parseErrDirections flag used
* by parseErrorParam().
*/
doDefault(actor, prep, io) = {
global.parseErrDirections = true;
return compass.contents;
}
sdesc = "go"
;