×
Create a new article
Write your page title here:
We currently have 1,906 articles on The Quelmar Wiki. Type your article name above or click on one of the titles below and start writing!



The Quelmar Wiki

Module:Worldbuilders: Difference between revisions

(Created page with "local p = {} -- Function to fetch and return the Worldbuilder section local function getWorldbuilderSection() local pageTitle = mw.title.getCurrentTitle().text local talkPageTitle = 'Talk:' .. pageTitle local talkPage = mw.title.new(talkPageTitle) local talkContent = talkPage:getContent() if not talkContent then return '' end local sectionPattern = '==%s*Worldbuilder%s*==(.*)' local worldbuilderSection = talkContent:match(sectio...")
 
No edit summary
Line 1: Line 1:
local p = {}
local p = {}


function p.getWorldbuilderSection(frame)
-- Function to fetch and return the Worldbuilder section
-- Get the title of the current page
local function getWorldbuilderSection()
local pageTitle = mw.title.getCurrentTitle().text
local pageTitle = mw.title.getCurrentTitle().text

-- Fetch the content of the Talk page
local talkPageTitle = 'Talk:' .. pageTitle
local talkPageTitle = 'Talk:' .. pageTitle
local talkPage = mw.title.new(talkPageTitle)
local talkPage = mw.title.new(talkPageTitle)
local talkContent = talkPage:getContent()
local talkContent = talkPage:getContent()


-- Check if the Talk page exists and has content
if not talkContent then
if not talkContent then
return ''
return 'No content found in Talk page.'
end
end


-- Extract the Worldbuilder section
local sectionPattern = '==%s*Worldbuilder%s*==(.*)'
local sectionPattern = '==%s*Worldbuilder%s*==(.*)'
local worldbuilderSection = talkContent:match(sectionPattern)
local worldbuilderSection = talkContent:match(sectionPattern)


-- Check if the Worldbuilder section exists
if not worldbuilderSection then
if not worldbuilderSection then
return ''
return 'No Worldbuilder section found.'
end
end


-- Return the Worldbuilder section content
return worldbuilderSection
return worldbuilderSection
end
end

-- Automatically execute the function when the module is invoked
p = getWorldbuilderSection()


return p
return p

Revision as of 01:25, 10 January 2024

Documentation for this module may be created at Module:Worldbuilders/doc

local p = {}

function p.getWorldbuilderSection(frame)
    -- Get the title of the current page
    local pageTitle = mw.title.getCurrentTitle().text

    -- Fetch the content of the Talk page
    local talkPageTitle = 'Talk:' .. pageTitle
    local talkPage = mw.title.new(talkPageTitle)
    local talkContent = talkPage:getContent()

    -- Check if the Talk page exists and has content
    if not talkContent then
        return 'No content found in Talk page.'
    end

    -- Extract the Worldbuilder section
    local sectionPattern = '==%s*Worldbuilder%s*==(.*)'
    local worldbuilderSection = talkContent:match(sectionPattern)

    -- Check if the Worldbuilder section exists
    if not worldbuilderSection then
        return 'No Worldbuilder section found.'
    end

    -- Return the Worldbuilder section content
    return worldbuilderSection
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies. (Hi Margarita's Table. 🇩🇪)

Recent changes

  • BurgerWise • Yesterday at 16:36
  • BurgerWise • Yesterday at 16:23
  • Spiderjjr45 • Yesterday at 15:16
  • Spiderjjr45 • Yesterday at 15:12
  • Cookies help us deliver our services. By using our services, you agree to our use of cookies. (Hi Margarita's Table. 🇩🇪)