scayze / MagicaVoxel-Importer

An Plugin for the GodotEngine to import MagicaVoxel's .vox format as meshes.
MIT License
55 stars 10 forks source link

I had import issues, for some reason this fixed it #13

Open ISebSej opened 3 years ago

ISebSej commented 3 years ago

I had some errors with importing .vox files. Changing line 138 onwards with this fixed my problem. In case anyone else runs into them.

It gave me a "you can't subtract an int from a string you stupid" error, so now I check if voxColors[data[i].color] is a hex string first

            # now push the voxel data into our voxel chunk structure
            for i in range(0,data.size()):
                # use the voxColors array by default, or overrideColor if it is available
                if colors == null:
                    if typeof(voxColors[data[i].color]) == 4: # check if string
                        data[i].color = Color(voxColors[data[i].color])
                    else:
                        data[i].color = Color(voxColors[data[i].color]-1)
                else:
                    data[i].color = colors[data[i].color-1]