Module:Dynmap

From Colonia Wiki
Revision as of 16:59, 18 October 2021 by Sudofox (talk | contribs)

TODO documentation

Script error: The function "dynmapImageForCoords" does not exist.


local p = {} -- package

-- worldtomap
local wtms = { world = {}, world_nether = {}, world_the_end = {}};

wtms.world.flat = {4, 0, -2.4492935982947064e-16, -2.4492935982947064e-16, 0, -4, 0, 1, 0}
wtms.world.t = {1.31370849898476, 0, -11.313708498984761, -5.6568542494923815, 13.856406460551018, -5.656854249492381, 5.551115123125782e-17, 0.9999999999999997, 5.551115123125782e-17 };

-- mapzoomout

local mapzoomouts = { world = {}, world_nether = {}, world_the_end = {}};

mapzoomouts.world.flat = 5;
mapzoomouts.world.t = 5;

function p.getWorldToMap(world, map)
    return wtms[world][map]
end

function p.getMapZoomOut(world, map)
    return mapzoomouts[world][map]
end

function p.gameCoordsToTile(coords, world, map)
    local wtm = p.getWorldToMap(world, map)
    local mapzoomout = p.getMapZoomOut(world, map)

    local lat = wtm[3] * coords.x + wtm[4] * coords.y + wtm[5] * coords.z;
    local lng = wtm[0] * coords.x + wtm[1] * coords.y + wtm[2] * coords.z;

    local results = {};
    -- results.x = -((128 - lat) / (1 << mapzoomout));
    results.x = -((128 - lat) / (bit.lshift(1, mapzoomout)));
    -- results.z = lng / (1 << mapzoomout);
    results.z = lng / (bit.lshift(1, mapzoomout));
    results.y = coords.y;

    return results;
end

function p.hello( frame )
    return "Hello, world!"
end

return p