From 5ca76c340c9f74fbadea1b5e2a95bd683219e839 Mon Sep 17 00:00:00 2001 From: kbulgrien Date: Fri, 14 Nov 2008 01:28:30 +0000 Subject: [PATCH] Like the @match system, CFDialog now converts both match strings and things the player says to lowercase before checking for a match. git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@10421 282e977c-c81d-0410-88c4-b93c2d0d6712 --- python/CFDialog.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/python/CFDialog.py b/python/CFDialog.py index 1965ca7ba..f9de78ced 100644 --- a/python/CFDialog.py +++ b/python/CFDialog.py @@ -78,6 +78,9 @@ # You can then add the rules you created to the dialog. Rules are parsed in # a given order, so you must add the most generic answer last. # +# Like the @match system, CFDialog converts both match strings and the things +# the player says to lowercase before checking for a match. +# # A simple example #================= # I want to create a dialog for an old man. If I say "hello" or "hi" for the @@ -115,6 +118,11 @@ # rmsg = ["What ?", "Huh ?", "What do you want ?"] # speech.addRule(DialogRule("*", prer, rmsg, postr),2) # +# A complete example that shows how to modify an actual in-game map may be +# found on the wiki: +# +# http://wiki.metalforge.net/doku.php/cfdialog?s=cfdialog#a_simple_example +# import Crossfire import string import random @@ -161,12 +169,13 @@ class Dialog: self.setConditions(rule) return 0 return 1 + def isAnswer(self,msg, keyword): if keyword=="*": return 1 keys=string.split(keyword,"|") for ckey in keys: - if string.find(msg,ckey)!=-1: + if string.find(msg.lower(),ckey.lower())!=-1: return 1 return 0