Module:Video: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
function p.file( frame ) | function p.file( frame ) | ||
for _, source in pairs({'RoE', 'AB', 'SoD', 'HC', 'HotA'}) do | |||
if s:match('^' .. source) then | |||
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'-'..source..'-voice.webm', 'yes'}} | |||
if fileexists == 'yes' then | |||
return frame.args[1]..'-'..source..'-voice.webm' | |||
end | |||
break | |||
end | |||
end | |||
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.webm', 'yes'}} | fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.webm', 'yes'}} | ||
if fileexists == 'yes' then | if fileexists == 'yes' then | ||
return frame.args[1]..'.webm' | return frame.args[1]..'.webm' | ||
end | end | ||
local lines = p.split(frame.args[1], '-') | local lines = p.split(frame.args[1], '-') | ||
Line 21: | Line 27: | ||
end | end | ||
end | end | ||
return parent2..'.gif' | return parent2..'.gif' | ||
end | end |
Revision as of 21:23, 19 February 2024
usage
{{#invoke:video|file|unknown file}} Lua error at line 5: attempt to index global 's' (a nil value).{{#invoke:video|file|RoE 1.0 CD-Heroes3-DATA-HEROES3 VID-EVIL1A-smk-EVIL1A}}
Lua error at line 5: attempt to index global 's' (a nil value).
local p = {}
function p.file( frame )
for _, source in pairs({'RoE', 'AB', 'SoD', 'HC', 'HotA'}) do
if s:match('^' .. source) then
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'-'..source..'-voice.webm', 'yes'}}
if fileexists == 'yes' then
return frame.args[1]..'-'..source..'-voice.webm'
end
break
end
end
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.webm', 'yes'}}
if fileexists == 'yes' then
return frame.args[1]..'.webm'
end
local lines = p.split(frame.args[1], '-')
local parent2 = ''
for i, line in ipairs(lines) do
parent2 = parent2 .. line
if i + 2 >= #lines then
break
else
parent2 = parent2 .. '-'
end
end
return parent2..'.gif'
end
function p.split(str, sep)
local result = {}
local regex = ("([^%s]+)"):format(sep)
for each in str:gmatch(regex) do
table.insert(result, each)
end
return result
end
return p