打开/关闭菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
圈圈菌Q留言 | 贡献2025年1月14日 (二) 22:22的版本 (创建页面,内容为“local p = {} local http = require("socket.http") local ltn12 = require("ltn12") local json = require("dkjson") local url = "https://store.steampowered.com/api/appdetails?appids=245170&cc=cn&filters=price_overview" local response = {} local res, code, response_headers, status = http.request{ url = url, sink = ltn12.sink.table(response) } if code == 200 then local data = json.decode(table.concat(response)) local priceOverview = data["245170"].dat…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

此模块的文档可以在模块:SteamPrice/doc创建

local p = {}
local http = require("socket.http")
local ltn12 = require("ltn12")
local json = require("dkjson")
local url = "https://store.steampowered.com/api/appdetails?appids=245170&cc=cn&filters=price_overview"
local response = {}
local res, code, response_headers, status = http.request{
    url = url,
    sink = ltn12.sink.table(response)
}

if code == 200 then
    local data = json.decode(table.concat(response))
    local priceOverview = data["245170"].data.price_overview
    print("货币单位: " .. priceOverview.currency)
    print("初始价格: " .. priceOverview.initial / 100 .. "元")
    print("最终价格: " .. priceOverview.final / 100 .. "元")
    print("折扣百分比: " .. priceOverview.discount_percent .. "%")
    print("格式化的最终价格: " .. priceOverview.final_formatted)
else
    print("请求失败,状态码: " .. code)
end

function p.discount()
	return string.format('%s', priceOverview.discount_percent)
end

function p.price()
	return string.format('%s', priceOverview.final)
end
return p