2017-02-22 51 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