Modul:Infobox Animal: Unterschied zwischen den Versionen
[unmarkierte Version] | [unmarkierte Version] |
Fix Image |
Auto Category |
||
Zeile 45: | Zeile 45: | ||
infobox = infobox .. '|- style=\"text-align: center; color: white; background-color: ' | infobox = infobox .. '|- style=\"text-align: center; color: white; background-color: ' | ||
if animalTable.isSwimming == 'Schwimmen' then | if animalTable.isSwimming == 'Schwimmen' then | ||
infobox = infobox .. '#65a9e6;\"\n| colspan=\"2\" | \'\'\'Wassertier\'\'\'\n' | infobox = infobox .. '#65a9e6;\"\n| colspan=\"2\" | \'\'\'Wassertier\'\'\'[[Category:Tiere]]\n' | ||
elseif animalTable.isFlying == 'Fliegend' then | elseif animalTable.isFlying == 'Fliegend' then | ||
infobox = infobox .. '#e3bd27;\"\n| colspan=\"2\" | \'\'\'Fliegendes Tier\'\'\'\n' | infobox = infobox .. '#e3bd27;\"\n| colspan=\"2\" | \'\'\'Fliegendes Tier\'\'\'[[Category:Tiere]]\n' | ||
else | else | ||
infobox = infobox .. '#11af53;\"\n| colspan=\"2\" | \'\'\'Land-Tier\'\'\'\n' | infobox = infobox .. '#11af53;\"\n| colspan=\"2\" | \'\'\'Land-Tier\'\'\'[[Category:Tiere]]\n' | ||
end | end | ||
Aktuelle Version vom 22. September 2020, 10:41 Uhr
Dokumentation[Quelltext bearbeiten]
Dieses Modul bietet die Back-End-Funktionalität der Vorlage: Infobox_Animal.
Wenn die Vorlage übergeben wird, wird eine Infobox mit Details aus den folgenden Modulen erstellt:
Translating Module[Quelltext bearbeiten]
This Module is a copy of the EN Module of the same name.
RULES FOR TRANSLATING THE LUA MODULES
IF IN DOUBT ASK IN DISCORD
IF ONLY 99.99% SURE ASK IN DISCORD
'string' --Anything using single quotes is a string HARDCODED in this file, these should be translated where appropriate.
'|- Valign \n' -- EXCEPTION if it looks like HTML styling,
local variable -- don't edit or change variable names
speciesTable.idealGrowthRate -- don't edit names of getters or methods
Kredit[Quelltext bearbeiten]
Die von Pradoxzon erstellte Original-Infobox (jetzt als Infobox_Item bekannt) wurde dann von Nesphit und TreeNuts0 bearbeitet. Fyre (FishAus) und Scotty (ZeelNightwolf) haben das Infobox_Item weiter bearbeitet. Sie wurden dann dupliziert und als Basis für Infobox_Skill, Infobox_Plant und Infobox_Animal verwendet.
local p = {}
-- Grabs args from the parent frame
-- Trims and parses the args into a table, then returns the table
function norm()
local origArgs = mw.getCurrentFrame():getParent().args
local args = {}
for k, v in pairs( origArgs ) do
v = mw.text.trim( tostring( v ) )
if v ~= '' then
args[k] = v
end
end
return args
end
-- Build an Animal Infobox
function animalBox( args, animalData )
-- check that all necessary arguments are passed correctly
if args.name == nil or args.name == '' then
return '\'name\' must be specified.'
end
local animal = args.name
local animalTable = animalData.animals[animal]
--Check Passes
if animalTable == nil then
return animal .. ' could not be found in Module:AnimalData.'
end
local animalEN = animalTable.untranslated
local animalimagename = string.gsub(animalEN, ' ', '')
-- string used to build the infobox
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 == 'Schwimmen' then
infobox = infobox .. '#65a9e6;\"\n| colspan=\"2\" | \'\'\'Wassertier\'\'\'[[Category:Tiere]]\n'
elseif animalTable.isFlying == 'Fliegend' then
infobox = infobox .. '#e3bd27;\"\n| colspan=\"2\" | \'\'\'Fliegendes Tier\'\'\'[[Category:Tiere]]\n'
else
infobox = infobox .. '#11af53;\"\n| colspan=\"2\" | \'\'\'Land-Tier\'\'\'[[Category:Tiere]]\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: 10px;\" | [[File:' .. image .. '|center|border|250x250px]]\n'
-- 'General' section header
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'General\'\'\'\n'
-- Health
if animalTable.health ~= nil then
infobox = infobox .. '|-\n| Gesundheit:\n| style=\"text-align: right; padding: 3px;\" | ' .. animalTable.health .. '\n'
end
-- Idle Speed
if animalTable.wanderingSpeed ~= nil then
infobox = infobox .. '|-\n| Leerlauf:\n| style=\"text-align: right; padding: 3px;\" | ' .. animalTable.wanderingSpeed .. ' mps\n'
end
-- Eats
if animalTable.foodSources ~= nil then
infobox = infobox .. '|-\n| Isst:\n| style=\"text-align: right; padding: 3px;\" | ' .. animalTable.foodSources .. '\n'
end
-- Climbing
if animalTable.climbHeight ~= nil then
infobox = infobox .. '|-\n| Kletterhöhe:\n| style=\"text-align: right; padding: 3px;\" | ' .. animalTable.climbHeight .. ' m \n'
end
-- Carbon Released
if animalTable.carbonRelease ~= nil then
infobox = infobox .. '|-\n| Kohlenstoff freigesetzt:\n| style=\"text-align: right; padding: 3px;\" | ' .. animalTable.carbonRelease .. ' ppm \n'
end
-- 'Hunting Infomation' section header
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Jagd\'\'\'\n'
-- Harvest
if animalTable.resourceItem ~= nil then
infobox = infobox .. '|-\n| Ernteartikel:\n| style=\"text-align: right; padding: 3px;\" | ' .. animalTable.resourceItem .. '\n'
end
-- Flees
if animalTable.flees ~= nil then
infobox = infobox .. '|-\n| Flieht:\n| style=\"text-align: right; padding: 3px;\" | Yes \n'
else
infobox = infobox .. '|-\n| Flieht:\n| style=\"text-align: right; padding: 3px;\" | No \n'
end
-- Animals Fear
if animalTable.fearFactor ~= nil then
infobox = infobox .. '|-\n| [[Angstfaktor]]:\n| style=\"text-align: right; padding: 3px;\" | ' .. animalTable.fearFactor .. '\n'
end
-- Running Speed
if animalTable.speed ~= nil then
infobox = infobox .. '|-\n| Fluchtgeschwindigkeit:\n| style=\"text-align: right; padding: 3px;\" | ' .. animalTable.speed .. ' mps \n'
end
-- Attack Chance
if animalTable.chanceToAttack ~= nil then
infobox = infobox .. '|-\n| Angriffschance:\n| style=\"text-align: right; padding: 3px;\" | ' .. (animalTable.chanceToAttack*100) .. ' % \n'
end
-- Attack Damage
if animalTable.damage ~= nil then
infobox = infobox .. '|-\n| Angriffsschaden:\n| style=\"text-align: right; padding: 3px;\" | ' .. animalTable.damage .. '\n'
end
-- Detect Range
if animalTable.detectRange ~= nil then
infobox = infobox .. '|-\n| Reichweite erkennen:\n| style=\"text-align: right; padding: 3px;\" | ' .. animalTable.detectRange .. ' m \n'
end
-- Attack Range
if animalTable.attackRange ~= nil then
infobox = infobox .. '|-\n| Angriffsreichweite:\n| style=\"text-align: right; padding: 3px;\" | ' .. animalTable.attackRange .. ' m \n'
end
infobox = infobox .. '|}'
return infobox
end
-- Main entry point for the Module
function p.AnimalMain()
-- get args from the Template
local args = norm()
-- get animal data
local animalData = require( "Module:AnimalData" )
return animalBox( args, animalData )
end
return p