2017-02-14 73 views
0

我在Inform7中實現了一個沒有任何擴展名的電話。Inform7中嵌套的If-Conditions

Calling is an action applying to one topic. 
Understand "Call [text]" or "[text] call" as calling. 
Carry out Calling: 
    if the topic understood matches "Melissa": 
     say "You are calling Melissa … 'are you fine?'"; 
     if player consents: 
      say "good???"; 
     otherwise: 
      say "I see!"; 
    if the topic understood matches "Dad": 
     say "Hey boy"; 
    otherwise: 
     say "beeeeep – [the topic understood] is not answering"; 

所以,如果我叫爸爸的程序工作。但是,如果我叫梅利莎,她回答問題,當玩家同意,整個過程失敗:

>call melissa 
You are calling Melissa … 'are you fine?' 
yes 
good??? 
beeeep - 
*** Run-time problem P39: Attempt to say a snippet value which is currently invalid: words 2 to 2. 

    is not answering 
> 
+0

@khelwood的問題似乎是,他正在運行的最後一個「否則」即使條件「梅麗莎」有匹配... – 18zehn

+0

那當然是這種情況。如果你不想那樣,那麼你的'如果主題理解匹配'爸爸'應該是'否則如果...' – khelwood

回答

2

當你有這樣的結構

if A 
    ... 
if B 
    ... 
otherwise 
    ... 

然後otherwise塊將在任何被執行B未匹配的情況。

在另一方面,如果你有

if A 
    ... 
otherwise if B 
    ... 
otherwise 
    ... 

那麼如果沒有A也不B被匹配的otherwise塊將被執行。

你的情況

所以,你

if the topic understood matches "Dad": 

應該

otherwise if the topic understood matches "Dad": 
+0

就是這樣!非常感謝! – 18zehn