Hey there! So I have been creating a Minecraft version of Apples to Apples and while naming the cards, I messed up until halfway through by making the text bold, so I have been editing SethBling's 'Modify Item Strings' filter to a 'Replace Item Codes' filter. What I want it to do is you select a 'find' color/code and a 'replace' color/code, then look at all the 'cards' in the selection box, and basically change the color code. Example: You select a chest and then select the 'Find: Bold' option, and select the 'Replace: White' (which would reset it to the regular code). And then it would look for any items with bold text, and reset it. It is currently busted though. Please help:
# coding unicode-escape
# ColorArmor Filter by SethBling
# Feel free to modify and reuse, but credit to SethBling would be nice.
# http://youtube.com/SethBling
from pymclevel import MCSchematic
from pymclevel import TileEntity
from pymclevel import TAG_Compound
from pymclevel import TAG_Short
from pymclevel import TAG_Byte
from pymclevel import TAG_String
from pymclevel import TAG_Int
from pymclevel import TAG_List
from numpy import zeros
displayName = "Replace Item Code"
Colors = {
"Black": "0",
"Dark Blue": "1",
"Dark Green": "2",
"Dark Aqua": "3",
"Dark Red": "4",
"Purple": "5",
"Gold": "6",
"Gray": "7",
"Dark Gray": "8",
"Indigo": "9",
"Bright Green": "a",
"Aqua": "b",
"Red": "c",
"Pink": "d",
"Yellow": "e",
"White": "f",
"Bold": "l",
"Strike": "m",
"Underlined": "n",
"Italics": "o",
}
inputs = (
("Find: Color", tuple(Colors.keys())),
("Replace: Color", tuple(Colors.keys())),
)
formatCode = unichr(167)
def perform(level, box, options):
findcolor = Colors[options["Find: Color"]]
replacecolor = Colors[options["Replace: Color"]]
for (chunk, slices, point) in level.getChunkSlices(box):
for te in chunk.TileEntities:
px = te["x"].value
py = te["y"].value
pz = te["z"].value
if px < box.minx or px >= box.maxx:
continue
if py < box.miny or py >= box.maxy:
continue
if pz < box.minz or pz >= box.maxz:
continue
if te["id"].value == "Trap" or te["id"].value == "Chest":
for item in te["Items"]:
doneText = item["tag"]["display"]["Name"]
print doneText
if "tag" not in item:
item["tag"] = TAG_Compound()
if "display" not in item["tag"]:
item["tag"]["display"] = TAG_Compound()
doneText.replace("findcolor", "replacecolor");
print doneText
item["tag"]["display"]["Name"] = doneText
chunk.dirty = True
Did you test this? It won't work for meOh and BTW you are spot on that I have really no clue what I am doing. I did do a SMALL amount of python a while ago...
Indents are messed up of course. I am trying to make it so that this works on the 'Lore' tags. I have it all figured out but I have no clue how to edit the Lore because of the way it is stored differently than 'Name' Think you can help?
# Replace Item Code Filter based on ColorArmor Filter by SethBling
# First Edit by Howzieky_10, correction and bug fixing by medi4
from pymclevel import MCSchematic
from pymclevel import TileEntity
from pymclevel import TAG_Compound
from pymclevel import TAG_Short
from pymclevel import TAG_Byte
from pymclevel import TAG_String
from pymclevel import TAG_Int
from pymclevel import TAG_List
from numpy import zeros
displayName = "Replace Item Code help"
Colors = {
"Black": "0",
"Dark Blue": "1",
"Dark Green": "2",
"Dark Aqua": "3",
"Dark Red": "4",
"Purple": "5",
"Gold": "6",
"Gray": "7",
"Dark Gray": "8",
"Indigo": "9",
"Bright Green": "a",
"Aqua": "b",
"Red": "c",
"Pink": "d",
"Yellow": "e",
"White": "f",
"Bold": "l",
"Strike": "m",
"Underlined": "n",
"Italics": "o",
}
Choices = {
"Lore": "lo",
"Name": "Na",
}
inputs = (
("Name:", False),
("Lore:", False),
("Find:", tuple(Colors.keys())),
("Replace:", tuple(Colors.keys())),
)
formatCode = unichr(167)
def perform(level, box, options):
findcolor = Colors[options["Find:"]]
replacecolor = Colors[options["Replace:"]]
#choice = Choices[options["Find/Replace:"]]
for (chunk, slices, point) in level.getChunkSlices(box):
for te in chunk.TileEntities:
px = te["x"].value
py = te["y"].value
pz = te["z"].value
if px < box.minx or px >= box.maxx:
continue
if py < box.miny or py >= box.maxy:
continue
if pz < box.minz or pz >= box.maxz:
continue
if te["id"].value == "Trap" or te["id"].value == "Chest":
for item in te["Items"]:
if options["Name:"]:
doneText = item["tag"]["display"]["Name"].value
doneText = doneText.replace(unichr(167) + findcolor, unichr(167) + replacecolor)
item["tag"]["display"]["Name"] = TAG_String(doneText)
#if options["Lore:"]:
# doneText = item["tag"]["display"]["Lore"].value
#
# doneText = doneText.replace(unichr(167) + findcolor, unichr(167) + replacecolor)
#
# item["tag"]["display"]["Lore"] = TAG_String(doneText)
#I hope you understand what I am trying to do here.
chunk.dirty = True
Yeah so it will have checkboxes that say 'Lore' and 'Name' you understand I see. Would you like me to put it in a file your you to download? It wouldnt keep messing with the indents.
MCEdit Filter: Replace Item Codes