2017-02-22 55 views
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]." 

任何想法?

回答

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检查palyer是否能够去房间。如果是这种情况,玩家进入的房间将被添加到列表中,并且玩家将被移回他来自的地方。

这只适用于没有制作混沌地图的情况下,在相反的方向上移动来自哪里并不意味着同一个房间内的地图。人可能只需将播放器早在他从来到房间......

晚的答案,但我知道,也许它可以帮助人们用同样的问题:)

+0

非常感谢,我会在我的下一个测试游戏。我通过提到通向其他房间的门来解决这个问题。不是很好,但它可以用更艺术的方式使用;) – 18zehn