|
|
| Line 17: |
Line 17: |
| | | |
| return WikiText | | return WikiText |
| end
| |
|
| |
| function p.AnimalMain(animalname)
| |
|
| |
| -- check that all necessary arguments are passed correctly
| |
| local args = Utils.normaliseArgs(animalname)
| |
| local animal = args.name
| |
| local animalData = require( 'Module:AnimalData' )
| |
| local animalTable = animalData.animals[animal]
| |
|
| |
| --Check Passes
| |
| assert(animalTable ~= nil, mw.ustring.format('Animal \'%s\' could not be found in Module:AnimalData.', animal))
| |
|
| |
| local animalEN = animalTable.untranslated
| |
| local animalimagename = string.gsub(animalEN, ' ', '')
| |
|
| |
| -- string used to build the infobox
| |
| local alternateRowColor = ' bgcolor=\"#c3e2ec\"' -- Mixed in 10% Green Blue Crayola from the palette with the table background color.
| |
| local headerStyle = 'style=\"background-color:#4688C0;text-align:center;\"'
| |
| local valueColumnStyle = 'style=\"text-align:right;padding:0.2em\"'
| |
| local longValueColumnStyle = 'style=\"text-align:right;padding:0.2em;max-width:12em\"'
| |
|
| |
| local infobox = '{| class=\"infobox\"\n'
| |
| -- name of the animal
| |
| infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; text-align: center;\"\n| colspan=\"2\" | \'\'\'<big>' .. animal .. '</big>\'\'\'\n'
| |
|
| |
| -- Water, Flying or Land Animal
| |
| infobox = infobox .. '|- style=\"text-align: center; color: white; background-color: '
| |
| if animalTable.isSwimming == 'Swimming' then
| |
| infobox = infobox .. '#65a9e6;\"\n| colspan=\"2\" | \'\'\'Water Animal\'\'\'[[Category:Animals]]\n'
| |
| elseif animalTable.isFlying == 'Flying' then
| |
| infobox = infobox .. '#e3bd27;\"\n| colspan=\"2\" | \'\'\'Flying Animal\'\'\'[[Category:Animals]]\n'
| |
| else
| |
| infobox = infobox .. '#11af53;\"\n| colspan=\"2\" | \'\'\'Land Animal\'\'\'[[Category:Animals]]\n'
| |
| end
| |
|
| |
| -- Animals Icon Image
| |
| local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. animalimagename .. '_Animal.png|[[Category:Pages_with_missing_animal]]'
| |
| if mw.title.makeTitle('File', animalimagename .. '_Animal.png').file.exists then
| |
| image = animalimagename .. '_Animal.png'
| |
| elseif mw.title.makeTitle('File', animalimagename .. '_Animal.jpg').file.exists then
| |
| image = animalimagename .. '_Animal.jpg'
| |
| end
| |
|
| |
| infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding:0;\" | [[File:' .. image .. '|center|frameless|250x250px]]\n'
| |
|
| |
| -- 'General' section header
| |
| infobox = infobox .. '|-' .. headerStyle .. '\n| colspan=\"2\" | \'\'\'General\'\'\'\n'
| |
|
| |
| -- Health
| |
| if animalTable.health ~= nil then
| |
| infobox = infobox .. '|-\n| Health:\n|' .. valueColumnStyle .. '| ' .. animalTable.health .. '\n'
| |
| end
| |
|
| |
| -- Idle Speed
| |
| if animalTable.wanderingSpeed ~= nil then
| |
| infobox = infobox .. '|-' .. alternateRowColor .. '\n| Idle Speed:\n|' .. valueColumnStyle .. '| ' .. animalTable.wanderingSpeed .. 'm/s \n'
| |
| end
| |
|
| |
| -- Eats
| |
| if animalTable.foodSources ~= nil then
| |
| -- 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.
| |
| infobox = infobox .. '|-\n| Eats:\n|' .. longValueColumnStyle .. '| ' .. animalTable.foodSources .. '\n'
| |
| end
| |
|
| |
| -- Climbing
| |
| if animalTable.climbHeight ~= nil then
| |
| infobox = infobox .. '|--' .. alternateRowColor .. '\n| Climb Height:\n|' .. valueColumnStyle .. '| ' .. animalTable.climbHeight .. 'm \n'
| |
| end
| |
|
| |
| -- Carbon Released
| |
| if animalTable.carbonRelease ~= nil then
| |
| infobox = infobox .. '|-\n| Carbon Released:\n|' .. valueColumnStyle .. '| ' .. animalTable.carbonRelease .. 'ppm \n'
| |
| end
| |
|
| |
| -- 'Hunting Information' section header
| |
| infobox = infobox .. '|-' .. headerStyle .. '\n| colspan=\"2\" | \'\'\'Hunting\'\'\'\n'
| |
|
| |
| -- Harvest
| |
| if animalTable.resourceItem ~= nil then
| |
| infobox = infobox .. '|-\n| Harvest Item:\n|' .. valueColumnStyle .. '| ' .. animalTable.resourceItem .. '\n'
| |
| end
| |
|
| |
| -- Flees
| |
| infobox = infobox .. '|--' .. alternateRowColor .. '\n| Flees:\n|' .. valueColumnStyle .. '| ' .. animalTable.flees .. '\n'
| |
|
| |
| -- Animals Fear
| |
| if animalTable.fearFactor ~= nil then
| |
| infobox = infobox .. '|-\n| [[Fear Factor]]:\n|' .. valueColumnStyle .. '| ' .. animalTable.fearFactor .. '\n'
| |
| end
| |
|
| |
| -- Running Speed
| |
| if animalTable.speed ~= nil then
| |
| infobox = infobox .. '|-' .. alternateRowColor .. '\n| Flee Speed:\n|' .. valueColumnStyle .. '| ' .. animalTable.speed .. 'm/s \n'
| |
| end
| |
|
| |
| -- Attack Chance
| |
| if animalTable.chanceToAttack ~= nil then
| |
| infobox = infobox .. '|-\n| Attack Chance:\n|' .. valueColumnStyle .. '| ' .. tonumber(animalTable.chanceToAttack)*100 .. ' % \n'
| |
| end
| |
|
| |
| -- Attack Damage
| |
| if animalTable.damage ~= nil then
| |
| infobox = infobox .. '|-' .. alternateRowColor .. '\n| Attack Damage:\n|' .. valueColumnStyle .. '| ' .. animalTable.damage .. '\n'
| |
| end
| |
|
| |
| -- Detect Range
| |
| if animalTable.detectRange ~= nil then
| |
| infobox = infobox .. '|-\n| Detect Range:\n|' .. valueColumnStyle .. '| ' .. animalTable.detectRange .. 'm \n'
| |
| end
| |
|
| |
| -- Attack Range
| |
| if animalTable.attackRange ~= nil then
| |
| infobox = infobox .. '|-' .. alternateRowColor .. '\n| Attack Range:\n|' .. valueColumnStyle .. '| ' .. animalTable.attackRange .. 'm \n'
| |
| end
| |
|
| |
| infobox = infobox .. '|}'
| |
|
| |
| return infobox
| |
| end | | end |
|
| |
|
| return p | | return p |
Documentation for this module may be created at Module:AnimalInfoCard/doc
local Utils = require('Module:Utils')
local RecipeUtils = require('Module:RecipeUtils')
local IconUtils = require('Module:IconUtils')
local Lang = Utils.getLanguageName()
function p.main(frame)
local PageName = frame.args[1]
if (Lang == 'English') then AnimalName = PageName else AnimalName = Utils.AnimalSearch(PageName) end
local AnimalData = require( "Module:AnimalData" )
local Animal = AnimalData.animals[AnimalName]
local WikiText =''
WikiText = WikiText ..'__NOTOC__'
WikiText = WikiText ..'page name get test: ' .. PageName ..'</br>'
WikiText = WikiText ..'Item name get test: ' .. AnimalName ..'</br>'
return WikiText
end
return p