E
Evil Puncker
Guest
Hi everyone, I want to make a PR once again to TFS with this and I don't know how to make the item generate 7 itens from the reward table, any help is appreciated:
Lua:
local presents = {
[6507] = { -- red christmas bundle
{6569, 15}, {2687, 20}, {2688, 10}, {2675, 10}, {2674, 5}, 6501, 6502, 6490, 6504, 6388
},
[6508] = { -- blue christmas bundle
{6569, 15}, {2687, 20}, {2688, 10}, {2675, 10}, {2674, 5}, 6501, 6502, 6490, 6505, 6388
},
[6509] = { -- green christmas bundle
{6569, 15}, {2687, 20}, {2688, 10}, {2675, 10}, {2674, 5}, 6501, 6502, 6490, 6503, 6388
}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local count = 1
local targetItem = presents[item.itemid]
if not targetItem then
return true
end
local gift = targetItem[math.random(#targetItem)]
if type(gift) == "table" then
gift = gift[1]
count = gift[2]
end
player:addItem(gift, count)
item:remove(1)
fromPosition:sendMagicEffect(CONST_ME_GIFT_WRAPS)
return true
end