From cb381c6b26eec7f5d5c037556dff30693a3bd8b8 Mon Sep 17 00:00:00 2001 From: kbulgrien Date: Fri, 21 Nov 2008 07:43:24 +0000 Subject: [PATCH] - 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 --- python/misc/npc_dialog.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/python/misc/npc_dialog.py b/python/misc/npc_dialog.py index 40f3a8b6a..9ab6c8d29 100644 --- a/python/misc/npc_dialog.py +++ b/python/misc/npc_dialog.py @@ -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())