Skip to content

Commit

Permalink
Update create-item.lua
Browse files Browse the repository at this point in the history
Refactored code, tested, works, etc.
  • Loading branch information
Tjudge1 authored Sep 3, 2024
1 parent 9f3d27b commit fe1809f
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions modtools/create-item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -335,27 +335,18 @@ function hackWish(accessors, opts)
until count
end
if not mattype or not itemtype then return end
if not typesThatUseCreaturesExceptCorpses[df.item_type[itemtype]] and df.item_type.attrs[itemtype].is_stackable then
return createItem({mattype, matindex}, {itemtype, itemsubtype}, quality, unit, description, count)
end
if typesThatUseCreaturesExceptCorpses[df.item_type[itemtype]] and df.item_type.attrs[itemtype].is_stackable then
return createItem({matindex, casteId}, {itemtype, itemsubtype}, quality, unit, description, count)
if df.item_type.attrs[itemtype].is_stackable then
local mat = typesThatUseCreaturesExceptCorpses[df.item_type[itemtype]] and {matindex, casteId} or {mattype, matindex}
return createItem(mat, {itemtype, itemsubtype}, quality, unit, description, count)
end
local items = {}
for _ = 1,count do
if itemtype == df.item_type.CORPSEPIECE or itemtype == df.item_type.CORPSE then
table.insert(items, createCorpsePiece(unit, bodypart, partlayerID, matindex, casteId, corpsepieceGeneric))
else
if typesThatUseCreaturesExceptCorpses[df.item_type[itemtype]] then
for
_,item in ipairs(createItem({matindex, casteId}, {itemtype, itemsubtype}, quality, unit, description, 1)) do
table.insert(items, item)
end
else
for
_,item in ipairs(createItem({mattype, matindex}, {itemtype, itemsubtype}, quality, unit, description, 1)) do
table.insert(items, item)
end
local mat = typesThatUseCreaturesExceptCorpses[df.item_type[itemtype]] and {matindex, casteId} or {mattype, matindex}
for _,item in ipairs(createItem(mat, {itemtype, itemsubtype}, quality, unit, description, 1)) do
table.insert(items, item)
end
end
end
Expand Down

0 comments on commit fe1809f

Please sign in to comment.