Editing Module:Infobox Biome

From Eco - English Wiki

Your changes will be displayed to readers once an authorized user accepts them. (help)

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

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 = Utils.mapColour(biome.Color)
     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"
        "|- 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 .. sectionHeader('Description')
     infobox = infobox .. sectionRow("Elevation", biome.ElevationMin*100 .. ' -  ' .. biome.ElevationMax*100)
    infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. biome.Description .. '\n'
     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 .. sectionHeader('Details')
    infobox = infobox .. sectionRow("Can have lakes?", Utils.formatBoolToYesNo(biome.Lakes))
     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 .. '|}'
     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"
        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'
        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'
            '| style=\"color: red; text-align: right; padding: 3px;\" | ' ..
         section = section .. '|- valign=\"center\"\n| style=\"color: orange; text-align: right; padding: 3px;\" | ' .. L.t('Protein') .. ': ' .. itemTable.protein .. '\n'
            L.t('Carbs') .. ': ' .. itemTable.carbs .. '\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'
            '|- 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 ..
            '|- valign=\"center\"\n| style=\"color: limegreen; text-align: right; padding: 3px;\" | ' ..
            L.t('Vitamins') .. ': ' .. itemTable.vitamins .. '\n'
         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() .. ']]'
        imageName .. '_' .. suffix .. '.png|[[Category:Pages_with_missing_' .. suffix:lower() .. ']]'
     if mw.title.makeTitle('File', imageName .. '_' .. suffix .. '.png').file.exists then
     if mw.title.makeTitle('File', imageName .. '_' .. suffix .. '.jpeg').file.exists then
        image = imageName .. '_' .. suffix .. '.jpeg'
    elseif mw.title.makeTitle('File', imageName .. '_' .. suffix .. '.png').file.exists then
         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
Please note that all contributions to Eco - English Wiki are considered to be released under the CC BY-NC-SA 4.0 (see Eco:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)

Template used on this page: