The Long Dark Wiki
Explore
Main Page
Discuss
All Pages
Community
Interactive Maps
Recent Blog Posts
The Long Dark
Skills
Archery
Carcass Harvesting
Cooking
Fire Starting
Gunsmithing
Ice Fishing
Mending
Rifle Firearm
Revolver Firearm
Regions (A-G)
Ash Canyon
Blackrock
Bleak Inlet
Broken Railroad
Coastal Highway
Desolation Point
Forlorn Muskeg
Forsaken Airfield
Regions (H-Z)
Hushed River Valley
Mountain Town
Mystery Lake
Pleasant Valley
Timberwolf Mountain
Transfer Pass
Zone of Contamination
Transition Zones
The Ravine
Old Island Connector
Winding River
Cinder Hills Coal Mine
Abandoned Mine No. 3
Far Range Branch Line
Caves
Items
Clothing
First Aid
Food And Drink
Tools
Materials
Decay
Wildlife
Deer
Rabbit
Wolf
Timberwolf
Bear
Moose
Ptarmigan
Poisoned Wolf
Cougar
Characters
Will Mackenzie
Astrid Greenwood
Grey Mother
Methuselah
Hobbs
Jeremiah
Mathis
Molly
Father Thomas
Heller
Gameplay
Needs
Condition
Stamina
Encumbrance
Afflictions
Aurora
Survival mode
Story mode
Episode 1: Do Not Go Gentle
Episode 2: Luminance Fugue
Episode 3: Crossroads Elegy
Episode 4: Fury, then Silence
Episode 5: The Light At The End Of All Things
Challenges
Hopeless Rescue
The Hunted, Part One
The Hunted, Part Two
The Hunted, Part Three
Whiteout
Nomad
Archivist
As the Dead Sleep
Escape the Darkwalker
DLCs
Tales from the Far Territory
Other
Game info
Game updates
Game developer
Community
About
Administrators and Wikia Rules
Thekillergreece (Bureaucrat)
Velonews (Administrator)
Aescopalus (Administrator)
TheCoolCario (Administrator)
Recent blog posts
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
The Long Dark Wiki
1,285
pages
Explore
Main Page
Discuss
All Pages
Community
Interactive Maps
Recent Blog Posts
The Long Dark
Skills
Archery
Carcass Harvesting
Cooking
Fire Starting
Gunsmithing
Ice Fishing
Mending
Rifle Firearm
Revolver Firearm
Regions (A-G)
Ash Canyon
Blackrock
Bleak Inlet
Broken Railroad
Coastal Highway
Desolation Point
Forlorn Muskeg
Forsaken Airfield
Regions (H-Z)
Hushed River Valley
Mountain Town
Mystery Lake
Pleasant Valley
Timberwolf Mountain
Transfer Pass
Zone of Contamination
Transition Zones
The Ravine
Old Island Connector
Winding River
Cinder Hills Coal Mine
Abandoned Mine No. 3
Far Range Branch Line
Caves
Items
Clothing
First Aid
Food And Drink
Tools
Materials
Decay
Wildlife
Deer
Rabbit
Wolf
Timberwolf
Bear
Moose
Ptarmigan
Poisoned Wolf
Cougar
Characters
Will Mackenzie
Astrid Greenwood
Grey Mother
Methuselah
Hobbs
Jeremiah
Mathis
Molly
Father Thomas
Heller
Gameplay
Needs
Condition
Stamina
Encumbrance
Afflictions
Aurora
Survival mode
Story mode
Episode 1: Do Not Go Gentle
Episode 2: Luminance Fugue
Episode 3: Crossroads Elegy
Episode 4: Fury, then Silence
Episode 5: The Light At The End Of All Things
Challenges
Hopeless Rescue
The Hunted, Part One
The Hunted, Part Two
The Hunted, Part Three
Whiteout
Nomad
Archivist
As the Dead Sleep
Escape the Darkwalker
DLCs
Tales from the Far Territory
Other
Game info
Game updates
Game developer
Community
About
Administrators and Wikia Rules
Thekillergreece (Bureaucrat)
Velonews (Administrator)
Aescopalus (Administrator)
TheCoolCario (Administrator)
Recent blog posts
Editing
Module:Navbox
Back to page
Edit source
View history
Talk (0)
Edit Page
Module:Navbox
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- <nowiki> -- -- Implements {{navbox}} -- local p = {} local tnavbar = require( 'Module:Tnavbar' ) local yesno = require( 'Module:Yesno' ) local onmain = require('Module:Mainonly').on_main() local page_title = mw.title.getCurrentTitle().fullText -- -- Helper for inserting a new row into the navbox -- -- @param tbl {mw.html table} -- @return tbl {mw.html table} -- local function insertRow( tbl ) return tbl:tag( 'tr' ) end -- -- Creates the navbox table -- -- @param args {table} -- @return tbl {mw.html table} -- local function createTbl( args ) local tbl = mw.html.create( 'table' ) tbl :addClass( yesno( args.subgroup ) and 'navbox-subgroup' or 'navbox' ) :addClass( 'nowraplinks' ) if not yesno( args.subgroup ) and ( args.state == 'collapsed' or args.state == 'uncollapsed' or args.state == 'autocollapse' or -- defaults to autocollapse args.state == nil ) then tbl:addClass( 'mw-collapsible' ) if args.state == 'collapsed' then tbl:addClass( 'mw-collapsed' ) elseif args.state == 'uncollapsed' then tbl:addClass('navbox-uncollapsed') end end if yesno( args.collapsible ) then tbl:addClass( 'navbox-collapsible' ) end if args.style then tbl:cssText( args.style ) end -- manually set collapse/expand messages tbl :attr( { ['cellspacing'] = '0', ['data-expandtext'] = 'show', ['data-collapsetext'] = 'hide' } ) return tbl end -- -- Wrapper for [[Module:Tnavbar]] -- -- @param args {table} -- @return {string} -- local function navbar( args ) return tnavbar._collapsible( { [1] = '<span style="display:none;">TLD </span>'..args.title, [2] = args.name } ) end -- -- Creates the header (what is seen when the navbox is collapsed) -- -- @param tbl {mw.html table} -- @param args {table} -- @return {mw.html table} -- local function header( tbl, args ) local div = insertRow( tbl ) :tag( 'th' ) :attr( 'colspan', '2' ) :addClass( 'navbox-title' ) :attr( 'id' , 'navbox-title' ) :tag( 'div' ) if args.name then div :css( 'padding-right', args.state == 'plain' and '6em' or '0' ) :wikitext( navbar( args ) ) else div :css( 'padding-left', args.state == 'plain' and '0' or '6em' ) :wikitext( '<span style="display:none;">TLD </span>'..args.title ) end return div:allDone() end -- -- Inserts a row into the navbox -- -- @param tbl {mw.html table} -- @param gtitle {string} -- @param group {string} -- @param gtype {string} -- @param gcats {table} -- @param style {string} -- @return {mw.html table} -- local function row( tbl, gtitle, group, gtype, gcats, style, _name, subgroup ) local tr = insertRow( tbl ) local td if gtitle then td = tr :addClass( 'navbox-group' ) :tag( 'td' ) :addClass( 'navbox-group-title' ) :wikitext( gtitle ) :done() :tag( 'td' ) else td = tr :addClass( 'navbox-group' ) :addClass( 'navbox-group-split' ) :tag( 'td' ) :addClass( 'navbox-group-title-hidden' ) :attr( 'colspan', '0' ) :css( 'display', 'none' ) :done() :tag( 'td' ) :attr( 'colspan', '2' ) end if mw.ustring.match( group, '^%s*%*' ) then td:newline() -- trim whitespace on bullets local spl = mw.text.split( group, '\n' ) for i = 1, #spl do spl[i] = mw.text.trim( spl[i] ) end group = '\n' .. table.concat( spl, '\n' ) end td :addClass( 'navbox-list' ) :wikitext( group ) --group3 if gtype and mw.ustring.lower( gtype ) == 'subgroup' then td :addClass( 'navbox-parent' ) :css( { padding = '0', ['border-bottom'] = '0' } ) end if style then td:cssText( style ) end -- add subgroup categories if next(gcats) and onmain then first_char = page_title:sub(1,1) title_pattern = "[" .. first_char:upper() .. first_char:lower() .. "]" .. page_title:sub(2) title_pattern = title_pattern :gsub("%(","%%(") :gsub("%)","%%)") :gsub("_"," ") :gsub(" ","[_ ]") :gsub("%-","%%-") local link_patterns = { "%[%["..title_pattern.."%]%]", "%[%["..title_pattern.."%|", "{{[Pp]link%|"..title_pattern.."}}", "{{[Pp]link%|"..title_pattern.."%|", "{{[Pp]linkp%|"..title_pattern.."}}", "{{[Pp]linkp%|"..title_pattern.."%|", "{{[Ii]linkp%|"..title_pattern.."}}", "{{[Ii]linkp%|"..title_pattern.."%|", "{{[Cc]hatl%|"..title_pattern.."}}", "{{[Cc]hatl%|"..title_pattern.."%|" } for _,v in ipairs(link_patterns) do if group:match(v) then for _,cat in ipairs(gcats) do td:wikitext('[[Category:'..cat..']]') end break end end end return td:allDone() end -- -- Inserts a footer into the navbox -- -- @param tbl {mw.html table} -- @param args {table} -- @return {mw.html table} -- local function footer( tbl, args ) local th = insertRow( tbl ) :tag( 'th' ) :attr( 'colspan', '2' ) :addClass( 'navbox-footer' ) if args.fstyle then th:cssText( args.fstyle ) end if mw.ustring.match( args.footer, '^%s*%*' ) then th:newline() -- trim whitespace on bullets local spl = mw.text.split( args.footer, '\n' ) for i = 1, #spl do spl[i] = mw.text.trim( spl[i] ) end args.footer = table.concat( spl, '\n' ) th:addClass( 'navbox-list' ) end th:wikitext( args.footer ) return th:allDone() end -- -- Adds [[Category:Navigational templates]] to navbox template pages -- -- @return {string} -- local function categories() local title = mw.title.getCurrentTitle() local page = title.text local ns = title.nsText if ns == 'Template' then -- sort in category by pagename return '[[Category:Navigational templates|' .. page .. ']]' else return '' end end -- -- Adds [[Template:Navbox/doc]] to navbox template pages -- -- @param args {table} -- @return {string} -- local function docs( args ) local frame = mw.getCurrentFrame() local title = mw.title.getCurrentTitle() local base = title.baseText local ns = title.nsText -- not if a subpage of [[Template:Navbox]] if base ~= 'Navbox' and -- in template ns ns == 'Template' and -- not a navbox group within a navbox not yesno( args.subgroup ) and -- not a collapsible navbox within a navbox not yesno( args.collapsible ) and -- not if the doc argument is not set to "yes" yesno( args.doc, false ) then return frame:expandTemplate{ title = 'Navbox/doc' } else return '' end end -- -- Navbox method to allow it to be called by other modules -- -- @param _args {table} -- @return {string} -- function p._navbox( _args ) local args = {} local wkCss = '' local wkDiv = '' local j -- preserves parser function behaviour where an empty string is considered undefined -- or nil in lua's case for k, v in pairs( _args ) do if v ~= '' then args[k] = v end end local tbl = createTbl( args ) if not yesno( args.subgroup ) then tbl = header( tbl, args ) end -- insert up to 20 rows for i = 1, 20 do j = tostring( i ) if args['group' .. j] then local gcats = {} for p = 1, 20 do local q = tostring ( p ) if args['g' .. j .. 'cat' .. q] then table.insert(gcats, args['g' .. j .. 'cat' .. q]) else break end end tbl = row( tbl, args['gtitle' .. j], args['group' .. j], args['gtype' .. j], gcats, args['style' .. j], args.name, args.subgroup ) else break end end if args.footer then tbl = footer( tbl, args ) end tbl = tostring( tbl ) local cats = '' if not yesno(args.subgroup) and not yesno(args.hidecat) then cats = categories() end local docs = docs( args ) return tbl .. cats .. docs end -- -- Main navbox method accessed through #invoke -- -- @param frame {table} -- @return {string} -- function p.navbox( frame ) local args = frame:getParent().args return p._navbox( args ) end return p -- </nowiki>
Summary:
Please note that all contributions to the The Long Dark Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Navbox/doc
(
edit
)
Follow on IG
TikTok
Join Fan Lab