Ported Buurazu's "IsaacXMLToLua" tool to python and added pocketitems to its tasks
This commit is contained in:
1 parent
ef711a54b4
commit
fe6a1fb9da
4 files changed
+187
-38
No files matched your search
@@ -0,0 +1,142 @@
|
||||
# This tool generates the lookup tables we need to display additional informations.
|
||||
# YOU DONT HAVE TO RUN THIS FILE YOURSELF! THE RESULTING DATA IS SHIPPED WITH THE MOD ALREADY!
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
filePath = "D:\\Programme\\Steam\\steamapps\\common\\The Binding of Isaac Rebirth\\resources-dlc3\\"
|
||||
|
||||
# take second element for sort
|
||||
def sortByID(elem):
|
||||
return elem["id"]
|
||||
recipies = []
|
||||
itemQuality = []
|
||||
itempools = {}
|
||||
itemIDToPool = {}
|
||||
maxItemID = 0
|
||||
cardMetadatas = []
|
||||
pillMetadatas = []
|
||||
|
||||
recipeIngredients = {}
|
||||
#Poop, Penny
|
||||
recipeIngredients["_"] = 29
|
||||
recipeIngredients["."] = 8
|
||||
#Red, Soul, Black Heart
|
||||
recipeIngredients["h"] = 1
|
||||
recipeIngredients["s"] = 2
|
||||
recipeIngredients["b"] = 3
|
||||
#Key, Bomb, Card
|
||||
recipeIngredients["/"] = 12
|
||||
recipeIngredients["v"] = 15
|
||||
recipeIngredients["["] = 21
|
||||
#Gold Heart, Eternal Heart, Pill
|
||||
recipeIngredients["g"] = 5
|
||||
recipeIngredients["e"] = 4
|
||||
recipeIngredients["("] = 22
|
||||
#Rotten Heart, Gold Key, Giga Bomb
|
||||
recipeIngredients["r"] = 7
|
||||
recipeIngredients["|"] = 13
|
||||
recipeIngredients["V"] = 17
|
||||
#Gold Bomb, Bone Heart
|
||||
recipeIngredients["^"] = 16
|
||||
recipeIngredients["B"] = 6
|
||||
#Dice Shard, Cracked Key
|
||||
recipeIngredients["?"] = 24
|
||||
recipeIngredients["~"] = 25
|
||||
|
||||
# Read recipes.xml
|
||||
recipesXML = ET.parse(filePath+'recipes.xml').getroot()
|
||||
for recipe in recipesXML.findall('recipe'):
|
||||
input = recipe.get('input')
|
||||
convertedInput = ""
|
||||
for char in input:
|
||||
convertedInput += str(recipeIngredients[char])+","
|
||||
recipies.append({"input": convertedInput.rstrip(","), "output": recipe.get('output')})
|
||||
|
||||
# Read items_metadata.xml
|
||||
items_metadataXML = ET.parse(filePath+'items_metadata.xml').getroot()
|
||||
for item in items_metadataXML.findall('item'):
|
||||
id = int(item.get('id'))
|
||||
if maxItemID < id:
|
||||
maxItemID = id
|
||||
itemIDToPool[id] = []
|
||||
itemQuality.append({"id": id, "quality": item.get('quality')})
|
||||
|
||||
# Read itempools.xml
|
||||
itempoolsXML = ET.parse(filePath+'itempools.xml').getroot()
|
||||
currentpool = 0
|
||||
for pool in itempoolsXML.findall('Pool'):
|
||||
items = []
|
||||
for item in pool.findall('Item'):
|
||||
id = int(item.get('Id'))
|
||||
items.append([id,float(item.get('Weight'))])
|
||||
itemIDToPool[id].append(currentpool)
|
||||
itempools[pool.get("Name")] = items
|
||||
currentpool += 1
|
||||
|
||||
# Read pocketitems.xml
|
||||
pocketitemsXML = ET.parse(filePath+'pocketitems.xml').getroot()
|
||||
|
||||
for card in pocketitemsXML.findall('card'):
|
||||
cardMetadatas.append({ "id": card.get('id'), "mimiccharge": card.get('mimiccharge', 0)})
|
||||
|
||||
for rune in pocketitemsXML.findall('rune'):
|
||||
cardMetadatas.append({ "id": rune.get('id'), "mimiccharge": rune.get('mimiccharge', 0)})
|
||||
cardMetadatas.sort(key=sortByID)
|
||||
|
||||
for pilleffect in pocketitemsXML.findall('pilleffect'):
|
||||
pillMetadatas.append({ "id": pilleffect.get('id'), "mimiccharge": pilleffect.get('mimiccharge', 0), "class":pilleffect.get('class')})
|
||||
pillMetadatas.sort(key=sortByID)
|
||||
|
||||
|
||||
#Write xml file
|
||||
|
||||
newfile = open("eid_xmldata.lua", "w")
|
||||
newfile.write("--This file was autogenerated using 'lookuptable_generator.py' found in the scripts folder\n")
|
||||
newfile.write("--It will have to be updated whenever the game's item XML files are updated\n")
|
||||
|
||||
|
||||
newfile.write("--The highest item ID found\n")
|
||||
newfile.write("EID.XMLMaxItemID = "+str(maxItemID) + "\n")
|
||||
|
||||
|
||||
newfile.write("--The fixed recipes, for use in Bag of Crafting\n")
|
||||
newfile.write("EID.XMLRecipes = {")
|
||||
for recipe in recipies:
|
||||
newfile.write("[\""+recipe["input"]+"\"] = "+str(recipe["output"])+", ")
|
||||
newfile.write("}\n\n")
|
||||
|
||||
|
||||
newfile.write("--The contents of each item pool, and the item's weight, for use in Bag of Crafting\n")
|
||||
newfile.write("EID.XMLItemPools = {")
|
||||
for poolName, data in itempools.items():
|
||||
newfile.write(""+str(data).replace("[","{").replace("]","}")+", -- "+poolName+"\n")
|
||||
newfile.write("}\n\n")
|
||||
|
||||
|
||||
newfile.write("--The quality of each item, for use in Bag of Crafting\n")
|
||||
newfile.write("EID.XMLItemQualities = {")
|
||||
for item in itemQuality:
|
||||
newfile.write("["+str(item["id"])+"] = "+str(item["quality"])+", ")
|
||||
newfile.write("}\n\n")
|
||||
|
||||
|
||||
newfile.write("--The pools that each item is in, for roughly checking if a given item is unlocked\n")
|
||||
newfile.write("EID.XMLItemIsInPools = {")
|
||||
for itemid, data in itemIDToPool.items():
|
||||
newfile.write("["+str(itemid)+"] = "+str(data).replace("[","{").replace("]","}")+", ")
|
||||
newfile.write("}\n\n")
|
||||
|
||||
|
||||
newfile.write("--Metadata found in Pocketitems.xml\n")
|
||||
newfile.write("EID.cardMetadata = {")
|
||||
for card in cardMetadatas:
|
||||
newfile.write("["+card["id"]+"] = {mimiccharge="+str(card["mimiccharge"])+"}, ")
|
||||
newfile.write("}\n\n")
|
||||
|
||||
newfile.write("EID.pillMetadata = {")
|
||||
|
||||
|
||||
for pill in pillMetadatas:
|
||||
newfile.write("["+pill['id']+"] = {mimiccharge="+str(pill['mimiccharge'])+", class=\""+str(pill['class'])+"\"}, ")
|
||||
|
||||
newfile.write("}\n")
|
||||
Reference in new issue
Block a user