我想在我的Inform7游戏中创建一个功能:
当玩家决定通过向北走过人行横道时,叙述者会第一次向玩家表明玩家有可能死亡,如果玩家再次向北走,那么事件就会发生并且在一次成功的偶数中,玩家可以去花园.像这样:
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.
Run Code Online (Sandbox Code Playgroud)
是的,这段代码不起作用..任何人都可以帮我弄清楚如何使这项工作?
这段代码有两个问题:
通知when后不允许使用子句for the second time.(你可以用相反的方式写它,如"当第二次偶然的机会成为第二次成功时",但这意味着不同的东西:它会在第二次随机机会成功时触发规则,即第二次玩家幸存过马路.)
otherwise必须成为if声明的一部分; 它不能与when条款一起使用.
要修复代码,您只需将"随机机会"条件移动到if语句中,然后更改标点符号,以便两个备选方案都属于同一规则:
[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.Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
298 次 |
| 最近记录: |