Difference between revisions of "Module:HonorTabs"
From Pathfinder Wiki
DesignerThan (talk | contribs) |
DesignerThan (talk | contribs) |
||
Line 20: | Line 20: | ||
function prepareAnswerVariants(variants) | function prepareAnswerVariants(variants) | ||
− | t_variants = | + | t_variants = split(variants, ";;") |
result_string = "" | result_string = "" | ||
for key, value in pairs(t_variants) do | for key, value in pairs(t_variants) do | ||
Line 37: | Line 37: | ||
end | end | ||
return t | return t | ||
+ | end | ||
+ | |||
+ | function split(inputstr, sep) | ||
+ | sep=sep or '%s' | ||
+ | local t={} | ||
+ | for field,s in string.gmatch(inputstr, "([^"..sep.."]*)("..sep.."?)") do | ||
+ | table.insert(t,field) | ||
+ | if s=="" then | ||
+ | return t | ||
+ | end | ||
+ | end | ||
end | end | ||
return p | return p |
Revision as of 20:58, 27 April 2021
Documentation for this module may be created at Module:HonorTabs/doc
local p = {}
function p.hello( frame )
return "Hello, world!"
end
function p.getLangSuffix( frame )
return frame:expandTemplate{ title = 'GetLangSuffix' }
end
function p.createAnswerTab( frame )
if frame.args.answerVariants then
return "There are answer variants: " .. prepareAnswerVariants(frame.args.answerVariants)
else
return "There aren't any answer variants!"
end
end
function prepareAnswerVariants(variants)
t_variants = split(variants, ";;")
result_string = ""
for key, value in pairs(t_variants) do
result_string = result_string .. " * " .. key .. " -- " .. value
end
return result_string
end
function splitString(inputstring, seperator)
if seperator == nil then
seperator = "%s"
end
local t={}
for str in string.gmatch(inputstring, "^"..seperator) do
table.insert(t, str)
end
return t
end
function split(inputstr, sep)
sep=sep or '%s'
local t={}
for field,s in string.gmatch(inputstr, "([^"..sep.."]*)("..sep.."?)") do
table.insert(t,field)
if s=="" then
return t
end
end
end
return p