Module:Video: Difference between revisions

From Heroes 3 wiki
Jump to navigation Jump to search
No edit summary
(found bug uploading new files now)
Tag: Manual revert
 
(15 intermediate revisions by the same user not shown)
Line 2: Line 2:


function p.file( frame )
function p.file( frame )
-- fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.webm', 'yes'}}
if frame.args[2] and frame.args[2] ~= 'none' then
-- fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.ogg', 'yes'}}
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'-'..frame.args[2]..'-voice.webm', 'yes'}}
if fileexists == 'yes' then
return frame.args[1]..'-'..frame.args[2]..'-voice.webm'
end
end
for _, source in pairs({'RoE', 'AB', 'SoD', 'HC', 'HotA'}) do
if frame.args[1]:match('^' .. source) == 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 lines = p.split(frame.args[1], '-')
local result = ''
local parent2 = ''
for i, line in ipairs(lines) do
for i, line in ipairs(lines) do
-- if i + 0 >= #lines then
  parent2 = parent2 .. line
-- break
if i + 2 >= #lines then
-- end
break
  result = result .. line
else
parent2 = parent2 .. '-'
end
end
end
return (result)
 
return parent2..'.gif'
-- fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.png', 'yes'}}
-- if frame.args[1] == 'if'  then
-- return 'if'
-- elseif frame.args[1] == 'elseif'  then
-- return 'elseif'
-- else
-- return 'else'
-- end
end
end



Latest revision as of 23:20, 19 February 2024

usage[edit | hide]

{{#invoke:video|file|unknown file}}
unknown file.gif

{{#invoke:video|file|RoE 1.0 CD-Heroes3-DATA-HEROES3 VID-EVIL1A-smk-EVIL1A}}

RoE 1.0 CD-Heroes3-DATA-HEROES3 VID-EVIL1A-smk-EVIL1A-RoE-voice.webm


local p = {}

function p.file( frame )
	if frame.args[2] and frame.args[2] ~= 'none' then
		fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'-'..frame.args[2]..'-voice.webm', 'yes'}}
		if fileexists == 'yes' then
			return frame.args[1]..'-'..frame.args[2]..'-voice.webm'
		end	
	end
	
	for _, source in pairs({'RoE', 'AB', 'SoD', 'HC', 'HotA'}) do
		if frame.args[1]:match('^' .. source) == 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