Allow include blocks to use either relative or absolute paths to reference other .msg files.
Maps still need to specify a full path in the slaying field of an event say. git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@13121 282e977c-c81d-0410-88c4-b93c2d0d6712master
parent
1c6503f49c
commit
96d5f0fd05
|
@ -47,13 +47,16 @@ import cjson
|
||||||
|
|
||||||
location = "defaultdialognamespace"
|
location = "defaultdialognamespace"
|
||||||
|
|
||||||
def parseJSON(filename):
|
def parseJSON(filename, relpath):
|
||||||
global location
|
global location
|
||||||
parameters = []
|
parameters = []
|
||||||
for filenm in filename:
|
for filenm in filename:
|
||||||
|
if filenm[0] == "/":
|
||||||
filepath = os.path.join(Crossfire.DataDirectory(),
|
filepath = os.path.join(Crossfire.DataDirectory(),
|
||||||
Crossfire.MapDirectory(),
|
Crossfire.MapDirectory(), filenm[1:])
|
||||||
filenm)
|
else:
|
||||||
|
filepath = os.path.join(Crossfire.DataDirectory(),
|
||||||
|
Crossfire.MapDirectory(), relpath, filenm)
|
||||||
try:
|
try:
|
||||||
f = open(filepath,'rb')
|
f = open(filepath,'rb')
|
||||||
except:
|
except:
|
||||||
|
@ -79,7 +82,7 @@ def parseJSON(filename):
|
||||||
if shouldinclude == 1:
|
if shouldinclude == 1:
|
||||||
# this isn't a 'real' rule, so we don't include it, but we do
|
# this isn't a 'real' rule, so we don't include it, but we do
|
||||||
# include the results of parsing it.
|
# include the results of parsing it.
|
||||||
parameters.extend(parseJSON(newfiles))
|
parameters.extend(parseJSON(newfiles, os.path.dirname(filepath)))
|
||||||
else:
|
else:
|
||||||
Crossfire.Log(Crossfire.LogDebug, "Ignoring NPC dialog from %s, conditions not met" % newfiles)
|
Crossfire.Log(Crossfire.LogDebug, "Ignoring NPC dialog from %s, conditions not met" % newfiles)
|
||||||
else:
|
else:
|
||||||
|
@ -91,7 +94,7 @@ npc = Crossfire.WhoAmI()
|
||||||
player = Crossfire.WhoIsActivator()
|
player = Crossfire.WhoIsActivator()
|
||||||
if (Crossfire.ScriptParameters() != None):
|
if (Crossfire.ScriptParameters() != None):
|
||||||
filename = Crossfire.ScriptParameters()
|
filename = Crossfire.ScriptParameters()
|
||||||
dialogs = parseJSON([filename])
|
dialogs = parseJSON([filename], '')
|
||||||
speech = Dialog(player, npc, location)
|
speech = Dialog(player, npc, location)
|
||||||
index = 0;
|
index = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue