Пример #1
0
def genWarpLocs(readfile="warps_insert.j",
                headerfile="locations_header.j",
                keyword="//insert",
                cwd="lua"):
    cwd = util.find(cwd, util.root)
    writefile = util.find(headerfile.replace("_header", "_insert"), util.root)
    headerfile = util.find(headerfile, util.root)
    names = util.getInsertFileData(readfile)[0]
    globalsStr = ""
    insertStr = ""
    for nameData in names:
        data = nameData.split("|")
        name = data[0]
        locName = name + " loc"
        idName = name + " id"
        if name not in special:
            globalsStr += "\tlocation " + util.name2Var(locName) + "\n"
            insertStr += "\tset " + util.name2Var(
                locName) + " = getNPCLoc(" + util.name2Var(idName) + ")\n"
    w = open(headerfile, 'r')
    t = w.read()
    w.close()
    t = t.replace("//globals", globalsStr)
    t = t.replace("//insert", insertStr)
    w = open(writefile, 'w')
    print >> w, t
    w.close()
Пример #2
0
def genWarpInit(readfile="warps_insert.j",
                headerfile="warp_init_header.j",
                keyword="//insert",
                cwd="lua"):
    cwd = util.find(cwd, util.root)
    writefile = util.find(headerfile.replace("_header", "_insert"), util.root)
    headerfile = util.find(headerfile, util.root)
    names = util.getInsertFileData(readfile)[0]
    insertStr = ""
    for nameData in names:
        data = nameData.split("|")
        name = data[0]
        exitName = name + " exit"
        isActive = "true"
        if len(data) > 1:
            isActive = data[1]
        if name not in special and getIsExit.findall(name) == []:
            insertStr += "\t\tset w = Warp.create(\"" + exitName + " to " + name + "\", " + util.name2Var(
                name) + "_LOC)\n"
            insertStr += "\t\tset playerDatum[i].warps[" + util.name2Var(
                exitName) + "] = w\n"
            insertStr += "\t\tset w = Warp.create(\"" + name + " to " + exitName + "\", " + util.name2Var(
                exitName) + "_LOC)\n"
            insertStr += "\t\tset playerDatum[i].warps[" + util.name2Var(
                name) + "] = w\n"
            if isActive == "false":
                insertStr += "\t\tset w.isActive = false\n"
    w = open(headerfile, 'r')
    t = w.read()
    w.close()
    t = t.replace("//insert", insertStr)
    w = open(writefile, 'w')
    print >> w, t
    w.close()
Пример #3
0
def genWarpInit(readfile = "warps_insert.j", headerfile = "warp_init_header.j",  keyword = "//insert", cwd = "lua"):
    cwd = util.find(cwd, util.root)
    writefile = util.find(headerfile.replace("_header", "_insert"), util.root)
    headerfile = util.find(headerfile, util.root)
    names = util.getInsertFileData(readfile)[0]
    insertStr = ""
    for nameData in names:
        data = nameData.split("|")
        name = data[0]
        exitName = name + " exit"
        isActive = "true"
        if len(data) > 1:
            isActive = data[1]
        if name not in special and getIsExit.findall(name) == []:
            insertStr += "\t\tset w = Warp.create(\"" + exitName + " to " + name + "\", " + util.name2Var(name) + "_LOC)\n"
            insertStr += "\t\tset playerDatum[i].warps[" + util.name2Var(exitName) + "] = w\n"
            insertStr += "\t\tset w = Warp.create(\"" + name + " to " + exitName + "\", " + util.name2Var(exitName) + "_LOC)\n"
            insertStr += "\t\tset playerDatum[i].warps[" + util.name2Var(name) + "] = w\n"
            if isActive == "false":
                    insertStr += "\t\tset w.isActive = false\n"
    w = open(headerfile, 'r')
    t = w.read()
    w.close()
    t = t.replace("//insert", insertStr)
    w = open(writefile, 'w')
    print>>w, t
    w.close()
Пример #4
0
def rawCns(insertFile, constantsFile, suffix = "id"):
    """Takes an insert file as an argument and creates a vJASS library,
    which contains each of the objects' rawcodes represented as
    JASS constant integers."""
    data = util.getInsertFileData(insertFile)
    names = [x.split("|")[0] for x in data[0]]
    ids = data[1]
    if len(names) != len(ids):
        print "Error: The size of names and ids is not the same!"
        return
    #build the first part of the library
    header = "library " + util.name2Lib(insertFile.replace("_insert.j", "") + suffix) + "Constants\n"
    header = header.replace("_", "")
    header += "globals\n"
    #now for each name, create a constant integer
    for x in range(0, len(names)):
        header += "\tconstant integer " + util.name2Var(names[x] + "_" + suffix) + " = \'" + ids[x] + "\'\n"
    header += "endglobals\nendlibrary"
    path = os.path.join(CONSTANTS_DIR, constantsFile)
    w = open(path, 'w')
    print>>w, header
    w.close()
Пример #5
0
def genWarpLocs(readfile = "warps_insert.j", headerfile = "locations_header.j",  keyword = "//insert", cwd = "lua"):
    cwd = util.find(cwd, util.root)
    writefile = util.find(headerfile.replace("_header", "_insert"), util.root)
    headerfile = util.find(headerfile, util.root)
    names = util.getInsertFileData(readfile)[0]
    globalsStr = ""
    insertStr = ""
    for nameData in names:
        data = nameData.split("|")
        name = data[0]
        locName = name + " loc"
        idName = name + " id"
        if name not in special:
            globalsStr += "\tlocation " + util.name2Var(locName) + "\n"
            insertStr += "\tset " + util.name2Var(locName) + " = getNPCLoc(" +  util.name2Var(idName) + ")\n"
    w = open(headerfile, 'r')
    t = w.read()
    w.close()
    t = t.replace("//globals", globalsStr)
    t = t.replace("//insert", insertStr)
    w = open(writefile, 'w')
    print>>w, t
    w.close()