Editing Module:Infobox Animal
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") | ||
local Unit = require("Module:Unit") | |||
local AnimalUtils = require("Module:UtilsAnimalTables") | |||
-- Build an Animal Infobox | -- Build an Animal Infobox | ||
Line 56: | Line 58: | ||
-- Idle Speed | -- Idle Speed | ||
if animalTable.wanderingSpeed ~= nil then | if animalTable.wanderingSpeed ~= nil then | ||
infobox = infobox .. '|-' .. alternateRowColor .. '\n| Idle Speed:\n|' .. valueColumnStyle .. '| ' .. animalTable.wanderingSpeed | infobox = infobox .. '|-' .. alternateRowColor .. '\n| Idle Speed:\n|' .. valueColumnStyle .. '| ' .. Unit._unit(animalTable.wanderingSpeed, 'm/s') .. '\n' | ||
end | end | ||
Line 63: | Line 65: | ||
-- 12em seems to be enough for the other column to scale up to fill the remaining space. | -- 12em seems to be enough for the other column to scale up to fill the remaining space. | ||
-- With this the longest line "Attack Damage:" fits on one line. | -- With this the longest line "Attack Damage:" fits on one line. | ||
infobox = infobox .. '|-\n| Eats:\n|' .. longValueColumnStyle .. '| ' .. animalTable.foodSources .. '\n' | infobox = infobox .. '|-\n| Eats:\n|' .. longValueColumnStyle .. '| ' .. AnimalUtils.formatFoodSources(animalTable.foodSources) .. '\n' | ||
end | end | ||
-- Climbing | -- Climbing | ||
if animalTable.climbHeight ~= nil then | if animalTable.climbHeight ~= nil then | ||
infobox = infobox .. '|--' .. alternateRowColor .. '\n| Climb Height:\n|' .. valueColumnStyle .. '| ' .. animalTable.climbHeight .. ' | infobox = infobox .. '|--' .. alternateRowColor .. '\n| Climb Height:\n|' .. valueColumnStyle .. '| ' .. Unit._unit(animalTable.climbHeight, 'm') .. '\n' | ||
end | end | ||
-- Carbon Released | -- Carbon Released | ||
if animalTable.carbonRelease ~= nil then | if animalTable.carbonRelease ~= nil then | ||
infobox = infobox .. '|-\n| Carbon Released:\n|' .. valueColumnStyle .. '| ' .. animalTable.carbonRelease .. ' | infobox = infobox .. '|-\n| Carbon Released:\n|' .. valueColumnStyle .. '| ' .. Unit._unit(animalTable.carbonRelease, 'ppm') .. '\n' | ||
end | end | ||
Line 94: | Line 96: | ||
-- Running Speed | -- Running Speed | ||
if animalTable.speed ~= nil then | if animalTable.speed ~= nil then | ||
infobox = infobox .. '|-' .. alternateRowColor .. '\n| Flee Speed:\n|' .. valueColumnStyle .. '| ' .. animalTable.speed | infobox = infobox .. '|-' .. alternateRowColor .. '\n| Flee Speed:\n|' .. valueColumnStyle .. '| ' .. Unit._unit(animalTable.speed, 'm/s') .. '\n' | ||
end | end | ||
-- Attack Chance | -- Attack Chance | ||
if animalTable.chanceToAttack ~= nil then | if animalTable.chanceToAttack ~= nil then | ||
infobox = infobox .. '|-\n| Attack Chance:\n|' .. valueColumnStyle .. '| ' .. tonumber(animalTable.chanceToAttack)*100 .. ' % \n' | infobox = infobox .. '|-\n| Attack Chance:\n|' .. valueColumnStyle .. '| ' .. tonumber(Unit._unit(animalTable.chanceToAttack))*100 .. ' % \n' | ||
end | end | ||
Line 109: | Line 111: | ||
-- Detect Range | -- Detect Range | ||
if animalTable.detectRange ~= nil then | if animalTable.detectRange ~= nil then | ||
infobox = infobox .. '|-\n| Detect Range:\n|' .. valueColumnStyle .. '| ' .. animalTable.detectRange .. ' | infobox = infobox .. '|-\n| Detect Range:\n|' .. valueColumnStyle .. '| ' .. Unit._unit(animalTable.detectRange, 'm') .. '\n' | ||
end | end | ||
-- Attack Range | -- Attack Range | ||
if animalTable.attackRange ~= nil then | if animalTable.attackRange ~= nil then | ||
infobox = infobox .. '|-' .. alternateRowColor .. '\n| Attack Range:\n|' .. valueColumnStyle .. '| ' .. animalTable.attackRange .. ' | infobox = infobox .. '|-' .. alternateRowColor .. '\n| Attack Range:\n|' .. valueColumnStyle .. '| ' .. Unit._unit(animalTable.attackRange, 'm') .. '\n' | ||
end | end | ||