Closed ghost closed 8 years ago
This error is thrown if you try to load a mapblock that has never been generated. Your only solution is to catch the Exception and initiate an empty mapblock using MapInterface.init_mapblock(mapblockpos, override=False)
. You don't really need to set the override
parameter since it only prevents the function from creating an empty mapblock where a generated mapblock exists.
I added a line for init_mapblock, see the gist, now I am getting an error:
D:\minetest\minetest-0.4.13\python-minetest\src>python demo_map_preloading.py .. \..\worlds\b\map.sqlite ..\..\mods\realterrain\rasters\dem.bmp 2016-03-29 14:36:29,842 map:set_maxcachesize :576 DEBUG MapVessel's maximum cache size set to 100 Traceback (most recent call last): File "demo_map_preloading.py", line 53, indb.init_mapblock(mapblockpos, override=True) File "D:\minetest\minetest-0.4.13\python-minetest\src\map.py", line 712, in in it_mapblock res = self.interface.load(mapblockpos) File "D:\minetest\minetest-0.4.13\python-minetest\src\map.py", line 526, in lo ad if not self.cache.get(blockID): TypeError: unhashable instance
You need to give an integer represention of the mapblock's position to init_mapblock
. I'll add assertations to check types so that those errors appear obvious. I'll also start writing documentation.
mapblock = libminetest.utils.intFromPos(libminetest.map.determineMapBlock(pos), 4096)
I have made a script that tries to load the contents of an image into the map.sqlite but am getting stuck on line 626 of map.py throwing an error. I am only just starting to play with your library so maybe I am misunderstanding the usage. I have tried this with a fresh map.sqlite from a new world, and have also tried emptying the contents of the blocks table with an sqlite manager tool, same error... the script is at https://gist.github.com/bobombolo/d243ccf2d03224d10cab traceback: