如何访问玩家刚刚输入的动词?

Ola*_*Now 2 inform7

我想使用玩家刚刚在响应中使用的动词。

这对于名词([名词])很容易,但在手册中我没有找到动词/动作的内容。

这就是我想要做的:

Instead of attacking someone:
   say "How do you want to [verb] [the noun]?".
Run Code Online (Sandbox Code Playgroud)

玩家可能试图杀死、攻击、破坏等某人,我想使用他/她使用的确切动词。

另外:是否有一个列表,列出了在打印响应时可以在 [] 中使用的所有标准项目?

小智 5

解析器并没有真正的“动词”概念,它只将命令与具有一些特殊标记(通常是名词)的模式匹配,但动词不是其中之一。

另请注意,解析器在对原始命令进行标记化后将其丢弃:换句话说,[the noun]它实际上并不包含玩家使用的单词,而是名词的打印名称。所以如果你有:

The dragon is an animal. Understand "beast" as the dragon.
Run Code Online (Sandbox Code Playgroud)

并且玩家输入>ATTACK BEAST,然后[the noun]仍然会打印“dragon”。

你有几个选择:

  • 再模糊点。例如:“你想怎么做?” 这是实践中最常用的选项。

  • 取玩家命令的第一个单词并假设它是动词:

say "How do you want to [word number 1 in the player's command] [the noun]?";
Run Code Online (Sandbox Code Playgroud)

这是不推荐使用,因为它不能保证第一个字实际上是动词。如果玩家命令 >GO NORTH THEN KILL DRAGON 或 >AGAIN 会怎样?游戏会问“你想怎么去龙?” 或者“你想怎么再龙?”

  • 将攻击动作拆分为多个部分,这样您就可以确定玩家使用了哪一个。
Hitting is an action applying to one thing.
Understand the command "hit" as something new.
Understand "hit [something]" as hitting.

Instead of hitting:
   say "How do you want to hit [the noun]?"
Run Code Online (Sandbox Code Playgroud)

我也不会这样做,因为有更好的选择......

  • 如果您正确创建了“攻击方式”操作,Inform 已经内置了此功能。
Attacking it with is an action applying to two things.
Understand the commands "attack" and "hit" as something new.
Understand "attack [something] with [something]" as attacking it with.
Understand "hit [something] with [something]" as attacking it with.
[and so on]
Run Code Online (Sandbox Code Playgroud)

现在 Inform 会自动询问“你想用什么攻击/击中/杀死龙?” 取决于玩家使用的动词。

这也比原来的“代替”方法好得多,因为现在玩家可以只用一个词(“> SWORD”)来回答问题——如果他们用代替规则来做,解析器就不会理解他们的意思。