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



    World Trigger Wiki

    Module:Which Volume: Difference between revisions

    Content added Content deleted
    mNo edit summary
    mNo edit summary
     
    Line 106: Line 106:
    function mod.get_volume(frame)
    function mod.get_volume(frame)
    local args, pargs = util.get_args_and_pargs(frame)
    local args, pargs = util.get_args_and_pargs(frame)
    local num = args[1] or pargs[1] or #tanko_items + 1
    local num = args[1] or pargs[1] or ""
    local n = tonumber(num) or #tanko_items + 1
    local mode = args[2] or pargs[2] or ""
    local mode = args[2] or pargs[2] or ""
    if mode == "tanko" then
    if mode == "tanko" then
    return frame:preprocess(find_from_table(tanko_items, num))
    return frame:preprocess(find_from_table(tanko_items, n))
    elseif mode == "headers" then
    elseif mode == "headers" then
    return frame:preprocess(find_from_table(headers, num))
    return frame:preprocess(find_from_table(headers, n))
    else
    else
    return frame:preprocess(find_from_table(normal, num))
    return frame:preprocess(find_from_table(normal, n))
    end
    end
    end
    end

    Latest revision as of 09:47, May 14, 2024

    Usage:

    {{#invoke:Which Volume|get_volume|num|mode=mode}}

    mode must be either tanko, headers, or normal. Not providing a mode will make it default to normal. Code will default to TBA if it cannot find a valid entry.

    Code uses Module:Which_Volume/tanko_data.json to keep the tanko data, please update this if anything changes.


    ---@param items table
    ---@param start integer
    ---@param stop integer
    ---@param item string
    ---@return table
    local function append_to(items, start, stop, item)
        for i = start,stop do
            items[i] = item
        end
        return items
    end
    
    -- Let me explain myself here, the stuff under the "tanko" section was so massive i felt like using 
    -- mw.loadJsonData was the best move here.
    
    local tanko_items = {}
    
    local tanko_json = mw.loadJsonData('Module:Which_Volume/tanko_data.json')
    
    for _, t in ipairs(tanko_json) do
        append_to(tanko_items, t.start, t.stop, t.item)
    end
    
    local headers = {
        [1] = "Osamu Mikumo",
        [2] = "Yūichi Jin",
        [3] = "Yūma Kuga",
        [4] = "Yūichi Jin 2",
        [5] = "Osamu Mikumo 2",
        [6] = "Large-Scale Invasion",
        [7] = "Large-Scale Invasion 2",
        [8] = "Large-Scale Invasion 3",
        [9] = "Large-Scale Invasion 4",
        [10] = "Osamu Mikumo 3",
        [11] = "Tamakoma Second",
        [12] = "Tamakoma Second 2",
        [13] = "Osamu Mikumo 4",
        [14] = "Yūichi Jin 3",
        [15] = "Galopoula",
        [16] = "Tamakoma Second 3",
        [17] = "Tamakoma Second 4",
        [18] = "Hyuse",
        [19] = "Tamakoma Branch",
        [20] = "Tamakoma Second 5",
        [21] = "Yuba Squad",
        [22] = "Chika Amatori",
        [23] = "Away Mission Test",
        [24] = "Away Mission Test 2",
        [25] = "Away Mission Test 3",
        [26] = "Away Mission Test 4",
        [27] = "Away Mission Test 5"
    }
    
    local normal = {
        [1]="Osamu Mikumo (volume){{!}}{{#if: {{{Name|}}}|Osamu Mikumo|1}}",
        [2]="Yūichi Jin (volume){{!}}{{#if: {{{Name|}}}|Yūichi Jin|2}}",
        [3]="Yūma Kuga (volume){{!}}{{#if: {{{Name|}}}|Yūma Kuga|3}}",
        [4]="Yūichi Jin 2 (volume){{!}}{{#if: {{{Name|}}}|Yūichi Jin 2|4}}",
        [5]="Osamu Mikumo 2 (volume){{!}}{{#if: {{{Name|}}}|Osamu Mikumo 2|5}}",
        [6]="Large-Scale Invasion (volume){{!}}{{#if: {{{Name|}}}|Large-Scale Invasion|6}}",
        [7]="Large-Scale Invasion 2 (volume){{!}}{{#if: {{{Name|}}}|Large-Scale Invasion 2|7}}",
        [8]="Large-Scale Invasion 3 (volume){{!}}{{#if: {{{Name|}}}|Large-Scale Invasion 3|8}}",
        [9]="Large-Scale Invasion 4 (volume){{!}}{{#if: {{{Name|}}}|Large-Scale Invasion 4|9}}",
        [10]="Osamu Mikumo 3 (volume){{!}}{{#if: {{{Name|}}}|Osamu Mikumo 3|10}}",
        [11]="Tamakoma Second (volume){{!}}{{#if: {{{Name|}}}|Tamakoma Second|11}}",
        [12]="Tamakoma Second 2 (volume){{!}}{{#if: {{{Name|}}}|Tamakoma Second 2|12}}",
        [13]="Osamu Mikumo 4 (volume){{!}}{{#if: {{{Name|}}}|Osamu Mikumo 4|13}}",
        [14]="Yūichi Jin 3 (volume){{!}}{{#if: {{{Name|}}}|Yūichi Jin 3|14}}",
        [15]="Galopoula (volume){{!}}{{#if: {{{Name|}}}|Galopoula|15}}",
        [16]="Tamakoma Second 3 (volume){{!}}{{#if: {{{Name|}}}|Tamakoma Second 3|16}}",
        [17]="Tamakoma Second 4 (volume){{!}}{{#if: {{{Name|}}}|Tamakoma Second 4|17}}",
        [18]="Hyuse (volume){{!}}{{#if: {{{Name|}}}|Hyuse|18}}",
        [19]="Tamakoma Branch (volume){{!}}{{#if: {{{Name|}}}|Tamakoma Branch|19}}",
        [20]="Tamakoma Second 5 (volume){{!}}{{#if: {{{Name|}}}|Tamakoma Second 5|20}}",
        [21]="Yuba Squad (volume){{!}}{{#if: {{{Name|}}}|Yuba Squad|21}}",
        [22]="Chika Amatori (volume){{!}}{{#if: {{{Name|}}}|Chika Amatori|22}}",
        [23]="Away Mission Test (volume){{!}}{{#if: {{{Name|}}}|Away Mission Test|23}}",
        [24]="Away Mission Test 2 (volume){{!}}{{#if: {{{Name|}}}|Away Mission Test 2|24}}",
        [25]="Away Mission Test 3 (volume){{!}}{{#if: {{{Name|}}}|Away Mission Test 3|25}}",
        [26]="Away Mission Test 4 (volume){{!}}{{#if: {{{Name|}}}|Away Mission Test 4 |26}}",
        [27]="Away Mission Test 5 (volume){{!}}{{#if: {{{Name|}}}|Away Mission Test 5|27}}"
    }
    
    ---@param table table
    ---@param num integer
    ---@return string
    local function find_from_table(table, num)
        for i, v in ipairs(table) do
            if i == num then
                return v
            end
        end
        return "TBA"
    end
    
    local util = require("Module:Util")
    
    local mod = {
        find_from_table = find_from_table,
        append_to = append_to,
        tanko_items = tanko_items,
        headers = headers,
        normal = normal
    }
    
    function mod.get_volume(frame)
        local args, pargs = util.get_args_and_pargs(frame)
        local num = args[1] or pargs[1] or ""
        local n = tonumber(num) or #tanko_items + 1
        local mode = args[2] or pargs[2] or ""
        if mode == "tanko" then
            return frame:preprocess(find_from_table(tanko_items, n))
        elseif mode == "headers" then
            return frame:preprocess(find_from_table(headers, n))
        else
            return frame:preprocess(find_from_table(normal, n))
        end
    end
    
    return mod
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.

    Recent changes

  • Fairemont • 19 minutes ago
  • Desk gun • 25 minutes ago
  • Fairemont • 1 hour ago
  • Desk gun • 2 hours 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!

    July 1

    Ken Satori

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