• 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 rope doesn't pull creature

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
931
Solutions
7
Reaction score
127
Location
Brazil
YouTube
caruniawikibr
I don't know why, my rope doesn't pull creatures up tfs 1.5


Lua:
local holeId = {
    294, 369, 370, 383, 392, 408, 409, 410, 427, 428, 429, 430, 462, 469, 470, 482,
    484, 485, 489, 924, 1369, 3135, 3136, 4835, 4837
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local tile = Tile(toPosition)
    if not tile then
        return false
    end

    if table.contains(ropeSpots, tile:getGround():getId()) or tile:getItemById(94435) then
        if Tile(toPosition:moveUpstairs()):hasFlag(TILESTATE_PROTECTIONZONE) and player:isPzLocked() then
            player:sendCancelMessage(RETURNVALUE_PLAYERISPZLOCKED)
            return true
        end
        player:teleportTo(toPosition, false)
        return true
    elseif table.contains(holeId, target.itemid) then
        toPosition.z = toPosition.z + 1
        tile = Tile(toPosition)
        if tile then
            local thing = tile:getTopVisibleThing()
            if thing:isPlayer() then
                if Tile(toPosition:moveUpstairs()):hasFlag(TILESTATE_PROTECTIONZONE) and thing:isPzLocked() then
                    return false
                end
                return thing:teleportTo(toPosition, false)
            end
            if thing:isItem() and thing:getType():isMovable() then
                return thing:moveTo(toPosition:moveUpstairs())
            end
        end
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return true
    end
    return false
end
 

Attachments

Here is mine that works on my 1.5 server. I think it uses some Nostalrius methods though test it.

Lua:
local holeSpots = {
    294, 369, 370, 383, 392, 408, 409, 410, 427, 428, 429, 430, 462, 469, 470, 482,
    484, 485, 489, 924, 3135, 3136, 4835, 4837
}

function onUse(player, item, fromPosition, target, toPosition)
    local tile = Tile(toPosition)
    if not tile then
        return false
    end
    
    if not tile:getGround() then
        return false
    end
    
    if table.contains(ropeSpots, tile:getGround():getId()) then
        player:teleportTo(target:getPosition():moveRel(0, 1, -1))
        return true
    elseif table.contains(holeSpots, tile:getGround():getId()) or target:getId() == 435 then
        local tile = Tile(target:getPosition():moveRel(0, 0, 1))
        if not tile then
            return false
        end
        
        local thing = tile:getTopCreature()
        if not thing then
            thing = tile:getTopVisibleThing()
        end
        
        if thing:isCreature() then
            thing:teleportTo(target:getPosition():moveRel(0, 1, 0), false)
            return true
        end
        if thing:isItem() and thing:getType():isMovable() then
            thing:moveTo(target:getPosition():moveRel(0, 1, 0))
            return true
        end
        return true
    end
    return false
end
 
Add after line 31:
Lua:
            elseif thing:isCreature() then
                return thing:teleportTo(toPosition:moveUpstairs())
 
Solution
Back
Top