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:Item
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:Item
require( 'strict' ) local gameData = require( 'Module:GameData' ) local p = {} local itemData = {} 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 itemName = args.name or mw.title.getCurrentTitle().fullText itemData = p.getData( itemName ) templateArgs = args local wikitext = { p.renderInfobox( itemName ), p.renderCategories( p.getCategories() ) } return table.concat( wikitext ) end --- Get the game data --- --- @param itemName string --- @return table function p.getData( itemName ) return gameData.getItem( itemName ) end --- Return the wikitext for the infobox --- --- @param itemName string --- @return string function p.renderInfobox( itemName ) local data = itemData or p.getData( itemName ) data.name = itemName return require( 'Module:Item/Components/Infobox' ).render( { data = data, args = templateArgs } ) end --- Get the page categories --- --- @return table function p.getCategories() local categories = { 'Items' } if itemData.evocreo2 then table.insert( categories, 'Items in EvoCreo 2' ) end if itemData.evocreo then table.insert( categories, 'Items 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 an item --- --- Items are illustrated with the EvoCreo 2 artwork by default. Pass a game ID --- to use that game's own icon, for the games whose art has been uploaded -- --- currently the EvoCreo tomes. --- --- @param name string --- @param gameId string|nil --- @return string function p.getThumbnail( name, gameId ) local game = gameId == 'evocreo' and 'evocreo' or 'evocreo2' return string.format( '%s - item - %s.png', string.lower( name ), game ) end return p
Templates used on this page:
Template:Documentation
(
view source
)
Module:Item/doc
(
view source
)
Return to
Module:Item
.