打开/关闭菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

模块:SteamPrice:修订间差异

来自骷髅女孩Wiki
无编辑摘要
标签已被回退
撤销圈圈菌Q讨论)的修订版本1650
标签撤销
第4行: 第4行:


data = mw.ext.externaldata.getExternalData  {
data = mw.ext.externaldata.getExternalData  {
     url = "https://store.steampowered.com/api/appdetails?appids=245170&cc=cn.json"
     url = "https://store.steampowered.com/api/appdetails?appids=245170&cc=cn&filters=price_overview"
   , data = "json=__json"
   , data = "json=__json"
}
}

2025年2月21日 (五) 00:09的版本

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

local p = {}
-- JSON字符串
-- https://store.steampowered.com/api/appdetails?appids=245170&cc=cn&filters=price_overview

data = mw.ext.externaldata.getExternalData  {
    url = "https://store.steampowered.com/api/appdetails?appids=245170&cc=cn&filters=price_overview"
  , data = "json=__json"
}


--[[
local json_str = 
{
  "245170": {
    "success": true,
    "data": {
      "price_overview": {
        "currency": "CNY",
        "initial": 8000,
        "final": 8000,
        "discount_percent": 0,
        "initial_formatted": "",
        "final_formatted": "¥ 80.00"
      }
    }
  }
}
]]

--[[ 解析JSON字符串
local data = mw.text.jsonDecode(json_str)
]]
-- 提取价格信息
local appid = "245170"
local priceOverview = data[appid].data.price_overview

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

function p.price()
    return priceOverview.final_formatted
end

return p