diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-09-26 20:54:42 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-09-26 20:54:42 +0300 |
commit | e7fcc08d2690d15982b86515a6ef883fd59cecad (patch) | |
tree | 43e428e466160f130f533b564cff58c7d4d1aa04 /util/minetestmapper.py | |
parent | 520b470217331787b26ca7633f9de26308b14bbc (diff) | |
download | minetest-e7fcc08d2690d15982b86515a6ef883fd59cecad.tar.gz minetest-e7fcc08d2690d15982b86515a6ef883fd59cecad.tar.bz2 minetest-e7fcc08d2690d15982b86515a6ef883fd59cecad.zip |
Fix minetestmapper.py
Diffstat (limited to 'util/minetestmapper.py')
-rwxr-xr-x | util/minetestmapper.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/util/minetestmapper.py b/util/minetestmapper.py index c7ec0774e..1914576e8 100755 --- a/util/minetestmapper.py +++ b/util/minetestmapper.py @@ -88,9 +88,19 @@ def int_to_hex4(i): def getBlockAsInteger(p): return p[2]*16777216 + p[1]*4096 + p[0] -def getIntegerAsBlock(i): - return i%4096, int(i/4096)%4096, int(i/16777216)%4096 +def unsignedToSigned(i, max_positive): + if i < max_positive: + return i + else: + return i - 2*max_positive +def getIntegerAsBlock(i): + x = unsignedToSigned(i % 4096, 2048) + i = int((i - x) / 4096) + y = unsignedToSigned(i % 4096, 2048) + i = int((i - y) / 4096) + z = unsignedToSigned(i % 4096, 2048) + return x,y,z def limit(i, l, h): if(i > h): |