Sb forum speech.png DiscordLink.png FacebookLink.png RedditLink.png SteamLink.png TwitterLink.png YoutubeLink.png

Difference between revisions of "Module:SB Infobox Begin"

From Starbase wiki
Jump to navigation Jump to search
m
m
 
(15 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 p = {}
local p = {}
function switch_key_val(tbl)
    local rtbl = {}
    for k,v in pairs(tbl) do
        rtbl[v] = k
    end
    return rtbl
end


function p.main(frame)
function p.main(frame)
local args = getArgs(frame)
local args = getArgs(frame)
return p._main(args)
return p._main(args)
end
function p.section(frame)
local args = getArgs(frame)
--local remap = switch_key_val(args)
-- return p._section(args)
local a, b = '', ''
for k, v in pairs(args) do
a = a .. tostring(k) .. ' = ' .. tostring(v) .. '\n'
end
for i, v in ipairs(args) do
b = b .. tostring(i) .. ' = ' .. tostring(v) .. '\n'
end
return('pairs: \n' .. a .. '\nipairs: ' .. b .. '\n' .. tostring(args[1]))
end
function p._section(args)
local output = ""
local s = ''
mw.log('error message')
for _,t in ipairs(args) do
if type(t) == 'table' then
for k, v in pairs(t) do
s = s .. tostring(k) .. ' = ' .. tostring(v) .. '\n'
end
else
return type(t) .. ' ' .. tostring(t)
end
s = 'yay'
end
return s
--[[local newRow = mw.html.create('div')
:addClass('SB-Infobox-Data-Cell')
newRow:tag('div')
:addClass('SB-Infobox-Cell-Header')
:wikitext(tostring(t))
newRow:tag('div')
:addClass('SB-Infobox-Cell-Body')
:wikitext(tostring(t))
output = output .. tostring(newRow)
end
--return tostring(output)--]]
end
end


function p._main(args)
function p._main(args)
local output = ""
    local t = {}
for k,v in pairs(args) do
    for i, v in ipairs(args) do
output = output .. tostring(v)
          t[i] = tostring(v)
end
        end
return tostring(output)
    return table.concat(t,"")
end
end


return p
return p

Latest revision as of 02:57, 26 May 2021

Documentation for this module may be created at Module:SB Infobox Begin/doc

local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
    local t = {}
    for i, v in ipairs(args) do
          t[i] = tostring(v)
        end
    return table.concat(t,"")
end

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