欢迎大家来到沙石镇时光中文维基!本站编辑权限开放,欢迎加入中文维基 QQ 群「沙海时光」:372816689
目前正在进行全站数据更新,期间可能会存在显示异常的问题。
全站通知:
模块:NpcProtoData
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:NpcProtoData/doc创建
local Helper = require("Module:Helper")
local AssetNpcProtoDatas = Helper.LazyLoad("Module:AssetNpcProtoDatas")
local AssetItemChinese = Helper.LoadAsset("Module:AssetItemChinese")
local AssetActorProtos = Helper.LazyLoad("Module:AssetActorProtos")
local AssetBubbleChoiceInfos = Helper.LazyLoad("Module:AssetBubbleChoiceInfos")
local AssetNpcHasMission = Helper.LazyLoad("Module:AssetNpcHasMission")
local AssetSceneConfigs = Helper.LazyLoad("Module:AssetSceneConfigs")
-- APIs Part --
local p = {}
p.season = function(frame)
local seasons = {"春", "夏", "秋", "冬"}
local birthday = p.birthday(frame)
if (birthday) then
return seasons[tonumber(birthday:sub(1, 2))]
end
end
p.birthday = function(frame)
local name = frame.args[1]
local TicksPerDay = 24 * 60 * 60 * 1000 * 10000
for npcProtoDataId, npcProtoData in pairs(AssetNpcProtoDatas) do
local text = getText(npcProtoData.nameID)
if (text and string.lower(name) == string.lower(text) and npcProtoData.birthday) then
local date = npcProtoData.birthday.dateData / TicksPerDay
local day = date % 28 + 1
local month = math.floor((date % (28 * 4)) / 28 + 1)
return month .. "." .. day
end
end
return nil
end
p.gender = function(frame)
local name = frame.args[1]
for npcProtoDataId, npcProtoData in pairs(AssetNpcProtoDatas) do
local text = getText(npcProtoData.nameID)
if (text and string.lower(name) == string.lower(text)) then
result = AssetActorProtos[npcProtoData.templetID].gender
if result == "Female" then
return "女"
elseif result == "Male" then
return "男"
end
return AssetActorProtos[npcProtoData.templetID].gender
end
end
return nil
end
p.height = function(frame)
local name = frame.args[1]
for npcProtoDataId, npcProtoData in pairs(AssetNpcProtoDatas) do
local text = getText(npcProtoData.nameID)
if (text and string.lower(name) == string.lower(text)) then
return npcProtoData.height
end
end
return nil
end
p.summary = function(frame)
local name = frame.args[1]
for npcProtoDataId, npcProtoData in pairs(AssetNpcProtoDatas) do
local text = getText(npcProtoData.nameID)
if (text and string.lower(name) == string.lower(text)) then
return getText(npcProtoData.backgrounds[1].transId)
end
end
return nil
end
p.id = function(frame)
local name = frame.args[1]
for npcProtoDataId, npcProtoData in pairs(AssetNpcProtoDatas) do
local text = getText(npcProtoData.nameID)
if (text and string.lower(name) == string.lower(text)) then
return npcProtoData.id
end
end
return "未知"
end
p.templateID = function(frame)
local name = frame.args[1]
for npcProtoDataId, npcProtoData in pairs(AssetNpcProtoDatas) do
local text = getText(npcProtoData.nameID)
if (text and string.lower(name) == string.lower(text)) then
return npcProtoData.templetID
end
end
return "未知"
end
p.caption = function(frame)
local name = frame.args[1]
for npcProtoDataId, npcProtoData in pairs(AssetNpcProtoDatas) do
local text = getText(npcProtoData.nameID)
if (text and string.lower(name) == string.lower(text)) then
return getText(npcProtoData.identityID)
end
end
return nil
end
p.weight = function(frame)
local name = frame.args[1]
for npcProtoDataId, npcProtoData in pairs(AssetNpcProtoDatas) do
local text = getText(npcProtoData.nameID)
if (text and string.lower(name) == string.lower(text)) then
return npcProtoData.weight
end
end
return nil
end
p.social = function(frame)
local name = frame.args[1]
for npcProtoDataId, npcProtoData in pairs(AssetNpcProtoDatas) do
local text = getText(npcProtoData.nameID)
if (text and string.lower(name) == string.lower(text)) then
if (npcProtoData.interactChoice) then
local result = ""
for _, interactChoice in pairs(npcProtoData.interactChoice) do
local choiceInfo = AssetBubbleChoiceInfos[interactChoice + 1]
local choiceName
-- CancelPlay = 9, CancelDate = 10
if (interactChoice ~= 9 and interactChoice ~= 10 and type(choiceInfo) == "table") then
choiceName = getText(choiceInfo.translationId) or choiceInfo.choiceType
-- mw.log(choiceName)
end
if (choiceName) then
result = result .. choiceName .. ","
end
end
result = string.sub(result, 0, #result - 1)
return Helper.ExpandTemplate("social list", {
[1] = result
})
end
end
end
return nil
end
p.mission = function(frame)
local name = frame.args[1]
for npcProtoDataId, npcProtoData in pairs(AssetNpcProtoDatas) do
local text = getText(npcProtoData.nameID)
if (text and string.lower(name) == string.lower(text)) then
if (AssetNpcHasMission[npcProtoDataId]) then
return AssetNpcHasMission[npcProtoDataId]
end
end
end
return nil
end
p.home = function(frame)
local name = frame.args[1]
for npcProtoDataId, npcProtoData in pairs(AssetNpcProtoDatas) do
local text = getText(npcProtoData.nameID)
if (text and string.lower(name) == string.lower(text)) then
return "[[" .. getText(AssetSceneConfigs[npcProtoData.homeScene - 1].nameId) .. "]]"
end
end
return nil
end
-- Helper Part --
function string.starts(String, Start)
return string.sub(String, 1, string.len(Start)) == Start
end
function getText(id)
if (AssetItemChinese[id]) then
return AssetItemChinese[id]
end
return nil
end
p.debug = function()
Helper.ExpandTemplate = Helper.ExpandTemplateDebug
local args = {
[1] = "欧文"
}
local frame = {
args = args
}
local result = p.home(frame)
mw.log(result)
end
return p

沪公网安备 31011002002714 号