Module:Skills/Cartography
From Melvor Idle
Documentation for this module may be created at Module:Skills/Cartography/doc
local p = {}
local Shared = require('Module:Shared')
local Constants = require('Module:Constants')
local GameData = require('Module:GameData')
local SkillData = GameData.skillData
local Items = require('Module:Items')
local Icons = require('Module:Icons')
function p.convertAxialToXY(HexCoords)
local Y = HexCoords.r + (HexCoords.q - (HexCoords.q % 2)) / 2
local X = HexCoords.q
return X, Y
end
function p.test()
local POIs = {}
local POI_Strings = {}
local tableStr = {}
table.insert(tableStr, '{| class="wikitable sortable"')
table.insert(tableStr, '\r\n|-\r\n!Name!!Type!!X!!Y!!Description')
for i, POI in pairs(SkillData.Cartography.worldMaps[1].pointsOfInterest) do
table.insert(POIs, POI)
end
table.sort(POIs, function(a, b)
local aX, aY = p.convertAxialToXY(a.coords)
local bX, bY = p.convertAxialToXY(b.coords)
if aX ~= bX then
return aX < bX
else
return aY < bY
end
end)
for i, POI in pairs(POIs) do
local X, Y = p.convertAxialToXY(POI.coords)
table.insert(POI_Strings, POI.name..' ('..X..', '..Y..')')
table.insert(tableStr,'\r\n|-\r\n|')
table.insert(tableStr, POI.name)
table.insert(tableStr, '||'..POI.type)
table.insert(tableStr, '||'..X)
table.insert(tableStr, '||'..Y)
table.insert(tableStr, '||'..POI.description)
end
table.insert(tableStr, '\r\n|}')
local keyset={}
local n=0
for k,v in pairs(POIs[1]) do
n=n+1
keyset[n]=k
end
mw.logObject(POIs[1])
return table.concat(tableStr, '')
end
return p