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():
|
for condition in rule.getPreconditions():
|
||||||
action = condition[0]
|
action = condition[0]
|
||||||
args = condition[1:]
|
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')
|
path = os.path.join(Crossfire.DataDirectory(), Crossfire.MapDirectory(), 'python/dialog/pre/', action + '.py')
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
try:
|
try:
|
||||||
exec(open(path).read(), globals())
|
exec(open(path).read(), {}, script_args)
|
||||||
except:
|
verdict = script_args['verdict']
|
||||||
Crossfire.Log(Crossfire.LogError, "CFDialog: Failed to evaluate condition %s." % condition)
|
except Exception as ex:
|
||||||
|
Crossfire.Log(Crossfire.LogError, "CFDialog: Failed to evaluate condition %s: %s." % (condition, str(ex)))
|
||||||
verdict = False
|
verdict = False
|
||||||
if verdict == False:
|
if verdict == False:
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Reference in New Issue