Module:Video: Difference between revisions

From Heroes 3 wiki
Jump to navigation Jump to search
(Created page with "local p = {} function p.file( frame ) -- fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.webm', 'yes'}} -- fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.ogg', 'yes'}} local lines = p.split(frame.args[1], '-') local result = '' for i, line in ipairs(lines) do result = result .. i .. ':' .. line end -- fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]...")
 
No edit summary
Line 6: Line 6:
local lines = p.split(frame.args[1], '-')
local lines = p.split(frame.args[1], '-')
local result = ''
local result = 'aaa'
for i, line in ipairs(lines) do
for i, line in ipairs(lines) do
  result = result .. i .. ':' .. line
  result = result .. i .. ':' .. line

Revision as of 00:27, 13 February 2024

usage

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

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

local p = {}

function p.file( frame )
	-- fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.webm', 'yes'}}
	-- fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.ogg', 'yes'}}
	
	local lines = p.split(frame.args[1], '-')
	local result = 'aaa'
	for i, line in ipairs(lines) do
	   result = result .. i .. ':' .. line
	end
	
	-- 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

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