×
Create a new article
Write your page title here:
We currently have 1,662 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

No edit summary
No edit summary
Line 9: Line 9:
     local talkPage = mw.title.new(talkPageTitle)
     local talkPage = mw.title.new(talkPageTitle)
     local talkContent = talkPage:getContent()
     local talkContent = talkPage:getContent()
    -- Define the URL for adding the Worldbuilder section
    local addSectionUrl = mw.uri.fullUrl(talkPageTitle, {
        action = 'edit',
        section = 'new',
        preloadtitle = 'Worldbuilders',
        preload = 'Template:WorldbuilderPreload' -- Assuming you have a template for preload content
    })
    -- Link text
    local addLinkText = 'Add worldbuilding credits now!'


     -- Check if the Talk page exists and has content
     -- Check if the Talk page exists and has content
     if not talkContent then
     if not talkContent then
         return 'No content found in Talk page.'
         return string.format('[%s %s]', addSectionUrl, addLinkText)
     end
     end


Line 21: Line 32:
     -- Check if the Worldbuilder section exists
     -- Check if the Worldbuilder section exists
     if not worldbuilderSection then
     if not worldbuilderSection then
         return 'No Worldbuilder section found.'
         return string.format('[%s %s]', addSectionUrl, addLinkText)
     end
     end



Revision as of 01:41, 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()

    -- Define the URL for adding the Worldbuilder section
    local addSectionUrl = mw.uri.fullUrl(talkPageTitle, {
        action = 'edit',
        section = 'new',
        preloadtitle = 'Worldbuilders',
        preload = 'Template:WorldbuilderPreload' -- Assuming you have a template for preload content
    })

    -- Link text
    local addLinkText = 'Add worldbuilding credits now!'

    -- Check if the Talk page exists and has content
    if not talkContent then
        return string.format('[%s %s]', addSectionUrl, addLinkText)
    end

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

    -- Check if the Worldbuilder section exists
    if not worldbuilderSection then
        return string.format('[%s %s]', addSectionUrl, addLinkText)
    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. 🇩🇪)
Cookies help us deliver our services. By using our services, you agree to our use of cookies. (Hi Margarita's Table. 🇩🇪)