Module:Skills/Archaeology: Difference between revisions

Added getDigSiteInfobox
(Created initial version with getDigSite and getDigSiteArtefactTable)
 
(Added getDigSiteInfobox)
Line 1: Line 1:
--New module for Archaeology-related tables
--New module for Archaeology-related tables
--Unavoidably has some overlap with Module:Skills/Cartography
--Unavoidably has some overlap with Module:Skills/Cartography
--Crucially, stuff that involves both MUST go here
--Because otherwise we get circular references, which are Not Fun.
local p = {}
local p = {}


Line 9: Line 11:
local Items = require('Module:Items')
local Items = require('Module:Items')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Cartography = require('Module:Skills/Cartography')


local sizes = {'small', 'tiny', 'medium', 'large'}
local sizes = {'small', 'tiny', 'medium', 'large'}
Line 118: Line 121:
return p._getDigSiteArtefactTable(digSite, size)
return p._getDigSiteArtefactTable(digSite, size)
end
--Trying something new this time. Building the entire infobox in Lua and then passing it to the module.
function p.getDigSiteInfobox(frame)
local name = frame.args ~= nil and frame.args[1] or frame[1]
name = string.gsub(name, "%%27", "'")
name = string.gsub(name, "'", "'")
local digSite = p.getDigSite(name)
if digSite == nil then
return Shared.printError('No Dig Site named '..name..' found')
end
local poi = Cartography.getPointOfInterestByID(digSite.id)
local hex = Cartography.getHexByAxial(poi.coords.q, poi.coords.r)
local coordX, coordY = Cartography.convertAxialToXY(poi.coords)
local resultArray = {}
table.insert(resultArray, '{| class="wikitable infobox"')
--Expansion Symbol + Name
table.insert(resultArray, '\r\n!')
table.insert(resultArray, Icons.getExpansionIcon(digSite.id))
table.insert(resultArray, digSite.name)
--Image
table.insert(resultArray, '\r\n|-\r\n| style="text-align:center" |')
table.insert(resultArray, Icons.Icon({digSite.name, type='poi', size=250, notext='true'}))
--ID
table.insert(resultArray, "\r\n|-\r\n|'''ID:''' ")
table.insert(resultArray, digSite.id)
--Coordinates
table.insert(resultArray, "\r\n|-\r\n|'''Coordinates:''' ")
table.insert(resultArray, '('..coordX..', '..coordY..')')
--Requirements
table.insert(resultArray, "\r\n|-\r\n|'''Requirements:''' ")
local reqTable = Cartography._getPOIRequirements(poi)
if Shared.tableCount(reqTable) == 0 then
table.insert(resultArray, 'None')
else
table.insert(resultArray, '\r\n* '..table.concat(reqTable, '\r\n* '))
end
--Description
table.insert(resultArray, '\r\n|-\r\n| style="text-align:center" |')
table.insert(resultArray, "''"..poi.description.."''")
table.insert(resultArray, '\r\n|}')
table.insert(resultArray, '\n[[Category:Dig Sites]]')
return table.concat(resultArray, '')
end
end


return p
return p