• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Moveto: free sloot inventory

Engradiel

Member
Joined
May 3, 2009
Messages
120
Reaction score
7
Location
Brazil
Hello guys. I want to know if is possible use this function item:moveTo({x=0, y=0, z=0}) to move a item to a free slot in inventory.

I tried some things but now work.

I use items habilities so to change this item hability I need to remove it from inventory changed the habilities and back to same place.

It is possible?
 
Solution
Not by default, the source code would require some tweaks

However you can achieve the same thing by cloning the item
Lua:
local sourceItem = item
local cloneItem = sourceItem:clone()

if cloneItem then

    -- your code here --
    cloneItem:setCustomAttribute(...)
    cloneItem:removeCustomAttribute(...)

    if sourceItem:remove() then
        -- # drops to the floor in case something went wrong, so we dont need to check the return value
        player:addItemEx(cloneItem, true, SLOT_POSITION)
    end

end
When you clone an item, you also clone all its attributes.
Not by default, the source code would require some tweaks

However you can achieve the same thing by cloning the item
Lua:
local sourceItem = item
local cloneItem = sourceItem:clone()

if cloneItem then

    -- your code here --
    cloneItem:setCustomAttribute(...)
    cloneItem:removeCustomAttribute(...)

    if sourceItem:remove() then
        -- # drops to the floor in case something went wrong, so we dont need to check the return value
        player:addItemEx(cloneItem, true, SLOT_POSITION)
    end

end
When you clone an item, you also clone all its attributes.
 
Solution
Back
Top