Add a 'prefunction' to rules to have special processing.
git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@13163 282e977c-c81d-0410-88c4-b93c2d0d6712master
parent
b66dcbeb89
commit
0d07667c50
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue