Editing Module:NavboxGenerator

Jump to navigation Jump to search
Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 3: Line 3:
local function generateNavbox(data, level)
local function generateNavbox(data, level)
     local result = {}
     local result = {}
     local boxSizePercent = 100 - (level-1)*15 -- 15% less per level, 100%, 85%, 70%, 55%, etc.
     local boxSize = 5 - level  -- Adjust box size reduction per level
     local fontSize = 170 - (level * 15)  -- Adjust font size reduction per level
     local fontSize = 150 - (level * 20)  -- Adjust font size reduction per level
      
      
     for key, value in pairs(data) do
     for key, value in pairs(data) do
Line 12: Line 12:
             -- Leaf node, render Display content
             -- Leaf node, render Display content
             table.insert(result, string.format(
             table.insert(result, string.format(
                 '<div style="text-align: center; font-size:%d%%;">%s</div>',
                 '<div style="text-align: center; font-size:%d%%; %s">%s</div>',
                 fontSize, value
                 fontSize, data.Style or "", value
             ))
             ))
         elseif type(value) == "table" then
         elseif type(value) == "table" then
             -- Nested node, render title with optional Style and recurse
             -- Nested node, render title with optional Style and recurse
             table.insert(result, string.format(
             table.insert(result, string.format(
                 '<div style="width: %s%%; margin-left: auto; margin-right: auto; text-align: center; font-size:%d%%; border:1px solid #aaa; %s">%s</div>',
                 '<div style="text-align: center; font-size:%d%%; border:1px solid #aaa; padding:5px; margin:2px; %s">%s</div>',
                 boxSizePercent, fontSize, value.Style or "", key
                 fontSize, value.Style or "", key
             ))
             ))
             table.insert(result, generateNavbox(value, level + 1))  -- Recursively process next level
             table.insert(result, generateNavbox(value, level + 1))  -- Recursively process next level
Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Deadlock:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template