Module:ExperimentalNavplate

From the Star Citizen Wiki, the fidelity™ encyclopedia
Revision as of 20:17, 3 August 2020 by Jale (talk | contribs)

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 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 belts = {};
   local asteroids = {};
   local lzs = {};
   local tradehubs = {};
   local stations = {};
   local spaceport = {};
   local rest = {};
   local locs = {};
   local jps = {};
   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 type = entry["Type"]
	--Ground Locations
	if type == nil then
		entry = list[i]["include"][2]
		type = entry["Type"]
		if type == "Landing zone" then
			table.insert(lzs,entry)
			
		elseif type == "Landmark" then
			table.insert(locs,entry)
			
		elseif type == "Spaceport" then
			table.insert(spaceport,entry)
		else
			table.insert(other,entry)
		end
	-- Space Locations
	elseif type == "Star" then
		star = entry
	elseif type == "Planet" then
		table.insert(planets,entry)
	elseif type == "Moon" then
		table.insert(moons,entry)
	elseif type == "Asteroid Belt" then
		table.insert(belts,entry)
	elseif type == "Trade Hub" then
		table.insert(tradehubs,entry)
	elseif type == "Space Station" then
		table.insert(stations,entry)
	elseif type == "Rest Stop" then
		table.insert(rest,entry)
	elseif type == "Asteroid Formation" then
		table.insert(asteroids,entry)
	elseif type == "Jump Point" then
		table.insert(jps,entry)
	else
		table.add(other,entry)
	end
end

table.sort(planets)

   
   
   --Test to see if we are getting these right
   mw.logObject(rest)
   
    
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
🍪 We use cookies to keep session information to provide you a better experience.