twoolie / NBT

Python Parser/Writer for the NBT file format, and it's container the RegionFile.
MIT License
365 stars 74 forks source link

Issues with TAG_List(type= TAG_Compound()) #85

Closed Omeganx closed 9 years ago

Omeganx commented 9 years ago

So I'm having this problem, I think the problem comes from me but that seems so illogical, So I'll leave that here hoping someone would help me. If I replace vill = TAG_List(type = TAG_Compound() with an other tag type, for example vill = TAG_List(type = TAG_Int()) It will work... (Please notice that's I'm just a python beginner) the code:

import nbt
from nbt.nbt import *
villages = NBTFile()
villages.name = "Data"
data = TAG_Compound()
data.tags.extend([
    TAG_Int(name="Tick", value=14694297)
    ])

vill = TAG_List(type = TAG_Compound())

vill.name = "Villages"
villages.tags.append(vill)
villages.tags.append(data)

print(villages.pretty_tree())

The Error message:

Traceback (most recent call last):
  File "C:\Users\Tom\Desktop\NBT-master\my files\VillageStacker_1.py", line 12, in <module>
    vill = TAG_List(type = TAG_Compound())
  File "C:\Python34\lib\site-packages\nbt-1.4.1-py3.4.egg\nbt\nbt.py", line 306, in __init__
    raise ValueError("No type specified for list: %s" % (name))
ValueError: No type specified for list: None
macfreek commented 9 years ago

Hi Omeganx,

The type parameter in TAG_List should be a class, not an instance. If you replace vill = TAG_List(type = TAG_Compound()) with vill = TAG_List(type = TAG_Compound), things may work. Let me know if that works for you!

I must admit that the error message is not very informative. Any suggestion for a more helpful message are appreciated :)

import nbt
from nbt.nbt import *
villages = NBTFile()
villages.name = "Data"
data = TAG_Compound()
data.tags.extend([
    TAG_Int(name="Tick", value=14694297)
])

vill = TAG_List(type = TAG_Compound)

vill.name = "Villages"
villages.tags.append(vill)
villages.tags.append(data)

print(villages.pretty_tree())
Omeganx commented 9 years ago

Yeah It does work. Thank you a lot, you replied so quickly. Ah ah, I don't really know about the error message, as I said I'm just a beginner, and I thought it would help with the error message. and again, thanks for the time you took to answer me.