Instantly share code, notes, and snippets.

@cydh /itemInfo.lua
Last active Apr 26, 2018

Embed
What would you like to do?
Edited itemInfo.lua to supports multi itemInfo files. Guide: https://pservero.com/multi-iteminfo-files-with-costume-slots-name-fixes-from-item_db/
main = function()
iiFiles = {
"System/itemInfo_Translation.lua", -- 1st priority
"System/itemInfo_kRO.lua", -- 2nd
"System/itemInfo_idRO.lua", -- 3rd
"System/itemInfo_iRO.lua", -- 4th
"System/itemInfo_misc.lua", -- 5th
"System/itemInfo_ItemDB.lua", -- Fixes!
}
_TempItems = {}
-- check existing item
function CheckItem(ItemID, DESC, flag)
if not (DESC.costume) then
DESC.costume = false
end
if not (_TempItems[ItemID]) then
_TempItems[ItemID] = DESC
else
myTbl = {}
-- remap
for pos,val in pairs(_TempItems[ItemID]) do
myTbl[pos] = val
end
-- add data if not exists yet
for pos,val in pairs(DESC) do
if not (myTbl[pos]) or myTbl[pos] == "" then
myTbl[pos] = val
end
end
-- use ClassNum from this itemInfo to fix attack sprite animation
if flag == true and DESC.ClassNum then
if not (_TempItems[ItemID].ClassNum) or _TempItems[ItemID].ClassNum == 0 then
myTbl["ClassNum"] = DESC.ClassNum
end
end
_TempItems[ItemID] = myTbl
end
end
-- end check
-- Set some fixes
function setDESC(ItemID,DESC)
if _TempItems[ItemID] then
if DESC.costume then
_TempItems[ItemID].costume = DESC.costume
end
if DESC.slotCount then
_TempItems[ItemID].slotCount = DESC.slotCount
end
if DESC.identifiedDisplayName then
_TempItems[ItemID].identifiedDisplayName = DESC.identifiedDisplayName
end
end
end
-- Set some fixes
-- Read all files
for i,iiFile in pairs(iiFiles) do
d = dofile(iiFile)
end
-- Read all files
-- process _TempItems
for ItemID,DESC in pairs(_TempItems) do
result, msg = AddItem(ItemID, DESC.unidentifiedDisplayName, DESC.unidentifiedResourceName, DESC.identifiedDisplayName, DESC.identifiedResourceName, DESC.slotCount, DESC.ClassNum, DESC.costume)
if not result then
return false, msg
end
for k,v in pairs(DESC.unidentifiedDescriptionName) do
result, msg = AddItemUnidentifiedDesc(ItemID, v)
if not result then
return false, msg
end
end
for k,v in pairs(DESC.identifiedDescriptionName) do
result, msg = AddItemIdentifiedDesc(ItemID, v)
if not result then
return false, msg
end
end
end
-- process _TempItems
_TempItems = nil
return true, "good"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment