Fix script conditions, round 2.
git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@21648 282e977c-c81d-0410-88c4-b93c2d0d6712master
parent
9dbb9fdaa9
commit
02f585973c
|
@ -268,12 +268,14 @@ class Dialog:
|
|||
for condition in rule.getPreconditions():
|
||||
action = condition[0]
|
||||
args = condition[1:]
|
||||
script_args = {'args': args, 'character': character, 'location': location, 'action': action, 'self': self}
|
||||
path = os.path.join(Crossfire.DataDirectory(), Crossfire.MapDirectory(), 'python/dialog/pre/', action + '.py')
|
||||
if os.path.isfile(path):
|
||||
try:
|
||||
exec(open(path).read(), globals())
|
||||
except:
|
||||
Crossfire.Log(Crossfire.LogError, "CFDialog: Failed to evaluate condition %s." % condition)
|
||||
exec(open(path).read(), {}, script_args)
|
||||
verdict = script_args['verdict']
|
||||
except Exception as ex:
|
||||
Crossfire.Log(Crossfire.LogError, "CFDialog: Failed to evaluate condition %s: %s." % (condition, str(ex)))
|
||||
verdict = False
|
||||
if verdict == False:
|
||||
return 0
|
||||
|
|
Loading…
Reference in New Issue