Terraria Wiki
探索
首页
所有页面
交互式地图
基础
物品
武器
工具
盔甲
配饰
药水
矿石
家具
物块
背景墙
时装物品
角色
NPC
敌怪
Boss
小动物
宠物
仆从
生物群落
事件
游戏玩法
困难模式
经典模式
专家模式
大师模式
旅行模式
多人模式
机制
制作
房屋
增益
怪物图鉴
成就
钓鱼
修饰语
指南
入门
通关攻略
职业设置
制作101
游戏进程
维护世界纯净度
NPC 快乐度
刷资源
赚钱
基地
进阶
游戏机制
生物群落蔓延
日夜更替
游戏控制
运气
月相
NPC 生成
设置
世界种子
世界大小
玩家机制
仇恨
伤害减免
死亡
防御
掉落伤害
生命
生命再生
魔力
移动速度
生成
战斗机制
攻击速度
自动挥舞
暴击
伤害
击退
射速
物品机制
挖矿速度
镐力
放置
稀有度
工具提示
使用时间
价值
模组
资源包
创意工坊中心
tModLoader
物品栏编辑器
地图查看器
数据 ID
泰拉瑞亚链接
官方网站
官方论坛
官方 Wiki 中文语言包
泰拉瑞亚 Twitter
泰拉瑞亚 Facebook
泰拉瑞亚 Instagram
泰拉瑞亚 Subreddit
Wiki 社区
帮助
样式指南
规则
视频政策
最近更改
社区专页
Wiki 翻译与样式指南
管理员告示板
Wiki Discord
FANDOM
游戏
电影
电视
wiki
探索wiki
社区中心
创建wiki
尚未注册?
注册
登录
登录
注册
Terraria Wiki
3,761
个页面
探索
首页
所有页面
交互式地图
基础
物品
武器
工具
盔甲
配饰
药水
矿石
家具
物块
背景墙
时装物品
角色
NPC
敌怪
Boss
小动物
宠物
仆从
生物群落
事件
游戏玩法
困难模式
经典模式
专家模式
大师模式
旅行模式
多人模式
机制
制作
房屋
增益
怪物图鉴
成就
钓鱼
修饰语
指南
入门
通关攻略
职业设置
制作101
游戏进程
维护世界纯净度
NPC 快乐度
刷资源
赚钱
基地
进阶
游戏机制
生物群落蔓延
日夜更替
游戏控制
运气
月相
NPC 生成
设置
世界种子
世界大小
玩家机制
仇恨
伤害减免
死亡
防御
掉落伤害
生命
生命再生
魔力
移动速度
生成
战斗机制
攻击速度
自动挥舞
暴击
伤害
击退
射速
物品机制
挖矿速度
镐力
放置
稀有度
工具提示
使用时间
价值
模组
资源包
创意工坊中心
tModLoader
物品栏编辑器
地图查看器
数据 ID
泰拉瑞亚链接
官方网站
官方论坛
官方 Wiki 中文语言包
泰拉瑞亚 Twitter
泰拉瑞亚 Facebook
泰拉瑞亚 Instagram
泰拉瑞亚 Subreddit
Wiki 社区
帮助
样式指南
规则
视频政策
最近更改
社区专页
Wiki 翻译与样式指南
管理员告示板
Wiki Discord
编辑“
Module:Iteminfo
”
返回页面
编辑源代码
查看历史
讨论 (0)
正在编辑
Module:Iteminfo
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
local data = mw.loadData( 'Module:Iteminfo/data' ) -- loading data table. local trim = mw.text.trim -- cache local currentFrame -- helper function local getArg = function(key) local value = currentFrame.args[key] if not value then return nil end value = trim(value) if value == '' then return nil else return value end end -- credit: http://richard.warburton.it -- this version is with trim. local function explode(div,str) if (div=='') then return false end local pos,arr = 0,{} -- for each divider found for st,sp in function() return string.find(str,div,pos,true) end do arr[#arr + 1] = trim(string.sub(str,pos,st-1)) -- Attach chars left of current divider pos = sp + 1 -- Jump past current divider end arr[#arr + 1] = trim(string.sub(str,pos)) -- Attach chars right of last divider return arr end local getStat = function(itemid, stat) return data[itemid][stat] or data[0][stat] or nil -- "or nil" will convert "false" to "nil" end local statname = { ["acc"] = "accessory", ["autoreuse"] = "autoReuse", ["autoswing"] = "autoReuse", ["auto"] = "autoReuse", ["axe power"] = "axe", ["axepower"] = "axe", ["bait power"] = "bait", ["baitpower"] = "bait", ["body slot"] = "bodySlot", ["bodyslot"] = "bodySlot", ["buff duration"] = "buffTime", ["buff id"] = "buffType", ["buffduration"] = "buffTime", ["buffid"] = "buffType", ["bufftime"] = "buffTime", ["bufftype"] = "buffType", ["carttrack"] = "cartTrack", ["createtile"] = "createTile", ["createwall"] = "createWall", ["critical"] = "crit", ["dd2summon"] = "DD2Summon", ["dmg"] = "damage", ["fishing power"] = "fishingPole", ["fishingpole"] = "fishingPole", ["fishingpower"] = "fishingPole", ["fishing"] = "fishingPole", ["hair dye"] = "hairDye", ["hairdye"] = "hairDye", ["hammer power"] = "hammer", ["hammerpower"] = "hammer", ["head slot"] = "headSlot", ["headslot"] = "headSlot", ["heallife"] = "healLife", ["healmana"] = "healMana", ["holdstyle"] = "holdStyle", ["id"] = "type", ["internal name"] = "internalName", ["internalname"] = "internalName", ["item id"] = "type", ["itemid"] = "type", ["kb"] = "knockBack", ["knockback"] = "knockBack", ["leg slot"] = "legSlot", ["legslot"] = "legSlot", ["liferegen"] = "lifeRegen", ["makenpc"] = "makeNPC", ["maxstack"] = "maxStack", ["mount id"] = "mountType", ["mountid"] = "mountType", ["mounttype"] = "mountType", ["mount"] = "mountType", ["nomelee"] = "noMelee", ["notammo"] = "notAmmo", ["nousegraphic"] = "noUseGraphic", ["nowet"] = "noWet", ["pick power"] = "pick", ["pickpower"] = "pick", ["pickaxe power"] = "pick", ["pickaxepower"] = "pick", ["pickaxe"] = "pick", ["placestyle"] = "placeStyle", ["projectileid"] = "shoot", ["projectile id"] = "shoot", ["questitem"] = "questItem", ["range bonus"] = "tileBoost", ["rangebonus"] = "tileBoost", ["rarity"] = "rare", ["reusedelay"] = "reuseDelay", ["shootspeed"] = "shootSpeed", ["sound"] = "UseSound", ["sounduse"] = "UseSound", ["stack"] = "maxStack", ["stringcolor"] = "stringColor", ["tile id"] = "createTile", ["tile sub id"] = "placeStyle", ["tile subid"] = "placeStyle", ["tilesubid"] = "placeStyle", ["tile wand"] = "tileWand", ["tileboost"] = "tileBoost", ["tileid"] = "createTile", ["tilewand"] = "tileWand", ["tile"] = "createTile", ["tool speed"] = "useTime", ["toolspeed"] = "useTime", ["tooltip"] = "ToolTip", ["uniquestack"] = "uniqueStack", ["use delay"] = "reuseDelay", ["use sound"] = "UseSound", ["use style"] = "useStyle", ["use time"] = "useAnimation", ["useammo"] = "useAmmo", ["useanimation"] = "useAnimation", ["usedelay"] = "reuseDelay", ["usesound"] = "UseSound", ["usestyle"] = "useStyle", ["usetime"] = "useAnimation", ["useturn"] = "useTurn", ["use"] = "useAnimation", ["velocity"] = "shootSpeed", ["wall id"] = "createWall", ["wallid"] = "createWall", ["wall"] = "createWall", ["sell"] = "value", --non-native stats: ["buy"] = "buyValue", ["price"] = "buyValue", ["buffname"] = "buffName", ["buff name"] = "buffName", ["buff"] = "buffName", ["research"] = "sacrifices" } local proc = {} proc.axe = function(value) return currentFrame:expandTemplate{ title = 'percent', args = { tostring((value or 0) * 5) .. '%' } } end proc.bodySlot = function(value) return (value == -1) and "" or value end proc.createTile = proc.bodySlot proc.createWall = proc.bodySlot proc.damage = proc.bodySlot proc.hairDye = proc.bodySlot proc.headSlot = proc.bodySlot proc.legSlot = proc.bodySlot proc.mountType = proc.bodySlot proc.tileWand = proc.bodySlot proc.bait = function(value) return currentFrame:expandTemplate{ title = 'percent', args = { tostring(value) .. '%' } } end proc.fishingPole = proc.bait proc.hammer = proc.bait proc.pick = proc.bait proc.buffTime = function(value) return currentFrame:expandTemplate{ title = 'duration', args = { (value or 0)/60 } } end proc.buffName = function(value, id) return currentFrame:expandTemplate{ title = 'GetBuffInfo', args = { getStat(id, 'buffType'), 'ename' } } end proc.crit = function(value, id) if getStat(id, 'damage') == -1 then return currentFrame:expandTemplate{ title = 'percent', args = { tostring(value) .. '%' } } -- no damage value else return currentFrame:expandTemplate{ title = 'percent', args = { tostring(value+4) .. '%' } } -- has damage value end end proc.damagetype = function(value, id) if getStat(id, 'melee') then return currentFrame:expandTemplate{ title = 'l10n', args = { 'GetItemInfo', 'damagetype_melee' } } end if getStat(id, 'ranged') then return currentFrame:expandTemplate{ title = 'l10n', args = { 'GetItemInfo', 'damagetype_ranged' } } end if getStat(id, 'magic') then return currentFrame:expandTemplate{ title = 'l10n', args = { 'GetItemInfo', 'damagetype_magic' } } end if getStat(id, 'summon') then return currentFrame:expandTemplate{ title = 'l10n', args = { 'GetItemInfo', 'damagetype_summon' } } end if getStat(id, 'thrown') then return currentFrame:expandTemplate{ title = 'l10n', args = { 'GetItemInfo', 'damagetype_thrown' } } end end proc.rare = function(value) return currentFrame:expandTemplate{ title = 'rare', args = { (value or 0) } } end proc.tileBoost= function(value) if value ~= 0 then if value > 0 then value = '+' .. tostring(value) else value = tostring(value) end return currentFrame:expandTemplate{ title = 'l10n', args = { 'GetItemInfo', 'tileBoost', ['$tiles$'] = value } } end end proc.useAmmo = function(value) if value == 40 or value == 71 or value == 97 or value == 283 or value == 771 or value == 931 then return currentFrame:expandTemplate{ title = 'l10n', args = { 'GetItemInfo', 'ammo'..tostring(value) } } end return currentFrame:expandTemplate{ title = 'itemNameFromId', args = { value } } end proc.UseSound = function(value) local str = '' for _,v in pairs(explode(',', value)) do str = str .. currentFrame:expandTemplate{ title = 'sound', args = { '', v..'.wav' } } end return str end proc.useStyle = function(value) if value == 0 then return end if value >= 1 and value <= 5 then return currentFrame:expandTemplate{ title = 'l10n', args = { 'GetItemInfo', 'usestyle'..tostring(value) } } end return value end proc.buyValue = function(value, id) local t=getStat(id, 'shopCustomPrice') if t then return currentFrame:expandTemplate{ title = 'dm', args = { t } } else return currentFrame:expandTemplate{ title = 'coin', args = { tostring(getStat(id, 'value'))..'cc' } } end end proc.value = function(value) value = tonumber(value or 0) if value > 0 then if value < 5 then -- items with value<5 have a sell value of 1, not 0 (contrary to regular rounding) return currentFrame:expandTemplate{ title = 'coin', args = { '1cc' } } else return currentFrame:expandTemplate{ title = 'coin', args = { tostring(math.floor(value/5))..'cc' } } end else return currentFrame:expandTemplate{ title = 'l10n', args = { 'GetItemInfo', 'noValue' } } end end --------------------------- local p = { -- for other module, get all stats, return as a table. getItemInfo = function(itemid) if itemid >= 5125 or itemid <= 0 then itemid = 0 end local result = {['type'] = itemid} for k,v in pairs(data[0]) do result[k] = v end for k,v in pairs(data[itemid]) do result[k] = v end return result end, -- for template, get all stats, setting in dplvars. getInfo = function(frame) currentFrame = frame -- cache local itemid = tonumber(getArg('id')) or tonumber(getArg(1)) or 0 local prefix = getArg('prefix') or getArg(2) or '_iteminfo_' if itemid >= 5125 or itemid <= 0 then itemid = 0 end local result = {['type'] = itemid} for k,v in pairs(data[0]) do result[k] = v end for k,v in pairs(data[itemid]) do result[k] = v end local args = {} for k,v in pairs(result) do args[#args + 1] = prefix .. k args[#args + 1] = v end frame:callParserFunction{ name = '#dplvar:set', args = args } end, -- for other module, get single stat, return this stat directly getItemStat = function(itemid, stat) if stat == 'count' then return 5124 end if itemid >= 5125 or itemid <= 0 then itemid = 0 end if stat == 'type' then return itemid end return data[itemid][stat] or data[0][stat] end, -- for template, get single stat, return directly getStat = function(frame) currentFrame = frame -- cache local itemid = tonumber(getArg('id')) or tonumber(getArg(1)) or 0 local stat = getArg('stat') or getArg(2) stat = statname[stat] or stat if not stat then return end if itemid >= 5125 or itemid <= 0 then itemid = 0 end local result if stat == 'type' then return itemid end if stat == 'count' then return 5124 end result = getStat(itemid, stat) if not getArg('raw') and proc[stat] then result = proc[stat](result, itemid) end if getArg('format') then result = frame:callParserFunction('formatnum', result) end return result end, } --alias p.getinfo = p.getInfo p.GetInfo = p.getInfo p.getstat = p.getStat p.GetStat = p.getStat return p
摘要:
请注意在Terraria Wiki上的所有贡献都将依据CC BY-NC-SA进行发布。
取消
编辑帮助
(在新窗口中打开)
本页使用的模板:
Template:(
(
查看源代码
)
Template:)
(
查看源代码
)
Template:Bool
(
查看源代码
)
Template:Displaytext
(
查看源代码
)
Template:Eicons
(
查看源代码
)
Template:Eil
(
查看源代码
)
Template:Eil/initOptions
(
查看源代码
)
Template:Error
(
查看源代码
)
Template:Error/l10n
(
查看源代码
)
Template:Exclusive icon link
(
查看源代码
)
Template:Exclusive icon link/initOptions
(
查看源代码
)
Template:Exclusive icons
(
查看源代码
)
Template:Extension DPL
(
查看源代码
)
Template:GetItemInfo
(
查看源代码
)
Template:Ifexists
(
查看源代码
)
Template:Iteminfo
(
查看源代码
)
Template:L10n
(
查看源代码
)
Template:L10n/register
(
查看源代码
)
Template:Lang
(
查看源代码
)
Template:LangList
(
查看源代码
)
Template:Language info
(
查看源代码
)(受保护)
Template:Localization
(
查看源代码
)
Template:Localization/register
(
查看源代码
)
Template:Note
(
查看源代码
)
Template:Note/initOptions
(
查看源代码
)
Template:Note/l10n
(
查看源代码
)
Template:Options/get
(
查看源代码
)
Template:Options/init
(
查看源代码
)
Template:Rare
(
查看源代码
)
Template:Rare/initOptions
(
查看源代码
)
Template:Rare/l10n
(
查看源代码
)
Template:Tl
(
查看源代码
)(受保护)
Template:Tr
(
查看源代码
)(受保护)
Template:Tr/db
(
查看源代码
)(受保护)
Module:Exclusive
(
查看源代码
)(受保护)
Module:Exclusive/data
(
编辑
)
Module:Exclusive/l10n
(
编辑
)
Module:Iteminfo
(
编辑
)
Module:Iteminfo/data
(
编辑
)
Module:Iteminfo/doc
(
编辑
)
Module:Language info
(
编辑
)
Module:Language info/data
(
编辑
)
Module:Tr
(
查看源代码
)(受保护)
Module:Tr/db
(
查看源代码
)(受保护)
Follow on IG
TikTok
Join Fan Lab