我从我正在编辑的 MCEDit 过滤器中获得了这段代码:
def getCommand(level, box):
for x in xrange(box.minx,box.maxx):
for y in xrange(box.miny,box.maxy):
for z in xrange(box.minz,box.maxz):
t = level.tileEntityAt(x, y, z)
if t and t["id"].value == "Control":
if "id" in t: del t["id"]
if "x" in t: del t["x"]
if "y" in t: del t["y"]
if "z" in t: del t["z"]
return (t, x, y, z)
return (None, None, None, None)
我得到这个错误:
'KeyError: 'Key x not found.'
请帮忙!
编辑:
已修复,感谢@Texelelf:
def getCommand(level, box):
for x in xrange(box.minx,box.maxx):
for y in xrange(box.miny,box.maxy):
for z in xrange(box.minz,box.maxz):
t = deepcopy(level.tileEntityAt(x,y,z))
if t and t["id"].value == "Control":
if "id" in t: del t["id"]
if "x" in t: del t["x"]
if "y" in t: del t["y"]
if "z" in t: del t["z"]
return (t, x, y, z)
return (None, None, None, None)