Joe Rod
Discord: joerod1
based on this request
This would be good in case you have to do something like obsidian knife where you want to add a new item to the player depending where the knife is located, so if the knife is on container it would be added to that container, else it will be given to the player to another container. If the obsidian knife is used on the floor is added to that position
This would be good in case you have to do something like obsidian knife where you want to add a new item to the player depending where the knife is located, so if the knife is on container it would be added to that container, else it will be given to the player to another container. If the obsidian knife is used on the floor is added to that position
Code:
function Player:addItemFromUsedItemContainer(item, fromPos, addItemId, amount) --lol name
if (not item or not item:isItem()) then return false end
if (not ItemType(addItemId)) then return false end
if (fromPos.x == CONTAINER_POSITION) then --check if is from container
if (not item:getParent():addItem(addItemId, amount)) then --check if could be added to that container where the item is located
self:addItem(addItemId, amount) --add to player if couldn't be added to that container
end
else
Game.createItem(addItemId, amount, fromPos) --item is on the ground, is created there
end
end