diff --git a/python/CFDialog.py b/python/CFDialog.py index 3d9640f80..c5ac859a9 100644 --- a/python/CFDialog.py +++ b/python/CFDialog.py @@ -132,6 +132,7 @@ class DialogRule: self.__messages = messages self.__postsems = postsemaphores self.__suggestions = suggested_response + self.__prefunction = None # The keyword is a string. Multiple keywords may be defined in the string # by delimiting them with vertical bar (|) characters. "*" is a special @@ -165,6 +166,14 @@ class DialogRule: def getSuggests(self): return self.__suggestions + # Return a possible pre function, that will be called to ensure the rule matches. + def getPreFunction(self): + return self.__prefunction + + # Define a prefunction that will be called to match the rule. + def setPreFunction(self, function): + self.__prefunction = function + # This is a subclass of the generic dialog rule that we use for determining whether to # 'include' additional rules. class IncludeRule(DialogRule): @@ -270,6 +279,10 @@ class Dialog: else: Crossfire.Log(Crossfire.LogError, "CFDialog: Pre Block called with unknown action %s." % action) return 0 + + if rule.getPreFunction() != None: + if rule.getPreFunction()(self.__character, rule) != True: + return 0 return 1