2017-02-14 123 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