Difference between revisions of "Module:Data/Templates"

From Yugipedia
Jump to: navigation, search
m (Just to prevent error (we want empty for wikitext).)
(Update old accesses to the data module.)
Line 30: Line 30:
 
end
 
end
  
local function getVideoGame( frame )
+
local function getVideoGameName( frame )
 
local v = frame:getParent().args[ 1 ]
 
local v = frame:getParent().args[ 1 ]
  
return DATA.getVideoGame( v ) or {}
+
return DATA.videoGames.getName( v ) or {}
 
end
 
end
  
Line 61: Line 61:
 
local link = UTIL.trim( frame:getParent().args[ 'link' ] )
 
local link = UTIL.trim( frame:getParent().args[ 'link' ] )
  
local game = getVideoGame( frame )
+
local game = getVideoGameName( frame )
 
 
 
return full
 
return full

Revision as of 19:49, 21 January 2020

Module documentation[create]
-- <pre>
--[=[Doc
@module Data/Templates
@description Interface for template interaction.
@author [[User:Becasita]]
@contact [[User talk:Becasita]]
]=]

local DATA = require( 'Module:Data' )
local UTIL = require( 'Module:Util' )

local D = {}

local function getLanguage( frame )
	local v = frame:getParent().args[ 1 ]

	return DATA.getLanguage( v ) or {}
end

local function getRegion( frame )
	local v = frame:getParent().args[ 1 ]

	return DATA.getRegion( v ) or {}
end

local function getMedium( frame )
	local v = frame:getParent().args[ 1 ]

	return DATA.getMedium( v ) or {}
end

local function getVideoGameName( frame )
	local v = frame:getParent().args[ 1 ]

	return DATA.videoGames.getName( v ) or {}
end

function D.ln( frame )
	return getLanguage( frame ).index or ''
end

function D.lang( frame )
	return getLanguage( frame ).full or ''
end

function D.rg( frame )
	return getRegion( frame ).index or ''
end

function D.region( frame )
	return getRegion( frame ).full or ''
end

function D.rgo( frame )
	return getMedium( frame ).abbr or ''
end

function D.vg( frame )
	local full = UTIL.trim( frame:getParent().args[ 'full' ] )

	local link = UTIL.trim( frame:getParent().args[ 'link' ] )

	local game = getVideoGameName( frame )
	
	return full
		and ( link and game.full or UTIL.removeDab( game.full or '' ) )
		or game.abbr
end

return D
-- </pre>