Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[TADS] EXITS verb

5 views
Skip to first unread message

Carsten Sørensen

unread,
Feb 22, 2000, 3:00:00 AM2/22/00
to
Hi,

I've been asked to add an EXITS command to my game and 'cos I'm such a nice
guy I agreed. My question is, are there any problems I haven't thought of
with capturing the output and probing the room's directions?

If that made no sense, the actual code is below (yes, those are the only
directions I use in the game.)


Thanks,
Carsten Sorensen

"Below" should be around here somewhere. Ah, there it is.

exitsVerb: darkVerb
verb = 'exits'
action(actor) =
{
local listofexits=[];
local totalexits;
local i;
local stat;

stat=outcapture( true );

if( actor.location.north )
listofexits+='north';
if( actor.location.south )
listofexits+='south';
if( actor.location.west )
listofexits+='west';
if( actor.location.east )
listofexits+='east';
if( actor.location.up )
listofexits+='up';
if( actor.location.down )
listofexits+='down';
if( actor.location.out )
listofexits+='out';

outcapture( stat );

totalexits=length(listofexits);

switch( totalexits )
{
case 0:
"It looks like you're stuck.";
return;
case 1:
"The only exit is ";
break;
default:
"Possible exits are ";
break;
}

for( i=1; i<=totalexits; i+=1 )
{
say( listofexits[i] );
if( i==totalexits-1 )
" and ";
else if( i<totalexits-1 )
", ";
}

".";
}
;


Kevin Forchione

unread,
Feb 23, 2000, 3:00:00 AM2/23/00
to
"Carsten Sørensen" <surf...@get2net.dk> wrote in message
news:88v3h2$20l6$1...@news.cybercity.dk...

> Hi,
>
> I've been asked to add an EXITS command to my game and 'cos I'm such a
nice
> guy I agreed. My question is, are there any problems I haven't thought of
> with capturing the output and probing the room's directions?

Your code looks like it will capture any output produced by going through
doors. If you have any output or game-state changes produced when going in a
certain direction you can easily prevent display and state-changes by
checking the (parserGetObj(PO_VERB) == exitsVerb) (note #pragma C+ syntax).

The Author's manual livingRoom example, modified to evaluate the verb:

livingRoom: room
sdesc = "Living Room"
ldesc = "You're in the living room. A dark stairway leads
down."
down =
{
if ( workingStairs.location = nil )
{
if (parserGetObj(PO_VERB) != exitsVerb)
"You quickly notice that the stairs have
collapsed, so there's no way down. ";
return( nil );
}
else
{
if (parserGetObj(PO_VERB) != exitsVerb)
{
"You start down the stairs, which creak and moan and
wobble uncertainly beneath you. You stop for a moment
to steady yourself, then continue down, when the entire
stairway suddenly breaks away from the wall and crashes
to the floor below. You land in a heap of splintered
wood. After a few moments, everything settles, and you
manage to get up and brush yourself off, apparently
uninjured.\b";
workingStairs.moveInto( nil ); /* replace workingStairs...
*/
brokenStairs.moveInto( cellar ); /* ... with brokenStairs
*/
}
return( cellar );
}
}
;

--Kevin

TenthStone

unread,
Feb 26, 2000, 3:00:00 AM2/26/00
to
On Tue, 22 Feb 2000 23:42:06 +0100, "Carsten Sørensen"
<surf...@get2net.dk> wrote:

>Hi,
>
>I've been asked to add an EXITS command to my game and 'cos I'm such a nice
>guy I agreed. My question is, are there any problems I haven't thought of
>with capturing the output and probing the room's directions?
>

>If that made no sense, the actual code is below (yes, those are the only
>directions I use in the game.)

As Kevin said, if any of your exit routines change the world state,
you'll be stuck. (this does not include doors that automatically
open, since those are handled differently). Since you're at the
beta-testing stage already, you should probably just look through your
entire game and rewrite the bits that you have to.

If you were just beginning your game, I would advise you to take a
look at Pianosa (programming/tads/library/pianosa.zip), which
separates the data from the action (i.e. there's .north and then
there's .goNorth).

----------------
The Imperturbable TenthStone
tenth...@hotmail.com mcc...@gsgis.k12.va.us

Carsten Sørensen

unread,
Feb 27, 2000, 3:00:00 AM2/27/00
to

"TenthStone" <tenth...@hotmail.com> wrote in message
news:38b84d6d...@news.erols.com...

> On Tue, 22 Feb 2000 23:42:06 +0100, "Carsten Sørensen"
> <surf...@get2net.dk> wrote:
>
> >Hi,
> >
> >I've been asked to add an EXITS command to my game and 'cos I'm such a
nice
> >guy I agreed. My question is, are there any problems I haven't thought of
> >with capturing the output and probing the room's directions?
> >
> >If that made no sense, the actual code is below (yes, those are the only
> >directions I use in the game.)
>
> As Kevin said, if any of your exit routines change the world state,
> you'll be stuck. (this does not include doors that automatically
> open, since those are handled differently). Since you're at the
> beta-testing stage already, you should probably just look through your
> entire game and rewrite the bits that you have to.

Thanks, both you and Kevin. Luckily I don't change the state in any of my
direction routines so it looks like I'm safe. I've already tried the verb in
all locations with doors in different positions and it works perfectly.
Thanks for the tip about Pianosa, I'll have a closer look at that when I'm
finished with this game.


Carsten Sorensen

0 new messages