打开/关闭搜索
搜索
打开/关闭菜单
63
133
6
1.6K
骷髅女孩Wiki
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
上传文件
可选角色
菲莉亚
赛瑞贝拉
孔雀
帕娜索
幸运猫女
痛苦转轮
瓦伦汀
双形
丝瑰丽
大乐队
伊莱莎
芙库亚
贝奥武夫
机械猫女
安妮
小伞
黑色大丽花
玛丽
系统
操纵方法
游戏界面
数据图例
启动选项
更新日志
机制
移动
进攻
防守
连段
组队
进阶
杂项
常见问题
术语
训练室
词典
通知
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
创建账号
登录
查看“模块:SteamPrice”的源代码
来自骷髅女孩Wiki
查看
阅读
查看源代码
查看历史
associated-pages
模块
讨论
更多操作
←
模块:SteamPrice
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} -- JSON字符串 -- https://store.steampowered.com/api/appdetails?appids=245170&cc=cn&filters=price_overview --data = mw.loadJsonData("https://store.steampowered.com/api/appdetails?appids=245170&cc=cn.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" } } } } ]] -- 安全提取价格信息的工具函数 local function getPriceOverview() -- 逐层检查字段是否存在 if type(data) ~= "table" then return nil, "Invalid JSON data" end local appData = data[appid] if not appData or not appData.success then return nil, "Failed to fetch app data" end local gameData = appData.data if not gameData then return nil, "No game data available" end return gameData.price_overview -- 可能为nil end -- 获取价格信息(带默认值) local priceOverview = getPriceOverview() function p.discount() if not priceOverview then return "N/A" -- 默认值或错误提示 end return string.format('%d%%', priceOverview.discount_percent) end function p.price() if not priceOverview or not priceOverview.final_formatted then return "价格信息不可用" -- 默认值 end return priceOverview.final_formatted end return p
该页面使用的模板:
模块:SteamPrice/doc
(
查看源代码
)
返回
模块:SteamPrice
。