首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Inform7:如何在inform7中的特定情况下创建随机事件?

Inform7:如何在inform7中的特定情况下创建随机事件?
EN

Stack Overflow用户
提问于 2012-11-22 21:37:28
回答 1查看 372关注 0票数 1

我想在我的Inform7游戏中实现一个功能:

当玩家决定向北通过人行横道时,第一次解说员将向玩家表明玩家有可能死亡,如果玩家再次键入向北,则事件将发生,并且在1/2成功的随机机会中,玩家将能够前往花园。如下所示:

代码语言:javascript
复制
        Instead of going north in the road for the second time when a random chance of 1 in 2 succeeds:
        say "Yay! You made it!";
        now the player is in the Garden.

        otherwise:
        say "The car crashed you instantly - without any hope, you lost your whole strength in your body…";
        end the game in death.

是的,这个代码不能工作..有没有人能帮我弄清楚怎么做?

EN

回答 1

Stack Overflow用户

发布于 2013-05-11 02:31:38

这段代码有两个问题:

  1. Inform不允许在for the second time之后使用when子句。(你可以写成相反的方式,比如“当2中有1的随机机会第二次成功时”,但这意味着不同的意思:它将在第二次随机机会成功时触发规则,也就是说,玩家第二次通过road.)
  2. otherwise幸存时必须是if语句的一部分;它不能与when子句一起使用。

要修复代码,您只需将“随机机会”条件移动到if语句中,然后更改标点符号,以便两个备选方案都属于同一规则:

代码语言:javascript
复制
[I added these lines to make a complete example...]
Road is a room.

Garden is a room, north of Road.

Instead of going north in the road for the first time:
    say "The road looks dangerous. You hesitate a moment, unsure if you really want to take the risk."

[And here's the fixed rule:]
Instead of going north in the road for the second time:
    if a random chance of 1 in 2 succeeds:
        say "Yay! You made it!";
        now the player is in the Garden;
    otherwise:
        say "The car crashed you instantly - without any hope, you lost your whole strength in your body…";
        end the game in death.
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13513892

复制
相关文章

相似问题

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