- More clearly document how to write JSONs when pre or postconditions are not

needed by a particular rule.  For the inexperienced, this was a showstopper.
- Dispense with the user defined exception and replace the old handling with a
  more effective debug log message combined with a generic exception.


git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@10636 282e977c-c81d-0410-88c4-b93c2d0d6712
master
kbulgrien 2008-11-21 07:43:24 +00:00
parent 5308835604
commit cb381c6b26
1 changed files with 5 additions and 12 deletions

View File

@ -85,8 +85,9 @@
# response is triggered.
#
# All of the rule values are lists, and must be enclosed by square braces, but
# pre and post are lists of lists, so the double square braces ([[]]) are
# required.
# pre and post are lists of lists, so the nested square braces ([[]]) are
# required except that using an empty list [] is the best way to indicate when
# the rule does not need to check preconditions or set postconditions.
#
# "msg" defines one or more responses that will be given if the rule triggers.
# When more than one "msg" value is set up, the NPC randomly selects which one
@ -104,15 +105,6 @@ import os
from CFDialog import DialogRule, Dialog
import cjson
# Avoid DeprecationWarning: raising a string exception is deprecated by making
# a user-defined exception handler.
#
class NPC_Dialog_Error(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
def ruleConnected(character,rule):
m = character.Map
m.TriggerConnected(rule.connected,1)
@ -124,7 +116,8 @@ if (Crossfire.ScriptParameters() != None):
try:
f = open(filename,'rb')
except:
NPC_Dialog_Error('Error loading NPC dialog %s' % filename)
Crossfire.Log(Crossfire.LogDebug, "Error loading NPC dialog %s" % filename)
raise
else:
Crossfire.Log(Crossfire.LogDebug,"Loading NPC dialog %s" %filename)
parameters=cjson.decode(f.read())