Module:MultiTabs

From EarthMC
Revision as of 21:53, 23 October 2023 by upgradewastaken (talk | contribs)
Jump to navigation Jump to search
local p = {} --p stands for package

function GetTableLng(tbl)
  local getN = 0
  for n in pairs(tbl) do 
    getN = getN + 1 
  end
  return getN
end

function p.create( frame )
	local myTable = frame.args
	for i = #myTable, 1, -1 do
		if myTable[i] == "" then
			table.remove(myTable, i)
		end
	end
    local int = GetTableLng(myTable)
    local width = 100/int
	local toReturn = '<div style="display:flex;border-bottom: 1px solid black;text-align:center;vertical-align: middle;line-height: 50px;font-size: 20px;">'
    for i = 1,int,1 
	do 
		toReturn = toReturn..'\n<div style="border: 1px solid black;width:'..width..'%;max-width:300px;height:50px;margin:4px;">'..frame.args[i].."</div>"
    end
	toReturn = toReturn.."</div>"
    return frame:preprocess(myTable)
end


return p