Module:Coordinates

require('Module:No globals')

local math_mod = require("Module:Math") local coordinates = {};

local current_page = mw.title.getCurrentTitle local page_name = mw.uri.encode( current_page.prefixedText, 'WIKI' ); local templatestyles = 'Module:Coordinates/styles.css'

local function displaytitle(s) local l = "Coordinates: " .. s	local co = ' ' .. l .. ' ';	return ' ' .. co .. ' '; end

local function makeInvokeFunc(funcName) return function (frame) local args = require('Module:Arguments').getArgs(frame, {			wrappers = 'Template:Coord'		}) return coordinates[funcName](args, frame) end end

local function formatFor2b2t(coordStr) local floored = math.floor(tonumber(coordStr)) return tostring(floored):reverse:gsub("(%d%d%d)", "%1,"):reverse:gsub("^,", "") end

coordinates.coord = makeInvokeFunc('_coord') function coordinates._coord(args)

local contents = mw.getCurrentFrame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} }

contents = contents .. 'X: ' .. formatFor2b2t(args[1]) contents = contents .. ', '	contents = contents .. 'Z: ' .. formatFor2b2t(args[2]) local Display = args.intitle and args.intitle:lower or 'yes'

local function isInTitle(s) return s:find('yes') ~= nil end

local text = contents if isInTitle(Display) then text = text .. displaytitle(contents) end

return text end

return coordinates