首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Inform7中嵌套的If条件

Inform7中嵌套的If条件
EN

Stack Overflow用户
提问于 2017-02-14 21:31:56
回答 1查看 236关注 0票数 0

我正在用Inform7实现一个没有任何扩展名的电话。

代码语言:javascript
复制
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";

所以如果我打电话给爸爸程序就行了。但如果我打电话给梅丽莎,她会回答问题,当玩家同意时,整个过程都会失败:

代码语言:javascript
复制
>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
>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-02-14 21:48:50

当你有了这样的结构

代码语言:javascript
复制
if A
   ...
if B
   ...
otherwise
   ...

则在B不匹配的任何情况下都将执行otherwise块。

另一方面,如果你有

代码语言:javascript
复制
if A
   ...
otherwise if B
   ...
otherwise
   ...

如果AB都不匹配,则将执行otherwise块。

所以在你的情况下,你的

代码语言:javascript
复制
if the topic understood matches "Dad":

应该是

代码语言:javascript
复制
otherwise if the topic understood matches "Dad":
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42227506

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档