Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve: "/i" create a big count of stackable items #1863

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions data/scripts/talkactions/god/create_item.lua
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
local invalidIds = {
1,
2,
3,
4,
5,
6,
7,
10,
11,
13,
14,
15,
19,
21,
26,
27,
28,
35,
43,
}

local createItem = TalkAction("/i")

function createItem.onSay(player, words, param)
Expand All @@ -37,15 +15,25 @@ function createItem.onSay(player, words, param)
end
end

if table.contains(invalidIds, itemType:getId()) then
if itemType:getId() < 100 then
return true
end

local charges = itemType:getCharges()
local count = tonumber(split[2])
if count then
if itemType:isStackable() then
count = math.min(10000, math.max(1, count))
local item = Game.createItem(itemType:getId(), count)
if not item then
player:sendCancelMessage("Cannot create item")
return true
end

local ret = player:addItemEx(item, INDEX_WHEREEVER, FLAG_NOLIMIT)
if ret ~= RETURNVALUE_NOERROR then
player:sendCancelMessage(ret)
end
return true
elseif not itemType:isFluidContainer() then
local min = 100
if charges > 0 then
Expand Down