Lymkwi / python-minetest

A python library to manipulate minetest's files
6 stars 3 forks source link

debug statements weird #8

Closed ghost closed 8 years ago

ghost commented 8 years ago

init_mapblock and map:save debug statements are showing the integer position as the x part of the position for blocks:

2016-04-05 14:44:51,859 map:save_mapblock            :614  DEBUG    Saving block
 at pos 3988 (3988, 0, 0)

and

2016-04-05 14:47:58,906 map:__init__                 :35   DEBUG    MapBlock obj
ect initiated at (4016, 0, 0)
Lymkwi commented 8 years ago

getAsInt's default value for max_val (the maximum, unreachable coordinate in the container) is 16. When you use a Pos object to refer to a mapblock, the container is the map, and the map can contain up to 4096*2 mapblocks (negative and positive) in all directions, so you should use mapblockpos.getAsInt(max_val=4096) for the calculation to work.

EDIT: Also, I realized that the modulo I applied on the coordinates in the Pos' getAsInt function annihilated negative values; oops. It's fixed now (and your script seems to be working fine).