Skip to content

Commit

Permalink
Merge branch 'main' into feature/tournament-coins-custom
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel authored Nov 24, 2023
2 parents 2fe9415 + 4a25372 commit da2539c
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions data/scripts/talkactions/god/create_item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,22 @@ function createItem.onSay(player, words, param)
local count = tonumber(split[2])
if count then
if itemType:isStackable() then
local item = Game.createItem(itemType:getId(), count)
if not item then
player:sendCancelMessage("Cannot create item")
return true
end
local stackSize = itemType:getStackSize()
local container = Game.createItem(2854)
local remainingCount = count

local ret = player:addItemEx(item, INDEX_WHEREEVER, FLAG_NOLIMIT)
if ret ~= RETURNVALUE_NOERROR then
player:sendCancelMessage(ret)
while remainingCount > 0 do
local countToAdd = math.min(remainingCount, stackSize)
local tmpItem = container:addItem(itemType:getId(), countToAdd, INDEX_WHEREEVER, FLAG_NOLIMIT)
if tmpItem then
remainingCount = remainingCount - countToAdd
else
logger.warn("Failed to add item: {}, to container", itemType:getName())
end
end

player:addItemEx(container)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
return true
elseif not itemType:isFluidContainer() then
local min = 100
Expand Down

0 comments on commit da2539c

Please sign in to comment.