简体   繁体   English

尝试调用全局“ getDirectionTo” <a nil value>堆栈回溯</a>

[英]attempt to call global 'getDirectionTo' <a nil value> stack traceback

What is wrong here? 怎么了

attempt to call global 'getDirectionTo' <a nil value> stack traceback: gateofexp_closed.lua:43: in gateofexp_closed.lua:5

gateofexp_closed.lua gateofexp_closed.lua

function onUse(cid, item, frompos, item2, topos)
local isLevelDoor = (item.actionid >= 1001 and item.actionid <= 1999)
local isVocationDoor = (item.actionid >= 2001 and item.actionid <= 2008)

if not(isLevelDoor or isVocationDoor) then
    -- Make it a normal door
    doTransformItem(item.uid, item.itemid+1)
    return true
end

local canEnter = true
if(isLevelDoor and getPlayerLevel(cid) < (item.actionid-1000)) then
    canEnter = false
end

if(isVocationDoor) then
    local doorVoc = item.actionid-2000
    if (doorVoc == 1 and not(isSorcerer(cid))) or
       (doorVoc == 2 and not(isDruid(cid)))   or
       (doorVoc == 3 and not(isPaladin(cid))) or
       (doorVoc == 4 and not(isKnight(cid)))  or
       (doorVoc ~= getPlayerVocation(cid))     then
        canEnter = false
    end
end

if(not canEnter and getPlayerAccess(cid) == 0) then
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
    return true
end


doTransformItem(item.uid, item.itemid+1)
local canGo = (queryTileAddThing(cid, frompos, bit.bor(2, 4)) == RETURNVALUE_NOERROR) --Veryfies if the player can go, ignoring blocking things
if not(canGo) then
    return false
end

local dir = getDirectionTo(getPlayerPosition(cid), frompos)
doMoveCreature(cid, dir)
return true
end

getDirectionTo is not defined when that code is run. 运行该代码时未定义getDirectionTo This is what the message means. 这就是消息的含义。 I don't know why this happens, of course. 我当然不知道为什么会这样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM