Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Song versions line: Difference between revisions

From Sekaipedia
Content added Content deleted
mNo edit summary
m (ChaoticShadow moved page Module:VocalVersionsLine to Module:Song versions line without leaving a redirect)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local utils = require('Module:Utilities')
local utils = require('Module:Utilities')
local yesno = require('Module:Yesno')
local constants = require('Module:Constants')
local yesno = require('Module:Yesno')


local p = {}
local p = {}

local characters = {
'hatsune miku', 'kagamine rin', 'kagamine len', 'megurine luka', 'meiko', 'kaito',
'hoshino ichika', 'tenma saki', 'mochizuki honami', 'hinomori shiho',
'hanasato minori', 'kiritani haruka', 'momoi airi', 'hinomori shizuku',
'azusawa kohane', 'shiraishi an', 'shinonome akito', 'aoyagi toya',
'tenma tsukasa', 'otori emu', 'kusanagi nene', 'kamishiro rui',
'yoisaki kanade', 'asahina mafuyu', 'shinonome ena', 'akiyama mizuki'
}


local function formatSingers(arg)
local function formatSingers(arg)
Line 18: Line 10:
local splits = utils.split(arg, ",")
local splits = utils.split(arg, ",")
for i=1,#splits do
for i=1,#splits do
splits[i] = utils.trim(splits[i])
splits[i] = mw.text.trim(splits[i])
if utils.array_index_of(characters, string.lower(splits[i])) ~= -1 then
if constants.get_character(splits[i]) ~= nil then
splits[i] = '[[' .. splits[i] .. ']]'
splits[i] = '[[' .. splits[i] .. ']]'
end
end
Line 31: Line 23:
local function formatFile(arg)
local function formatFile(arg)
if arg and arg ~= '' then
if arg and arg ~= '' then
return '[[' .. arg .. ']]'
return '[[File:' .. arg .. ']]'
end
end

Latest revision as of 17:06, 24 July 2022

Documentation for this module may be created at Module:Song versions line/doc

local getArgs   = require('Module:Arguments').getArgs
local utils     = require('Module:Utilities')
local constants = require('Module:Constants')
local yesno     = require('Module:Yesno')

local p = {}

local function formatSingers(arg)
	if arg and arg ~= '' then
		local splits = utils.split(arg, ",")
		for i=1,#splits do
			splits[i] = mw.text.trim(splits[i])
			if constants.get_character(splits[i]) ~= nil then
				splits[i] = '[[' .. splits[i] .. ']]'
			end
		end
		return mw.text.listToText(splits)
	end
	
	return nil
end

local function formatFile(arg)
	if arg and arg ~= '' then
		return '[[File:' .. arg .. ']]'
	end
	
	return nil
end

function p.main(frame)
	local args = getArgs(frame)
	
	local root = mw.html.create('tr')
	
	root:tag('td'):wikitext(args['version'])
	root:tag('td'):wikitext(formatSingers(args['singers']))
	root:tag('td'):wikitext(formatFile(args['audio']))
	
	return tostring(root)
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.