2017-02-14 6 views
0

Ich implementiere ein Telefon in Inform7 ohne jede Erweiterung.Verschachtelte Wenn-Bedingungen in Inform7

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"; 

Also wenn ich Dad anrufen, funktioniert das Verfahren. Aber wenn ich Melissa nennen, sie ist die Frage zu beantworten, und wenn der Spieler damit einverstanden, das gesamte Verfahren versagt:

>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

seine @khelwood das Problem zu sein scheint, dass er die letzte „sonst“, auch wenn die Bedingung „Melisse“ hat läuft abgestimmt ... – 18zehn

+0

Nun, das ist sicherlich der Fall. Wenn du das nicht willst, dann sollte dein 'wenn das Thema verstanden wird, mit 'Dad' übereinstimmen,' sonst wenn ... ' – khelwood

Antwort

2

Wenn Sie diese Konstruktion haben

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

Dann wird der otherwise Block wird in jedem ausgeführt werden Fall, dass B nicht übereinstimmte.

Auf der anderen Seite, wenn Sie

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

dann der otherwise Block ausgeführt werden, wenn weder A noch B abgestimmt wurde.

Also in Ihrem Fall Ihr

if the topic understood matches "Dad": 

sollte

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

Das ist es! Danke vielmals! – 18zehn