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 4: | Line 5: | ||
-- Build an Biome Infobox | -- Build an Biome Infobox | ||
function p. | function p.itemBox(args) | ||
-- check that all necessary arguments are passed correctly | -- check that all necessary arguments are passed correctly | ||
if args.id == nil or args.id == '' then | if args.id == nil or args.id == '' then | ||
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' | ||
infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; 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 .. | infobox = infobox .. '|}' | ||
infobox | return infobox | ||
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 46: | ||
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 80: | ||
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 99: | ||
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 128: | ||
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 |