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

Error on globalevent script

neptuno

Active Member
Joined
Jan 5, 2012
Messages
84
Solutions
1
Reaction score
30
Hi, I have an issue that is driving me crazy. It's with this script:
Lua:
local config = {
    teleportId = 1387,
    dias = {
        ["Saturday"] = {Position(33649, 31261, 11), Position(33647, 31254, 11)}, -- tanjis

        ["Friday"] = {Position(33558, 31282, 11), Position(33545, 31263, 11)}, -- jaul


        ["Sunday"] = {Position(33438, 31248, 11), Position(33419, 31255, 11)}, -- obujos
    }
}

function onStartup(interval)
    local i = config.dias[os.date("%A")]
    doCreateTeleport(config.teleportId, i[2], i[1])
end

The error console sends is:

Code:
Lua Script Error: [GlobalEvent Interface] 

data/globalevents/scripts/gray island/grayIslandBosses.lua:onStartup

data/lib/compat/compat.lua:998: attempt to index local 'item' (a nil value)

stack traceback:

    [C]: in function '__index'

    data/lib/compat/compat.lua:998: in function 'doCreateTeleport'

    data/globalevents/scripts/gray island/grayIslandBosses.lua:17: in function <data/globalevents/scripts/gray island/grayIslandBosses.lua:15>

And the fragment of compat.lua that defines doCreateTeleport is
Lua:
function doCreateTeleport(itemId, destination, position)
    local item = Game.createItem(itemId, 1, position)
    if not item:isTeleport() then
        item:remove()
        return false
    end
    item:setDestination(destination)
    return item:getUniqueId()
end

I'm using OTX latest version compiled by myself.
 
are you sure your create position is correct?
item will be nil if the position is incorrect
 
Solution
Back
Top