From IFWiki
#charset "us-ascii"
#include <adv3.h>
#include <en_us.h>
versionInfo: GameID
name = 'Smell restrictions (TADS 3 example)'
byline = 'by David Welbourn'
version = '1.0'
;
street: Room 'Street'
"You are in a street. The sewer is below you. "
down = sewer
;
+ flower: Thing 'flower' 'flower'
"It's just a nice flower. You don't know what type. "
smellDesc = "It smells wonderful. "
;
+ spacesuit: Wearable 'spacesuit/suit' 'spacesuit'
"Spacesuits are wonderful things, but they make EVERYONE look fat. "
smellDesc = "You smell nothing unusual about the spacesuit. "
beforeAction() {
if (gActionIs(Smell) || gActionIs(SmellImplicit)) {
if (!self.isWornBy(gActor)) return;
if (gDobj == gActor || gDobj == self) return;
"You can't smell anything while wearing the spacesuit.";
exitAction;
}
}
;
sewer: Room 'Sewer'
"You are in a sewer. The street is above you. "
up = street
;
+ sewage: Immovable 'sewage' 'sewage'
"Horrible smelly sewage is everywhere in the sewer. "
isMassNoun = true /* want "some sewage" instead of "a sewage" */
isListed = true /* otherwise it isn't visible in the room */
;
++ SimpleOdor
desc = "It reeks. "
beforeAction() {
if (gActionIs(Smell)) {
if (spacesuit.isWornBy(gActor)) return;
if (gDobj == sewage) return;
"The disgusting reek of the sewage overwhelms your nose. You can't smell anything else. ";
exitAction;
}
}
;
me: Actor
location = street /* my initial location is the street */
;
/* The rest is the code is mostly the same as in the standard sample T3 game with comments removed. */
main(args)
{
mainCommon(args, nil);
}
mainRestore(args, restoreFile)
{
mainCommon(args, restoreFile);
}
mainCommon(args, restoreFile)
{
"<title><<versionInfo.name>></title>";
if (restoreFile == nil)
{
gPlayerChar = me;
}
else
{
"Restoring saved game...\n";
local succ = RestoreAction.startupRestore(restoreFile);
"\b";
if (!succ)
return;
}
runGame(restoreFile == nil);
"<.p>Thanks for playing!\b";
}