Skip to content

Commit

Permalink
Merge pull request #1289 from Tjudge1/create-item
Browse files Browse the repository at this point in the history
modtools/create-item
  • Loading branch information
myk002 authored Sep 3, 2024
2 parents ec7cf97 + 1629829 commit 9d05127
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Template for new versions:
## New Features

## Fixes
- `gui/create-item`: fix items of type "VERMIN", "PET", "REMANS", "FISH", "RAW FISH", and "EGG" no longer spawn creature item "nothing."
Items will now spawn correctly, and will be of the creature type and creature caste that selected by the user. Items of these types will also stack correctly when needed.
- `modtools/create-item`: fix items of type "VERMIN", "PET", "REMANS", "FISH", "RAW FISH", and "EGG" no longer spawn creature item "nothing"s.
Items will now spawn correctly, and will be of the creature type and creature caste that selected by the user. Items of these types will also stack correctly when needed.

## Misc Improvements

Expand Down
15 changes: 13 additions & 2 deletions modtools/create-item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ local no_quality_item_types = utils.invert{
'BRANCH',
}

local typesThatUseCreaturesExceptCorpses = utils.invert {
'REMAINS',
'FISH',
'FISH_RAW',
'VERMIN',
'PET',
'EGG',
}

local CORPSE_PIECES = utils.invert{'BONE', 'SKIN', 'CARTILAGE', 'TOOTH', 'NERVE', 'NAIL', 'HORN', 'HOOF', 'CHITIN',
'SHELL', 'IVORY', 'SCALE'}
local HAIR_PIECES = utils.invert{'HAIR', 'EYEBROW', 'EYELASH', 'MOUSTACHE', 'CHIN_WHISKERS', 'SIDEBURNS'}
Expand Down Expand Up @@ -327,14 +336,16 @@ function hackWish(accessors, opts)
end
if not mattype or not itemtype then return end
if df.item_type.attrs[itemtype].is_stackable then
return createItem({mattype, matindex}, {itemtype, itemsubtype}, quality, unit, description, count)
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
for _,item in ipairs(createItem({mattype, matindex}, {itemtype, itemsubtype}, quality, unit, description, 1)) do
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
Expand Down

0 comments on commit 9d05127

Please sign in to comment.