Module:BiomeInfo

local p = {} local cargo = mw.ext.cargo

-- Perform a SQL query to "planet" table in the Cargo database (see Special:CargoTables/planet). -- @param {string} planetType -- @return {table} Database row. local function queryPlanet( planetType ) local tables = 'planet' local fields = 'name,minTier,maxTier,minGravity,maxGravity,minDayLight,maxDayLight,id' local queryOpt = { where = 'id="' .. planetType .. '"', limit = 1 }	return ( cargo.query( tables, fields, queryOpt ) or {} )[1] end

-- Print "on what planets can we find this biome" information. -- Usage: -- First parameter: biome ID, e.g. "supermatterzone". function p.OnWhatPlanets( frame ) local args = frame.args if not args[1] then args = frame:getParent.args end

local biomeCode = args[1] if not biomeCode then return '' end

local tables = 'planet,layer,region' local fields = 'planet.name,primaryRegion,secondaryRegions' local queryOpt = { join = 'layer.primaryRegion HOLDS region.id OR layer.secondaryRegions HOLDS region.id, planet.id=layer.planet', where = 'region.biome="' .. biomeCode .. '"', limit = 1 }	local rows = cargo.query( tables, fields, queryOpt ) if not rows then return 'Not found on any planets.' end

local ret = '' for _, row in ipairs( rows ) do ret = ret .. row['planet.name'] end

return ret end

return p