Die Dokumentation für dieses Modul kann unter Modul:Benutzer:XanonymusX/Doku erstellt werden

--
-- Created by IntelliJ IDEA.
-- User: patricklanzinger
-- Date: 17.03.15

local tablemodule = {}

function tablemodule.iseven(frame)
    if(frame.args[1] % 2 == 0) then
        return 0
    else
    return 1
    end
end

function tablemodule.createtable(frame)
	rows = tonumber(frame.args[1])
	collums = tonumber(frame.args[2])
	color_odd = frame.args[3]
	color_even = frame.args[4]
	sum_collum = tonumber(frame.args[5])
	sum = 0
	temp_count = 0
	temp_count2 = 0
	array = {}
	array[temp_count2] = {}
	wikimedia = ""
	for i in string.gmatch(frame.args[6], "%S+") do
		if temp_count == collums then
			temp_count = 0
			temp_count2 = temp_count2 + 1
			array[temp_count2] = {}
		end
		array[temp_count2][temp_count] = i
		temp_count = temp_count + 1
	end
	for k = 0,(rows - 1),1 do
		if (k % 2) == 0 then
			wikimedia = wikimedia.."|-style=\"background-color:"..color_even.."\"\n|"
		else
			wikimedia = wikimedia.."|-style=\"background-color:"..color_odd.."\"\n|"
			end
		for j = 0,(collums - 1), 1 do
			x = array[k][j]
			if j == (collums - 1) then
				
				wikimedia = wikimedia..tostring(x).."\n"
			else
				wikimedia = wikimedia..tostring(x)
				wikimedia = wikimedia.."||"
			end
			if j == (sum_collum - 1) then
				sum = sum + array[k][j]
			end
			
		end
		
	end
	if sum_collum > 0 then
		--colspan not working
		wikimedia = wikimedia.."|-style=\"background-color:"..color_odd.."\" colspan=\"2\"\n|"
		wikimedia = wikimedia.."| Sum last collum: "..tostring(sum)
	end
	
	return wikimedia
end

return tablemodule