Module:Fleet

-- Example how to not write modules.

local ShipBattleCardKai = require('Module:ShipBattleCardKai') local EquipmentCardKai = require('Module:EquipmentCardKai')

local function render(args) local result = {} local firstCell = true local openTab = false local openSubtab = false for _, arg in ipairs(args) do       if arg:sub(0, 2) == '!!' then if openSubtab then table.insert(result, string.format('|-| %s =\n{|class="wikitable" style="text-align:center"\n!Ship\n!colspan="4"|Equipment', arg:sub(3))) else table.insert(result, string.format(' \n|-| %s =\n{|class="wikitable" style="text-align:center"\n!Ship\n!colspan="4"|Equipment', arg:sub(3))) openSubtab = true end elseif arg:sub(0, 1) == '!' then if openSubtab then table.insert(result, ' ') openSubtab = false end if openTab then table.insert(result, string.format('|-| %s =', arg:sub(2))) else table.insert(result, string.format('')       openTab = false    end    return table.concat(result, '\n') end

return { render = render, test = render({       '!1 DD',        '!!Example 1',        '-', 'Yuudachi/Kai Ni', 'Type 3 Active Sonar',        '!!Example 2',        '-', 'Yuudachi/Kai Ni', 'Type 3 Active Sonar', 'Type 3 Active Sonar',        '!2 DD',        '!!Example 1',        '-', 'Yuudachi/Kai Ni', 'Type 3 Active Sonar',        '-', 'Shigure/Kai Ni', 'Type 3 Active Sonar',        '!!Example 2',        '-', 'Yuudachi/Kai Ni', 'Type 3 Active Sonar', 'Type 3 Active Sonar',        '-', 'Shigure/Kai Ni', 'Type 3 Active Sonar', 'Type 3 Active Sonar',    }), }