Inform7互动小说开发:如何让NPC Auto-Doc响应玩家say ah指令
Inform7 Auto-Doc对话触发问题解决方案
错误原因
你原代码报错的核心原因是Inform7标准规则集未内置speaking通用动作,玩家输入的say [文本]指令默认没有对应的统一动作规则可以捕获,所以你尝试的After speaking这类写法无法通过编译。
通用回复实现(所有在场发言都触发Auto-Doc回应)
以下代码先自定义了speaking动作,将所有玩家输入的say类指令统一归入该动作,只要Auto-Doc在同一场景就会触发固定回复,完全满足你最低需求:
The exam table is a supporter in the Med Bay. It is fixed in place and enterable. In the Med Bay is a person called Auto-Doc. After entering the exam table, say "A number of bright lights embedded in an overhead panel bathe you in a cold, white light. A panel in the wall opens and an auto-doc trundles forth on a three-wheeled base. Clutching a tongue depressor in its mechanical grip, a small speaker hidden within crackles with the words 'Say, ah.'" Understand "say [text]" as speaking. Speaking is an action applying to one topic. Carry out speaking: say "You say '[the topic understood]'." After speaking when Auto-Doc is in the location: say "The Auto-Doc's speaker crackles in response: 'Mmm. Mm-hmm. Very interesting.'" Instead of telling Auto-Doc about something: try speaking the topic understood instead.
该代码兼容玩家两种输入习惯:输入say ah或者say ah to auto-doc都会触发对应回复。
定向回复实现(仅识别“ah”触发回应)
如果需要仅当玩家说ah的时候触发Auto-Doc的回应,其他发言保持默认逻辑,替换上述代码中的After speaking规则即可:
After speaking when Auto-Doc is in the location: if the topic understood matches "ah": say "The Auto-Doc's speaker crackles in response: 'Mmm. Mm-hmm. Very interesting.' It retracts the tongue depressor and begins rolling back to its wall panel."; otherwise: continue the action.
内容的提问来源于stack exchange,提问作者Dave H.
相关产品推荐
相关产品推荐

