维护提醒
BWIKI 全站将于 9 月 3 日(全天)进行维护,期间无法编辑任何页面或发布新的评论。
全站通知:
模块:Furniture
刷
历
编
跳到导航
跳到搜索
local Helper = require("Module:Helper")
local ID = require("Module:ID")
local Data = Helper.LazyLoad("Module:Furniture/data")
local p = {}
-- 解析数据函数
function p.parseData()
local parsedData = {}
for id, entry in pairs(Data) do
local fields = {}
for field in string.gmatch(entry, "[^/]+") do
table.insert(fields, field)
end
parsedData[id] = {
name = fields[1],
type = fields[2],
tileSize = fields[3],
collisionSize = fields[4],
rotation = tonumber(fields[5]) or -1,
price = tonumber(fields[6]) or -1,
placementRestriction = tonumber(fields[7]) or -1,
displayName = fields[8],
spriteIndex = fields[9] or "-1",
spriteSheet = fields[10] or "TileSheets/furniture",
noRandomSale = fields[11] == "true",
contextTags = fields[12] or "none"
}
end
return parsedData
end
-- 调试函数
function p.debug()
local parsedData = p.parseData()
local output = {"<pre>"}
for id, furniture in pairs(parsedData) do
table.insert(output, string.format("ID: %s", id))
table.insert(output, string.format(" Name: %s", furniture.name))
table.insert(output, string.format(" Type: %s", furniture.type))
table.insert(output, string.format(" Tile Size: %s", furniture.tileSize))
table.insert(output, string.format(" Collision Size: %s", furniture.collisionSize))
table.insert(output, string.format(" Rotation: %d", furniture.rotation))
table.insert(output, string.format(" Price: %d", furniture.price))
table.insert(output, string.format(" Placement Restriction: %d", furniture.placementRestriction))
table.insert(output, string.format(" Display Name: %s", furniture.displayName))
table.insert(output, string.format(" Sprite Index: %s", furniture.spriteIndex))
table.insert(output, string.format(" Sprite Sheet: %s", furniture.spriteSheet))
table.insert(output, string.format(" No Random Sale: %s", tostring(furniture.noRandomSale)))
table.insert(output, string.format(" Context Tags: %s", furniture.contextTags))
table.insert(output, "")
end
table.insert(output, "</pre>")
return table.concat(output, "\n")
end
return p