Editing Module:Infobox Biome
From Eco - English Wiki
Your changes will be displayed to readers once an authorized user accepts them. (help)
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local Utils = require('Module:Utils') | local Utils = require('Module:Utils') | ||
Line 16: | Line 17: | ||
if biome == nil then | if biome == nil then | ||
return "Biome " .. biome_id .. " not found" | return "Biome ".. biome_id .." not found" | ||
end | end | ||
local infobox = '{| class=\"infobox\"\n' | local infobox = '{| class=\"infobox\"\n' | ||
foreground, background = | foreground, background = biomeColour(biome.Color) | ||
infobox = infobox .. | infobox = infobox .. "|- style=\"color: white; background-color: "..background.."; text-align: center;\"\n| colspan=\"2\" | '''<big>" .. biome.Name .. "</big>'''\n" | ||
infobox = infobox .. sectionImage(biome.ID, "Biome") | infobox = infobox .. sectionImage(biome.ID, "Biome") | ||
infobox = infobox .. sectionRow("Elevation", biome.ElevationMin*100 .. ' - ' .. biome.ElevationMax*100) | |||
infobox = infobox .. sectionRow("Temperature", biome.TemperatureMin*40-10 .. ' - ' .. biome.TemperatureMax*40-10 .. ' °C') | |||
infobox = infobox .. sectionRow("Moisture", biome.MoistureMin*100 .. ' - ' .. biome.MoistureMax*100) | |||
infobox = infobox .. sectionRow("Elevation", biome.ElevationMin * 100 .. ' - ' .. biome.ElevationMax * 100) | |||
infobox = infobox .. | |||
infobox = infobox .. sectionRow("Moisture", biome.MoistureMin * 100 .. ' - ' .. biome.MoistureMax * 100) | |||
infobox = infobox .. '|}' | infobox = infobox .. '|}' | ||
return infobox | return infobox | ||
end | |||
function biomeColour(colourName) | |||
local foreground = "white" | |||
local background = "#1165AF" | |||
if colourName == "SteelBlue" then | |||
background = "#4682b4" | |||
elseif colourName == "LightSkyBlue" then | |||
background = "#87cefa" | |||
end | |||
return foreground, background | |||
end | end | ||
function sectionHeader(title, count) | function sectionHeader(title, count) | ||
return "|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | '''" .. | return "|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | '''" .. L.t(title, count) .. "'''\n" | ||
end | end | ||
Line 58: | Line 66: | ||
unit = '' | unit = '' | ||
end | end | ||
return '|-\n| ' .. | return '|-\n| ' .. L.t(label, count) .. ':\n| style=\"text-align: right; padding: 3px;\" | ' .. content .. unit .. '\n' | ||
end | end | ||
Line 93: | Line 100: | ||
section = section .. sectionRow('Calorie', itemTable.calories, tonumber(itemTable.calories), 'cal') | section = section .. sectionRow('Calorie', itemTable.calories, tonumber(itemTable.calories), 'cal') | ||
section = section .. '|- valign=\"center\"\n| rowspan=\"4\" | ' .. L.t('Nutrients') .. ':\n' | section = section .. '|- valign=\"center\"\n| rowspan=\"4\" | ' .. L.t('Nutrients') .. ':\n' | ||
section = section .. | section = section .. '| style=\"color: red; text-align: right; padding: 3px;\" | ' .. L.t('Carbs') .. ': ' .. itemTable.carbs .. '\n' | ||
section = section .. '|- valign=\"center\"\n| style=\"color: orange; text-align: right; padding: 3px;\" | ' .. L.t('Protein') .. ': ' .. itemTable.protein .. '\n' | |||
section = section .. '|- valign=\"center\"\n| style=\"color: darkkhaki; text-align: right; padding: 3px;\" | ' .. L.t('Fat') .. ': ' .. itemTable.fat .. '\n' | |||
section = section .. | section = section .. '|- valign=\"center\"\n| style=\"color: limegreen; text-align: right; padding: 3px;\" | ' .. L.t('Vitamins') .. ': ' .. itemTable.vitamins .. '\n' | ||
section = section .. | |||
section = section .. | |||
section = section .. sectionRow('Nutrition Density', L.t('%s per 100 cals'):format(itemTable.density)) | section = section .. sectionRow('Nutrition Density', L.t('%s per 100 cals'):format(itemTable.density)) | ||
end | end | ||
Line 120: | Line 119: | ||
local weight | local weight | ||
if itemTable.weight ~= nil then | if itemTable.weight ~= nil then | ||
weight = itemTable.weight / 100 | weight = itemTable.weight/100 | ||
else | else | ||
weight = '0.0' | weight = '0.0' | ||
Line 149: | Line 148: | ||
function checkImage(imageName, suffix) | function checkImage(imageName, suffix) | ||
local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. | local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. imageName .. '_' .. suffix .. '.png|[[Category:Pages_with_missing_' .. suffix:lower() .. ']]' | ||
if mw.title.makeTitle('File', imageName .. '_' .. suffix .. '.png').file.exists then | |||
if | |||
image = imageName .. '_' .. suffix .. '.png' | image = imageName .. '_' .. suffix .. '.png' | ||
elseif mw.title.makeTitle('File', imageName .. '_' .. suffix .. '.jpg').file.exists then | |||
image = imageName .. '_' .. suffix .. '.jpg' | |||
end | end | ||
return image | return image |