Documentation for this module may be created at Module:ExperimentalNavplate/doc
--[[This Mess is an experimental module for seeing if we can create a navplate that populates itself
as an ordered, nested list]]--
local p = {};
local lzSymb = "✈"
local landSymb = "🏠"
local portSymb = "⚓"
local miscLandSymb = "🏚"
local starSymb = "☀"
local planetSymb = "🪐"
local moonSymb ="🌙"
local beltSymb ="⭕"
local hubSymb = "💰"
local stationSymb = "🧑"
local restSymb = "🏨"
local asteroidSymb = "🧱"
local jpSymb = "🌌"
local miscSpaceSymb = "🌠"
local pirateSymb = "☠"
local dpl = require( 'Module:DPLlua' )
p.fullplate= function(frame )
-- Get the pages from the category of Stanton System
-- Potential to make this more elegant
local list = dpl.ask({
namespace = '',
category = 'Stanton System',
include='{Infobox Astronomical Object},{Infobox Location}'
} )
--Define categories
local star;
local planets = {};
local moons = {};
local other = {}; -- Catchall for anything that has a type set weirdly.
--Iterate through list, place each item in correct category
for i, entry in ipairs(list) do
local entry = list[i]["include"][1]
local name = entry["Name"]
local type = entry["Type"]
--Ground Locations
if type == nil then
entry = list[i]["include"][2]
type = entry["Type"]
if type == "Landing zone" then
entry["ListEntry"] = lzSymb+" "+name
entry["SortPower"] = 0
table.insert(lzs,entry)
elseif type == "Landmark" then
entry["ListEntry"] = landSymb+" "+name
entry["SortPower"] = 2
table.insert(locs,entry)
elseif type == "Spaceport" then
entry["ListEntry"] = portSymb+" "+name
entry["SortPower"] = 1
table.insert(spaceport,entry)
else
entry["ListEntry"] = miscLandSymb+" "+name
entry["SortPower"] = 3
table.insert(other,entry)
end
-- Space Locations
elseif type == "Star" then
entry["ListEntry"] = starSymb+" "+name
star = entry
entry["SortPower"] = 0
elseif type == "Planet" then
entry["ListEntry"] = planetSymb+" "+name
table.insert(planets,entry)
entry["SortPower"] = 1
elseif type == "Moon" then
entry["ListEntry"] = moonSymb+" "+name
entry["SortPower"] = 2
table.insert(moons,entry)
else
if type == "Asteroid Belt" then
entry["ListEntry"] = beltSymb+" "+name
entry["SortPower"] = 3
elseif type == "Trade Hub" then
entry["ListEntry"] = hubSymb+" "+name
entry["SortPower"] = 4
elseif type == "Asteroid Base" then
entry["ListEntry"] = pirateSymb+" "+name
entry["SortPower"] = 4.5
elseif type == "Space Station" then
entry["ListEntry"] = stationSymb+" "+name
entry["SortPower"] = 6
elseif type == "Rest Stop" then
entry["ListEntry"] = restSymb+" "+name
entry["SortPower"] = 5
elseif type == "Asteroid Formation" then
entry["ListEntry"] = asteroidSymb+" "+name
entry["SortPower"] = 7
elseif type == "Jump Point" then
entry["ListEntry"] = jpSymb+" "+name
entry["SortPower"] = 99
else
entry["SortPower"] = 8
entry["ListEntry"] = miscSpaceSymb+" "+name
end
table.add(other,entry)
end
end
--Test to see if we are getting these right
mw.logObject(rest)
end
p.sortPrecedence = function(a,b)
if a["SortPower"] == b["SortPower"] then return compareOrbits(a,b) end
return a["SortPower"] < b["SortPower"]
end
--Sort the orbits of two objects of the same time, or default to alphabetical if both are unknown
--If one is known, and the other is not, the known position will be sorted first.
p.compareOrbits = function (a,b)
orbA = a["Orbital Position"]
orbB = b["Orbital Position"]
if orbA == nil then
if orbB == nil then return a["Name"]<b["Name"] end
return false
else
if orbB == nil then return true end
return orbA<orbB
end
end
return p