• 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 [TFS 1.3] Help with script logic

E

Evil Puncker

Guest
Hello, I'm breaking my head to get this to work but no success, currently I have tried the following:

Lua:
    local tile2 = Tile(toPosition)
    if tile2 and not tile2:hasFlag(TILESTATE_HOUSE) and item:getAttribute("wrapid") then
        self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return false
    end

What I need is, the script is a OnMoveItem event that needs to do the following:
  • if the moved item have the getAttribute("wrapid") it will only be possible to move to backpack or the character house floor
  • if you try to move it out of the house it should return 'not possible'

but right now my script prevents it to move anywhere, thanks in advance
 
Solution
Lua:
if fromPosition.x ~= CONTAINER_POSITION and toPosition.x ~= CONTAINER_POSITION then
    if not Tile(toPosition):getHouse() and item:getAttribute("wrapid") then
        self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return false
    end
end
Shouldn't use Cylinders to check this? I can't test atm.

Lua:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if fromCylinder:getTopParent():getId() == self:getId() then --moved from player inventory?
        --check if is not a house tile
    end
end
 
Back
Top