Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
MediaWiki help
Creopedia
Search
Search
Appearance
Log in
Personal tools
Log in
View source for Module:Trait
Module
Discussion
English
Read
View source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
View source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
←
Module:Trait
require( 'strict' ) local gameData = require( 'Module:GameData' ) local p = {} local traitData = {} local templateArgs = {} --- Wikitext entry point for the module --- --- @param frame mw.frame --- @return string function p.main( frame ) local getArgs = require( 'Module:Arguments' ).getArgs return p._main( getArgs( frame ) ) end --- Lua entry point for the module --- --- @param args table --- @return string function p._main( args ) args = args or {} local traitName = args.name or mw.title.getCurrentTitle().fullText traitData = p.getData( traitName ) templateArgs = args local wikitext = { p.renderInfobox( traitName ), p.renderCategories( p.getCategories() ) } return table.concat( wikitext ) end --- Get the game data --- --- @param traitName string --- @return table function p.getData( traitName ) return gameData.getTrait( traitName ) end --- Return the wikitext for the infobox --- --- @param traitName string --- @return string function p.renderInfobox( traitName ) local data = traitData or p.getData( traitName ) data.name = traitName return require( 'Module:Trait/Components/Infobox' ).render( { data = data, args = templateArgs } ) end --- Get the page categories --- --- @return table function p.getCategories() local categories = { 'Traits' } if traitData.evocreo2 then table.insert( categories, 'Traits in EvoCreo 2' ) end if traitData.evocreo then table.insert( categories, 'Traits in EvoCreo' ) end return categories end --- Return the wikitext for the category --- --- @param categories table --- @return string function p.renderCategories( categories ) local wikitext = {} for _, category in ipairs( categories ) do table.insert( wikitext, string.format( '[[Category:%s]]', category ) ) end return table.concat( wikitext, '' ) end --- Get the thumbnail for a trait --- --- The hyphenated trait names were uploaded with a space instead, so --- Force-field is File:Force field - trait - evocreo2.png. Normalising the --- separator here keeps those six files reachable rather than lower-casing the --- page title verbatim and red-linking them. --- --- @param name string --- @return string function p.getThumbnail( name ) local file = string.lower( name ):gsub( '%-', ' ' ) return string.format( '%s - trait - evocreo2.png', file ) end return p
Templates used on this page:
Template:Documentation
(
view source
)
Module:Trait/doc
(
view source
)
Return to
Module:Trait
.