add timed regenerate and unified_inventory integration
|
@ -0,0 +1,31 @@
|
|||
This mod displays a map of the entire minetest world with a location arrow and direction. Or if you wish, you can now place a map voxel/block with the world map on it (but the aspect ratio may not be correct).
|
||||
I've borrowed from other peoples code, so Thanks to:
|
||||
MAPP: https://forum.minetest.net/viewtopic.php?f=9&t=4922&p=140013#p139891.
|
||||
VanessaE for her massive minetest colour file (I had to remove the comments as they broke the script), so maps show dramatically more features (and colours are more accurate).
|
||||
Maps are generated offline by minetestmapper-numpy.py https://forum.minetest.net/viewtopic.php?f=14&t=8730. The legacy minetestmapper https://forum.minetest.net/viewtopic.php?f=3&t=49 is not supported as I recoded the -numpy script to add text comments to the PNG.
|
||||
Not essential, but I also think MT-GitSync is great for keeping your mods uptodate https://forum.minetest.net/viewtopic.php?f=14&t=8749&hilit=gitsync
|
||||
|
||||
USAGE:
|
||||
Install Dependancies:-
|
||||
As well as enablind the mod in minetest you will need python, numpy, and the python imaging library. Very easy in Ubuntu: in the software centre, just install python, python-numpy and python-pil or python3, python3-numpy and python3-pil.
|
||||
Generate the Map:-
|
||||
Run the MapWorlds.sh bash script from the mapit directory. This will generate maps for all your currently installed worlds, and can be re-run to update these whenever you like (if you only want to do one world, then copy the Mapstampyworld.sh script and edit it). You may need to set the file permissions to allow execution of the script (sudo chmod u+rwx MapWorlds.sh).
|
||||
In the terminal run it with:-
|
||||
cd ~/.minetest/mods/mapit
|
||||
./MapWorlds.sh
|
||||
|
||||
Display the map:
|
||||
Select the mapit:maptool in your inventory.
|
||||
L-button (punch) to bring up the map.
|
||||
So far it doesn't have a recipe, so you'll have to use the chat command: /give mapit:maptool
|
||||
|
||||
|
||||
TODO:
|
||||
Create square images for the block so aspect ratio isn't skewed
|
||||
It probably won't be improved much after that, but the improvements I wish I was good enough to make are:-
|
||||
Have a button to run minetestmapper in the background to update the png, then reload.
|
||||
Zoom - Would be great if it was possible to zoom in with the mousewheel, but looks like the formspec doesn't support that, so would probably be with L/R mouse click.
|
||||
Teleport to location on the map (?middle click)
|
||||
|
||||
Having said that, I think it is already quite a useful excellent quality map.
|
||||
Going to make a big mesh sign, but haven't yet coded it...
|
|
@ -0,0 +1,28 @@
|
|||
from PIL import Image
|
||||
|
||||
def average_image_color(filename):
|
||||
i = Image.open(filename)
|
||||
h = i.histogram()
|
||||
|
||||
# split into red, green, blue
|
||||
r = h[0:256]
|
||||
g = h[256:256*2]
|
||||
b = h[256*2: 256*3]
|
||||
|
||||
# perform the weighted average of each channel:
|
||||
# the *index* is the channel value, and the *value* is its weight
|
||||
return (
|
||||
sum( i*w for i, w in enumerate(r) ) / sum(r),
|
||||
sum( i*w for i, w in enumerate(g) ) / sum(g),
|
||||
sum( i*w for i, w in enumerate(b) ) / sum(b)
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
if len(sys.argv) > 1:
|
||||
print average_image_color(sys.argv[1])
|
||||
else:
|
||||
print 'usage: average_image_color.py FILENAME'
|
||||
print 'prints the average color of the image as (R,G,B) where R,G,B are between 0 and 255.'
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
default
|
||||
unified_inventory?
|
||||
travelpoints?
|
||||
|
||||
|
|
@ -0,0 +1,165 @@
|
|||
-- pngparse.lua
|
||||
-- Simple example of parsing the main sections of a PNG file.
|
||||
--
|
||||
-- This is mostly just an example. Not intended to be complete,
|
||||
-- robust, modular, or well tested.
|
||||
--
|
||||
-- (c) 2008 David Manura. Licensed under the same terms as Lua (MIT license).
|
||||
|
||||
|
||||
-- Unpack 32-bit unsigned integer (most-significant-byte, MSB, first)
|
||||
-- from byte string.
|
||||
local function unpack_msb_uint32(s)
|
||||
local a,b,c,d = s:byte(1,#s)
|
||||
local num = (((a*256) + b) * 256 + c) * 256 + d
|
||||
return num
|
||||
end
|
||||
|
||||
-- Read 32-bit unsigned integer (most-significant-byte, MSB, first) from file.
|
||||
local function read_msb_uint32(fh)
|
||||
return unpack_msb_uint32(fh:read(4))
|
||||
end
|
||||
|
||||
-- Read unsigned byte (integer) from file
|
||||
local function read_byte(fh)
|
||||
return fh:read(1):byte()
|
||||
end
|
||||
|
||||
|
||||
local function parse_zlib(fh, len)
|
||||
local byte1 = read_byte(fh)
|
||||
local byte2 = read_byte(fh)
|
||||
|
||||
local compression_method = byte1 % 16
|
||||
local compression_info = math.floor(byte1 / 16)
|
||||
|
||||
local fcheck = byte2 % 32
|
||||
local fdict = math.floor(byte2 / 32) % 1
|
||||
local flevel = math.floor(byte2 / 64)
|
||||
|
||||
print("compression_method=", compression_method)
|
||||
print("compression_info=", compression_info)
|
||||
print("fcheck=", fcheck)
|
||||
print("fdict=", fdict)
|
||||
print("flevel=", flevel)
|
||||
|
||||
fh:read(len - 6)
|
||||
print("(deflate data not displayed)")
|
||||
|
||||
local checksum = read_msb_uint32(fh)
|
||||
print("checksum=", checksum)
|
||||
end
|
||||
|
||||
local function parse_IHDR(fh, len)
|
||||
assert(len == 13, 'format error')
|
||||
local width = read_msb_uint32(fh)
|
||||
local height = read_msb_uint32(fh)
|
||||
local bit_depth = read_byte(fh)
|
||||
local color_type = read_byte(fh)
|
||||
local compression_method = read_byte(fh)
|
||||
local filter_method = read_byte(fh)
|
||||
local interlace_method = read_byte(fh)
|
||||
|
||||
print("width=", width)
|
||||
print("height=", height)
|
||||
print("bit_depth=", bit_depth)
|
||||
print("color_type=", color_type)
|
||||
print("compression_method=", compression_method)
|
||||
print("filter_method=", filter_method)
|
||||
print("interlace_method=", interlace_method)
|
||||
|
||||
return compression_method
|
||||
end
|
||||
|
||||
local function parse_sRGB(fh, len)
|
||||
assert(len == 1, 'format error')
|
||||
local rendering_intent = read_byte(fh)
|
||||
print("rendering_intent=", rendering_intent)
|
||||
end
|
||||
|
||||
local function parse_gAMA(fh, len)
|
||||
assert(len == 4, 'format error')
|
||||
local rendering_intent = read_msb_uint32(fh)
|
||||
print("rendering_intent=", rendering_intent)
|
||||
end
|
||||
|
||||
local function parse_cHRM(fh, len)
|
||||
assert(len == 32, 'format error')
|
||||
|
||||
local white_x = read_msb_uint32(fh)
|
||||
local white_y = read_msb_uint32(fh)
|
||||
local red_x = read_msb_uint32(fh)
|
||||
local red_y = read_msb_uint32(fh)
|
||||
local green_x = read_msb_uint32(fh)
|
||||
local green_y = read_msb_uint32(fh)
|
||||
local blue_x = read_msb_uint32(fh)
|
||||
local blue_y = read_msb_uint32(fh)
|
||||
print('white_x=', white_x)
|
||||
print('white_y=', white_y)
|
||||
print('red_x=', red_x)
|
||||
print('red_y=', red_y)
|
||||
print('green_x=', green_x)
|
||||
print('green_y=', green_y)
|
||||
print('blue_x=', blue_x)
|
||||
print('blue_y=', blue_y)
|
||||
end
|
||||
|
||||
local function parse_IDAT(fh, len, compression_method)
|
||||
if compression_method == 0 then
|
||||
-- fh:read(len)
|
||||
parse_zlib(fh, len)
|
||||
else
|
||||
print('(unrecognized compression method)')
|
||||
end
|
||||
end
|
||||
|
||||
local function parse_png(fh)
|
||||
-- parse PNG header
|
||||
local bytes = fh:read(8)
|
||||
local expect = "\137\080\078\071\013\010\026\010"
|
||||
if bytes ~= expect then
|
||||
error 'not a PNG file'
|
||||
end
|
||||
|
||||
-- parse chunks
|
||||
local compression_method
|
||||
while 1 do
|
||||
local len = read_msb_uint32(fh)
|
||||
local stype = fh:read(4)
|
||||
print("chunk:", "type=", stype, "len=", len)
|
||||
|
||||
if stype == 'IHDR' then
|
||||
compression_method = parse_IHDR(fh, len)
|
||||
elseif stype == 'sRGB' then
|
||||
parse_sRGB(fh, len)
|
||||
elseif stype == 'gAMA' then
|
||||
parse_gAMA(fh, len)
|
||||
elseif stype == 'cHRM' then
|
||||
parse_cHRM(fh, len)
|
||||
elseif stype == 'IDAT' then
|
||||
parse_IDAT(fh, len, compression_method)
|
||||
else
|
||||
local data = fh:read(len)
|
||||
print("data=", len == 0 and "(empty)" or "(not displayed)")
|
||||
end
|
||||
|
||||
local crc = read_msb_uint32(fh)
|
||||
print("crc=", crc)
|
||||
|
||||
if stype == 'IEND' then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local filename = arg[1]
|
||||
|
||||
if not filename then
|
||||
io.stderr:write("usage: lua pngparse.lua <filename>")
|
||||
os.exit(1)
|
||||
end
|
||||
|
||||
local fh = assert(io.open(filename, 'rb'))
|
||||
parse_png(fh)
|
||||
|
||||
|
After Width: | Height: | Size: 305 KiB |
After Width: | Height: | Size: 200 B |
After Width: | Height: | Size: 198 B |
After Width: | Height: | Size: 266 B |
After Width: | Height: | Size: 522 B |
After Width: | Height: | Size: 527 B |
After Width: | Height: | Size: 512 B |
After Width: | Height: | Size: 554 B |
After Width: | Height: | Size: 646 B |
After Width: | Height: | Size: 536 B |
After Width: | Height: | Size: 511 B |
After Width: | Height: | Size: 527 B |
After Width: | Height: | Size: 534 B |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 24 KiB |