2

我尝试列出用户可能去往的可能方向。但是对于故事的基调,最好不要说“你可以去南北”而是“你可以去浴室和厨房”。

我找到了帽子代码,但它只显示了方向。

Definition: a direction (called thataway) is viable if the room 
thataway from the location is a room.

After looking:
    say "you can go [list of viable directions]."

任何想法?

4

1 回答 1

1

绝对不是最好的方法,但我遇到了类似的问题,我最终遍历了您创建的方向列表并将每个房间添加到房间列表中,然后可以说:

nLooking is a number that varies. nLooking is 0.

After looking:
    now nLooking is 1;
    let accessibleRooms be a list of rooms;
    let pDirections be list of viable directions;
    repeat with dirToLookAt running through pDirections:
        try silently going dirToLookAt;
        if rule succeeded:
            add the location of the player to accessibleRooms;
            try silently going the opposite of dirToLookAt;
    now nLooking is 0;
    say "You can go to [accessibleRooms].".

Before going through a locked door when nLooking is 1:
    stop the action.

我用 nLooking 来阻止输出

(第一次开门)
好像是锁着的。

在寻找可以访问的房间时。
if rule succeeded检查玩家是否能够进入房间。如果是这种情况,玩家走进的房间会被添加到列表中,并且玩家会被移回他原来的位置。

这只有在一个人没有制作一张混乱的地图时才有效,其中向一个人来自哪里的相反方向移动并不意味着一个人降落在同一个房间里。一个可能只是将玩家放回他来自的房间......

我知道迟到的答案,但也许它可以帮助有同样问题的人:)

于 2017-05-13T10:31:51.153 回答