维护提醒
BWIKI 全站将于 9 月 3 日(全天)进行维护,期间无法编辑任何页面或发布新的评论。
全站通知:
模块:Expanded/Object
刷
历
编
跳到导航
跳到搜索
local Helper = require("Module:Helper")
local ObjectData = Helper.LazyLoad('Module:Expanded/Object/data')
local ID = require("Module:ID")
local p = {}
-- =p.getFieldsById{ args = { "137"} }
-- mw.logObject(p.getFieldsById{ args = { "137"} })
function p.getFieldsById(frame)
local id = frame.args[1]
local item = ObjectData[id]
if not item then return "Error: ID not found." end
return {
Name = item.Name,
Type = item.Type,
Category = item.Category,
Price = item.Price,
ContextTags = item.ContextTags
}
end
-- =p.getFirstFishTagById{ args = { "137"} }
-- mw.logObject(p.getFirstFishTagById{ args = { "137"} })
function p.getFirstFishTagById(frame)
local id = frame.args[1]
local item = ObjectData[id]
if not item or not item.ContextTags then return "" end
for _, tag in ipairs(item.ContextTags) do
if tag:match("^fish_") and tag ~= "fish_has_roe" and tag ~= "fish_pond" and tag ~= "fish_mines" and tag ~= "fish_night_market" then
return tag
end
end
return ""
end
-- =p.getAllFishTagById{ args = { "137"} }
-- mw.logObject(p.getAllFishTagById{ args = { "137"} })
function p.getAllFishTagById(frame)
local id = frame.args[1]
local item = ObjectData[id]
if not item or not item.ContextTags then return "" end
local new_tags = {}
for _, tag in ipairs(item.ContextTags) do
if tag:match("^fish_") and (tag == "fish_legendary" or tag == "fish_desert" or tag == "fish_semi_rare" or tag == "fish_carnivorous" or tag == "fish_freshwater" or tag == "fish_crab_pot" or tag == "fish_ocean" or tag == "fish_river" or tag == "fish_lake") then
table.insert(new_tags, tag)
end
end
return new_tags
end
-- =p.getColorById{ args = { "137"} }
-- mw.logObject(p.getColorById{ args = { "137"} })
function p.getColorById(frame)
local id = frame.args[1]
local item = ObjectData[id]
if not item or not item.ContextTags then return "" end
for _, tag in ipairs(item.ContextTags) do
if tag:match("^color_") then
local result = tag
result = result
:gsub("color_", "")
:gsub("_", " ")
:gsub("(%a)(%w*)", function(first, rest)
return first:upper() .. rest:lower()
end)
return result
end
end
return ""
end
-- =p.getIdByName{ args = { "小狗鱼"} }
function p.getIdByName(frame)
local itemName = frame.args[1]
local id = ID.idSVE {args = { itemName }}
if id then
if id:sub(1, 3) == "(O)" then
id = id:sub(4)
return id
else
return "Error: Name not found."
end
end
return "Error: Name not found."
end
-- =p.getFieldsByName{ args = { "Smallmouth Bass"} }
-- mw.logObject(p.getFieldsByName{ args = { "Smallmouth Bass"} })
function p.getFieldsByName(frame)
local id = p.getIdByName({ args = { frame.args[1] } })
local name = mw.ustring.lower(frame.args[1])
if id then
return p.getFieldsById({ args = { id } })
end
return "Error: Name not found."
end
-- mw.logObject(p.getPriceById{ args = { "137"} })
function p.getPriceById(frame)
return p.getFieldsById({ args = { frame.args[1] } })["Price"]
end
-- mw.logObject(p.getPriceByName{ args = { "Smallmouth Bass"} })
function p.getPriceByName(frame)
local id = p.getIdByName({ args = { frame.args[1] } })
return p.getPriceById({ args = { id } })
end
return p