Module:Sandbox/RedWolf

local p = {} rank_number = 0;

function p.titled_coords(frame) local name = frame.args[1] local raw_coords = frame.args[2] local options = frame.args[3] --   local raw_coords = frame:expandTemplate{title='wikidata', args={'property','page=' .. page,'raw','coord'}} if options == "raw" then return "raw_coords:" .. raw_coords end _, _, lat_d, lat_m, lat_s, lat_NS, lon_d, lon_m, lon_s, lon_WE = string.find(raw_coords, "(%d+)/(%d+)/(%d+%.?%d?)/(%a+)/(%d+)/(%d+)/(%d+%.?%d?)/(%a+)")

--" .. lat_m .. "|" .. lat_s .. "|" .. lat_NS ..                                "|" .. lon_d .. "|" .. lon_m .. "|" .. lon_s .. "|" .. lon_WE ..                                 "|type:mountain|format=dms|name=" .. name ***

if options == "debug" then return "raw_coords:" .. raw_coords .. " lat dms = " .. lat_d .. "|" .. lat_m .. "|" .. lat_s .. "|" .. lat_NS .. " lon dms = " .. lon_d .. "|" .. lon_m .. "|" .. lon_s .. "|" .. lon_WE end title = name:gsub(" ", "+") return frame:expandTemplate{title='coord', args= { lat_d, lat_m, lat_s, lat_NS, lon_d, lon_m, lon_s, lon_WE,"type:mountain&title=" .. title}} --"type:mountain","format=dms","name=" .. name}} end

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

function p.start(frame) local unit_1, unit_2

local unit = frame.args[1] if unit == nil or unit == "" then unit = 'm'   end if unit == 'm' then unit_1 = 'm'       unit_2 = 'ft' else unit_1 = 'ft' unit_2 = 'm'   end

local s = '{| class="wikitable sortable"\n' .. '! align="left" rowspan=2|Rank||rowspan=2|Mountain/Peak ||colspan=2|Elevation ||colspan=2| Prominence ||rowspan=2| Subrange' .. '||rowspan=2| FA ||rowspan=2| Notes\n' .. '|-\n' s = s .. '!' .. unit_1 .. '||' .. unit_2 .. '||' .. unit_1 .. ' ||' .. unit_2

return s end

function p.finish(frame) return "|}" end

function p.list(frame) local name_cell, prom_cells local name = frame.args[1] local unit = frame.args[2] local elevation = frame.args[3] local prominence = frame.args[4] local range     = frame.args[5] local fa        = frame.args["fa"] local notes     = frame.args["notes"] local refs      = frame.args["refs"] if fa == nil then fa = " " end if range == nil then range = " " end if notes == nil then notes = " " end rank_number = rank_number + 1 local s = '\n|-\n|align=center|' .. rank_number .. '||' .. name .. '' if refs ~= nil then s = s .. refs end local elev = frame:expandTemplate{title='elevation_cells', args= { elevation, unit}} if prominence ~= nil and prominence ~= "-1" and prominence ~= "" then prom_cells = frame:expandTemplate{title='elevation_cells', args= { prominence,unit}} else prom_cells = "|| " end

s = s .. '\n|' .. elev .. '|' .. prom_cells .. '||' .. range .. '||' .. fa .. '||' .. notes .. '\n' return s end

return p

-- class="wikitable sortable" ! align="left" rowspan=2|Rank||rowspan=2|Mountain/Peak ||colspan=2|Elevation ||colspan=2| Prominence ||rowspan=2| Subrange !rowspan=2| FA ||rowspan=2| Notes ||rowspan=2| References !m || ft || m || ft
 * - bgcolor="#ffffcc"
 * align=center|1||Mount Robson
 * Rainbow Range
 * 1913||Highest point in the Canadian Rockies||
 * 1913||Highest point in the Canadian Rockies||