• 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 Script error

MorganaSacani

Active Member
Joined
Sep 20, 2022
Messages
87
Solutions
1
Reaction score
30
Can u help-me? I've problems with my rope script:
[2022-24-09 10:12:16.773] [error] Lua script error:
scriptInterface: [Scripts Interface]
scriptId: [C:\Users\Anderson Sacani\Documents\Tibia Project 1291 - 740\Server\TibiaOtServerProject\data\scripts\actions\tools\rope.lua:callback]
timerEvent: []
callbackId:[]
function: []
error [data/lib/compat/compat.lua:808: attempt to compare number with nil
stack traceback:
[C]: in function '__le'
data/lib/compat/compat.lua:808: in function 'doTeleportThing'
...TibiaOtServerProject\data\scripts\actions\tools\rope.lua:23: in function <...TibiaOtServerProject\data\scripts\actions\tools\rope.lua:9>]

Compat.lua:
Lua:
function doTeleportThing(uid, dest, pushMovement)
    if type(uid) == "userdata" then
        if uid:isCreature() then
            return uid:teleportTo(dest, pushMovement or false)
        else
            return uid:moveTo(dest)
        end
    else
        if uid >= 0x10000000 then
            local creature = Creature(uid)
            if creature then
                return creature:teleportTo(dest, pushMovement or false)
            end
        else
            local item = Item(uid)
            if item then
                return item:moveTo(dest)
            end
        end
    end
    return false
end

My rope script:
Lua:
local rope = Action()

local OPENED_HOLE = {294, 383, 469, 470, 482, 482, 485, 489, 430}
local OPENED_TRAP = {462}
local DOWN_LADDER = {369, 370, 408, 409, 427, 428, 3135, 3136, 5545, 5763}
local ROPE_SPOT = {386, 421}
local allowed_items_inway = {2016, 2017, 2018, 2019, 2020, 2021, 1903, 1904, 1905}

function rope.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    Spdlog.info("1")
    newPos = {x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 0}
    target = getThingfromPos(newPos)
    blockingItem = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 1})
    if(isInArray(ROPE_SPOT, target.itemid) == true) then
        Spdlog.info("2")
        newPos.y = newPos.y + 1
        newPos.z = newPos.z - 1
        if((blockingItem.itemid > 0 and not isInArray(allowed_items_inway, blockingItem.itemid)) or isCreature(target.uid)) then
            Spdlog.info("3")
            doPlayerSendCancel(cid, "Sorry, not possible.")
       else
            Spdlog.info("4")
           doTeleportThing(cid, newPos)
        end
    elseif(isInArray(OPENED_HOLE, target.itemid) == true or isInArray(OPENED_TRAP, target.itemid) == true or isInArray(DOWN_LADDER, target.itemid) == true) then
        Spdlog.info("5")
        newPos.y = newPos.y + 1
        downPos = {x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = 255}
        downItem = getThingfromPos(downPos)
        if(downItem.itemid > 0) then
            Spdlog.info("6")
            doTeleportThing(downItem.uid, newPos)
        else
            Spdlog.info("7")
            doPlayerSendCancel(cid, "Sorry, not possible.")
        end
    end
    return true
end

rope:id(3003, 646)
rope:register()
 
change
Lua:
function rope.onUse(player, item, fromPosition, target, toPosition, isHotkey)
to
Lua:
function rope.onUse(cid, item, fromPosition, target, toPosition, isHotkey)
 
Back
Top