×
Create a new article
Write your page title here:
We currently have 1,393 articles on World Trigger Wiki. Type your article name above or create one of the articles listed here!



    World Trigger Wiki

    Module:Chapter Infobox: Difference between revisions

    Content added Content deleted
    mNo edit summary
    mNo edit summary
     
    Line 9: Line 9:
    local pargs={}
    local pargs={}
    if parent then pargs=parent.args end
    if parent then pargs=parent.args end
    local num = args[1] or pargs[1] or 0
    local num = args[1] or pargs[1] or ""
    if num - 1 <= 0 then
    local n = tonumber(num) or 0
    if n - 1 <= 0 then
    return "N/A"
    return "N/A"
    else
    else
    frame.args[1] = num - 1
    frame.args[1] = n - 1
    return "[[" .. wc.where_chapter(frame) .. "]]"
    return "[[" .. wc.where_chapter(frame) .. "]]"
    end
    end
    Line 24: Line 25:
    local pargs={}
    local pargs={}
    if parent then pargs=parent.args end
    if parent then pargs=parent.args end
    local num = args[1] or pargs[1] or 0
    local num = args[1] or pargs[1] or ""
    frame.args[1] = num + 1
    local n = tonumber(num) or #wc.chapters + 1
    frame.args[1] = n + 1
    local ret = wc.where_chapter(frame)
    local ret = wc.where_chapter(frame)
    if ret ~= "TBA" then return "[[" .. ret .. "]]" else return ret end
    if ret ~= "TBA" then return "[[" .. ret .. "]]" else return ret end

    Latest revision as of 10:21, May 14, 2024

    For Previous Chapter:

    num must be the current chapter number, this removes the need for all the #expr calls {{#invoke:Chapter Infobox|prev_chapter|num}}

    For Next Chapter:

    num must be the current chapter number, this removes the need for all the #expr calls {{#invoke:Chapter Infobox|next_chapter|num}}

    Code uses/calls Module:Which_Chapter


    local wc = require("Module:Which_Chapter")
    
    local mod = {}
    
    ---@return string
    function mod.prev_chapter(frame)
        local args = frame.args
        local parent = frame:getParent()
        local pargs={}
        if parent then pargs=parent.args end
        local num = args[1] or pargs[1] or ""
        local n = tonumber(num) or 0
        if n - 1 <= 0 then
            return "N/A"
        else
            frame.args[1] = n - 1
            return "[[" .. wc.where_chapter(frame) .. "]]"
        end
    end
    
    ---@return string
    function mod.next_chapter(frame)
        local args = frame.args
        local parent = frame:getParent()
        local pargs={}
        if parent then pargs=parent.args end
        local num = args[1] or pargs[1] or ""
        local n = tonumber(num) or #wc.chapters + 1
        frame.args[1] = n + 1
        local ret = wc.where_chapter(frame)
        if ret ~= "TBA" then return "[[" .. ret .. "]]" else return ret end
    end
    
    return mod
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.

    Recent changes

  • Fairemont • 1 day ago
  • Fairemont • 1 day ago
  • Fairemont • 1 day ago
  • Fairemont • 1 day ago
  • Welcome to WorldTriggerWiki.com!

    We have completed moving the wiki here from FANDOM. This is the wiki that will be maintained and updated in the future (more information). Enjoy your stay!


    If you would like to get involved, or if you have questions or feedback, check out the Community Portal.

    Happy Birthday!

    June 30

    Takeru Yuiga

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.