work in progress
Lua bindings to the d2itemreader library
Returns the type of the file at filepath, or nil, err if the filetype cannot be determined. If the filetype can be determined, it will be returned as one of the following strings: "character", "item", "atma", "personal", "shared"
Returns an array-like table of items, or nil, err if there was an error reading the file. See Item Format for the format of each item.
Returns an iterator for all items in the file. Items in the file are parsed while iterating, and are returned in item, source pairs. See Item Format for the format of each item. Example usage:
foritem, sourceind2itemreader.itemiterator('char.d2s') doprint(item.code..' in ' ..source.file)
endLoad custom Diablo II .txt data files from disk at the filepaths given. filepaths should be a table of the format:
{
armors=<string>, -- path to Armor.txtweapons=<string>, -- path to Weapons.txtmiscs=<string>, -- path to Misc.txtitemstats=<string>, -- path to ItemStatCost.txt
}Load custom Diablo II .txt data files from memory with the contents given. databufs should be a table of the format:
{
armors=<string>, -- contents of Armor.txtweapons=<string>, -- contents of Weapons.txtmiscs=<string>, -- contents of Misc.txtitemstats=<string>, -- contents of ItemStatCost.txt
}-- Item
{
source= {
-- filepath containing the itemfile=<string>,
-- section only exists for filetype "character",-- will be one of "character", "corpse", "merc"section=<string>,
-- page only exists for paginated filetypes-- ("personal" or "shared")page=<number>
},
identified=<boolean>,
socketed=<boolean>,
isNew=<boolean>,
isEar=<boolean>,
startItem=<boolean>,
simpleItem=<boolean>,
ethereal=<boolean>,
personalized=<boolean>,
isRuneword=<boolean>,
version=<number>,
locationID=<number>,
equippedID=<number>,
positionX=<number>,
positionY=<number>,
panelID=<number>,
-- only exists if isEar is trueear= {
classID=<number>,
level=<number>,
name=<string>
},
code=<string>,
socketedItems= {...} -- array-like table of items-- every key below only exists if simpleItem is falseid=<string>, -- unique ID of the item in hexadecimallevel=<number>,
-- rarity is one of:-- "unique", "set", "normal", "lowquality"-- "superior", "magic", "crafted", "rare"rarity=<string>,
-- rarityData is different depending on rarity, and-- doesn't exist for "normal" rarityrarityData= {
-- for "unique", "set", "lowquality", "superior" raritiesid=<number>,
-- for "magic" rarityprefix=<number>,
suffix=<number>,
-- for "rare" or "crafted" raritiesname1=<number>,
name2=<number>,
prefixes= {...}, -- array-like table of prefix IDs (numbers)suffixes= {...} -- array-like table of suffix IDs (numbers)
},
multiplePictures=<boolean>,
pictureID=<number>,
classSpecific=<boolean>,
automagicID=<number>,
-- only exists if personalized is truepersonalizedName=<string>,
timestamp=<boolean>,
defenseRating=<number>,
maxDurability=<number>,
currentDurability=<number>,
quantity=<number>,
numSockets=<number>,
magicProperties= {...}, -- array-like table of magic properties (see 'Magic Property' below)setBonuses= {...}, -- see 'Set Bonuses' belowrunewordProperties= {...} -- array-like table of magic properties (see 'Magic Property' below)
}
-- Magic Property
{
id=<number>,
params= {...} -- array-like table of parameter values (numbers)
}
-- Set Bonuses---- A table with keys 1-5 where each key may have a nil value. This means that it is-- not guaranteed to be an array-like table (so ipairs and the # operator will not-- always work, use `for i=1,5 do` to iterate instead)---- Note: These are the green per-item set bonuses, not the overall set bonuses
{
-- Each non-nil value is an array-like table of magic properties (see 'Magic Property' above)
[1] = {...} ornil,
[2] = {...} ornil,
[3] = {...} ornil,
[4] = {...} ornil,
[5] = {...} ornil,
-- When the bonuses are active depends on the value of add_func in SetItems.txt-- for the setID of the item:---- If add_func=2, then it uses the number of items of the set that are worn:-- - The property list at key 1 is active when >= 2 items of the set are worn.-- - The property list at key 2 is active when >= 3 items of the set are worn.-- - etc.---- If add_func=1, then specific other items of the set need to be worn:-- - If the item's setID is the first of the set:-- + then the property list at key 1 is active when the second setID of the set is worn-- + and the property list at key 2 is active when the third setID of the set is worn-- + etc.-- - If the item's setID is the second of the set:-- + then the property list at key 1 is active when the first setID of the set is worn-- + and the property list at key 2 is active when the third setID of the set is worn-- + etc.-- - etc.
}