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

Module:VHVersion

From Vault Hunters Official Wiki
Revision as of 17:56, 15 July 2025 by Mnooseman (talk | contribs) (Created page with "local p = {} local http = require('socket.http') local json = require('dkjson') function p.getVersion(frame) local url = 'https://api.vaulthunters.gg/patch-notes?limit=1' -- Fetch the data local body, status = http.request(url) if status ~= 200 then return 'Error fetching version data' end -- Parse JSON local data, pos, err = json.decode(body) if err then return 'Error parsing JSON: ' .. err end...")
(diff) ← Older revision | Latest revision (diff) | Newer revision β†’ (diff)

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

local p = {}
local http = require('socket.http')
local json = require('dkjson')

function p.getVersion(frame)
    local url = 'https://api.vaulthunters.gg/patch-notes?limit=1'
    
    -- Fetch the data
    local body, status = http.request(url)
    
    if status ~= 200 then
        return 'Error fetching version data'
    end
    
    -- Parse JSON
    local data, pos, err = json.decode(body)
    
    if err then
        return 'Error parsing JSON: ' .. err
    end
    
    -- Extract version from first item
    if data and data[1] and data[1].version then
        local version = data[1].version
        
        -- Transform "18.3.0" to "3.18.3"
        -- Remove the patch version (everything after the last dot)
        local majorMinor = version:match("^(.+)%.")
        
        if majorMinor then
            return "3." .. majorMinor
        else
            return "3." .. version
        end
    else
        return 'Version not found in response'
    end
end

return p