Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:MapUrls: Difference between revisions

From SlabWiki
Created page with "local p = {} -- Define the mapping between the inputs and URLs local map = { ["S4, Overworld"] = "SlabserverS4", ["S3, Overworld"] = "SlabserverS3", ["S4, Nether"] = "SlabserverS4_Nether", ["S3, Nether"] = "SlabserverS3_Nether" -- Add more mappings here as needed } -- Default function to generate the URL based on input parameters function p._main(frame) local server = frame.args.server -- E.g., S4, S3, etc. local world = frame.args.world --..."
 
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 3: Line 3:
-- Define the mapping between the inputs and URLs
-- Define the mapping between the inputs and URLs
local map = {
local map = {
     ["S4, Overworld"] = "SlabserverS4",
     ["survivals4, overworld"] = "map.slabserver.org?world=SlabserverS4",
     ["S3, Overworld"] = "SlabserverS3",
     ["survivals4, nether"] = "map.slabserver.org?world=SlabserverS4_nether",
     ["S4, Nether"] = "SlabserverS4_Nether",
    ["survivals4, end"] = "map.slabserver.org?world=SlabserverS4_the_end",
     ["S3, Nether"] = "SlabserverS3_Nether"
    ["survivals3, overworld"] = "s3map.slabserver.org?world=Slabserver S3",
     -- Add more mappings here as needed
    ["survivals3, nether"] = "s3map.slabserver.org?world=Slabserver S3_nether",
     ["survivals3, end"] = "s3map.slabserver.org?world=Slabserver S3_the_end",
     ["survivals2, overworld"] = "s2map.slabserver.org?world=Slabserver%20Prelease",
    ["survivals2, nether"] = "s2map.slabserver.org?world=Slabserver%20Prelease_nether",
     ["survivals2, end"] = "s2map.slabserver.org?world=Slabserver%20Prelease_the_end"
}
}


-- Default function to generate the URL based on input parameters
-- Default function to generate the URL based on input parameters
function p._main(frame)
function p.main(frame)
     local server = frame.args.server -- E.g., S4, S3, etc.
     local season = frame.args.season:lower() -- E.g., S4, S3, etc.
     local world = frame.args.world -- E.g., Overworld, Nether
     local world = frame.args.world:lower() -- E.g., Overworld, Nether


     -- Build the key based on the inputs
     -- Build the key based on the inputs
     local key = server .. ", " .. world
     local key = season .. ", " .. world


     -- Lookup the URL in the map
     -- Lookup the URL in the map
Line 25: Line 29:
         return url
         return url
     else
     else
         return "Unknown server/world combination"
         return "map_error"
     end
     end
end
end


-- Set the default function to be the main function
-- Return a table, with `main` as the default function
return p._main
return p

Latest revision as of 08:51, 8 December 2024

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

local p = {}

-- Define the mapping between the inputs and URLs
local map = {
    ["survivals4, overworld"] = "map.slabserver.org?world=SlabserverS4",
    ["survivals4, nether"] = "map.slabserver.org?world=SlabserverS4_nether",
    ["survivals4, end"] = "map.slabserver.org?world=SlabserverS4_the_end",
    ["survivals3, overworld"] = "s3map.slabserver.org?world=Slabserver S3",
    ["survivals3, nether"] = "s3map.slabserver.org?world=Slabserver S3_nether",
    ["survivals3, end"] = "s3map.slabserver.org?world=Slabserver S3_the_end",
    ["survivals2, overworld"] = "s2map.slabserver.org?world=Slabserver%20Prelease",
    ["survivals2, nether"] = "s2map.slabserver.org?world=Slabserver%20Prelease_nether",
    ["survivals2, end"] = "s2map.slabserver.org?world=Slabserver%20Prelease_the_end"
}

-- Default function to generate the URL based on input parameters
function p.main(frame)
    local season = frame.args.season:lower() -- E.g., S4, S3, etc.
    local world = frame.args.world:lower() -- E.g., Overworld, Nether

    -- Build the key based on the inputs
    local key = season .. ", " .. world

    -- Lookup the URL in the map
    local url = map[key]

    -- Return the URL or a default value if no match is found
    if url then
        return url
    else
        return "map_error"
    end
end

-- Return a table, with `main` as the default function
return p