• 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!

Solved Globalevent: attempt to call global

swevaman

New Member
Joined
Jun 18, 2013
Messages
38
Reaction score
0
Well basically here is the screenshot of the error
O1QToQH.png


and here is the script:

Code:
function onThink(interval)

local Pos = Position
if not Position then
    Pos = function (x, y, z)
        local position = {x = 0, y = 0, z = 0}
        if(tonumber(x .. y .. z) ~= nil) then
            position = {x = x, y = y, z = z}
        end
        return position
    end
end
end
                        
function modify_pos(old, new)
    return Pos(new.x and old.x+new.x or old.x, new.y and old.y+new.y or old.y, new.z and old.z+new.z or old.z)
end


local SPEED = 300         --fastest = 1, slowest = 1000
local PLATFORM = 420     --itemid of platform
local FLOOR = 460         --invisible tile
local path = 
    {
        [NORTH] = {y = -1},
        [EAST] = {x = 1},
        [SOUTH] = {y = 1},
        [WEST] = {x = -1}
    }


function getPosition(position, lastPosition)
    for direction, mod in pairs(path) do
        local pos = modify_pos(position, mod)
        if (getTileItemById(pos, FLOOR).uid > 0) and not doComparePositions(pos, lastPosition) then
            return pos
        end
    end
    return lastPosition
end

function doPlatform(position, lastPosition)
    local posEx = getPosition(position, lastPosition)
    doTransformItem(getTileItemById(posEx, FLOOR).uid, PLATFORM)
    doCleanTile(position)
    for i = 1, getTileInfo(position).things do
        position.stackpos = getTileInfo(position).things-i
        local cid = getThingFromPos(position).uid
        if isCreature(cid) then
            doTeleportThing(cid, posEx, false)
        end
    end
    doTransformItem(getTileItemById(position, PLATFORM).uid, FLOOR)
    return addEvent(doPlatform, SPEED, posEx, position)
end


function onStartup()
    doPlatform(Pos(2115, 2061, 6), Pos(2115, 2062, 6))
    return true
end


I just need to know what this means.
 
It means the server is not recognizing 'pos' as a local key available in your script. If it cannot find 'pos' as a local key, it attempts to find it as a global key. If that also fails, the server will print that error.

If you want me to help you with it, feel free to tell me.

*EDIT-1*: And by the way, this error can occur in any type of script, not just globalevents. So don't get confused by it.
 
Remove function onThink(interval) and this end.
Code:
local Pos = Position
if not Position then
    Pos = function (x, y, z)
        local position = {x = 0, y = 0, z = 0}
        if(tonumber(x .. y .. z) ~= nil) then
            position = {x = x, y = y, z = z}
        end
        return position
    end
end
[COLOR="#FF0000"]end[/COLOR]
The reason for this error is because it's now local for function onThink, so a nil value in an other function.
 
Back
Top