• 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 Scripts Error Tile Transform

adrenyslopez

Member
Joined
Dec 22, 2015
Messages
201
Reaction score
15
Hello, someone help me, I am trying to do this scripts but I have this error when the vortexes appear, erase the floor, I want it not to erase the floor and appear above the crystal


HElpç.png

Lua:
local function createVortex()
    local positions1 = {
        {x = 33749, y = 31661, z = 14},
        {x = 33743, y = 31662, z = 14},
    }

    local positions2 = {
        {x = 33747, y = 31666, z = 14},
        {x = 33739, y = 31666, z = 14},
    }

    local positions3 = {
        {x = 33751, y = 31663, z = 14},
        {x = 33754, y = 31665, z = 14},
    }

    local positions4 = {
        {x = 33751, y = 31670, z = 14},
        {x = 33745, y = 31671, z = 14},
    }
    local tempo = 10
    if vortexPositions == 0 then
        for i = 1, #positions1 do
            local items = Tile(Position(positions1[i])):getGround()
            items:transform(37249)
            addEvent(function()
            items:transform(14938)
            end, tempo*1000)
        end
        vortexPositions = 1
    elseif vortexPositions == 1 then
        for i = 1, #positions2 do
            local items = Tile(Position(positions2[i])):getGround()
            items:transform(37249)
            addEvent(function()
            items:transform(14938)
            end, tempo*1000)
        end
        vortexPositions = 2
    elseif vortexPositions == 2 then
        for i = 1, #positions3 do
            local items = Tile(Position(positions3[i])):getGround()
            items:transform(37249)
            addEvent(function()
            items:transform(14938)
            end, tempo*1000)
        end
        vortexPositions = 3
    elseif vortexPositions == 3 then
        for i = 1, #positions4 do
            local items = Tile(Position(positions4[i])):getGround()
            items:transform(37249)
            addEvent(function()
            items:transform(14938)
            end, tempo*1000)
        end
        vortexPositions = 0
    end
    greedTransform = false
    areagreed2 = addEvent(createVortex, tempo*1000)
end
 
Solution
I already put in 1

Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/actions/quests/soulwar/greed_lever.lua:callback
...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:23: attempt to index global 'positions1' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:23: in function 'createVortex'
        ...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:70: in function <...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:53>
ah oops.
change
Lua:
local tile = Tile(Position(positions1[n][i]))
to
Lua:
local tile = Tile(Position(positions[n][i]))
create the item on the tile instead of transforming the ground tile.
Game.createItem(itemId, 1, Position(positions1[i]))

If you want some examples to look at, check out this script I made previously.
 
create the item on the tile instead of transforming the ground tile.
Game.createItem(itemId, 1, Position(positions1[i]))

If you want some examples to look at, check out this script I made previously.
would I have to add it like this? sorry i'm just learning
Lua:
    if vortexPositions == 0 then
        for i = 1, #positions1 do
            local items = Game.createItem(itemId, 1, Position(positions1[i]))
            createItem(37249)
            addEvent(function()
            createItem(14938)
            end, tempo*1000)
        end
 
would I have to add it like this? sorry i'm just learning
Lua:
    if vortexPositions == 0 then
        for i = 1, #positions1 do
            local items = Game.createItem(itemId, 1, Position(positions1[i]))
            createItem(37249)
            addEvent(function()
            createItem(14938)
            end, tempo*1000)
        end
I'm just assuming both of these items go above the tile as an object, btw.
If they aren't both an object, you'll need to explain how the script is supposed to work.
Lua:
    if vortexPositions == 0 then
        for i = 1, #positions1 do
            Game.createItem(37249, 1, Position(positions1[i]))
            addEvent(function()
                Game.createItem(14938, 1, Position(positions1[i]))
            end, tempo*1000)
        end
 
I'm just assuming both of these items go above the tile as an object, btw.
If they aren't both an object, you'll need to explain how the script is supposed to work.
Lua:
    if vortexPositions == 0 then
        for i = 1, #positions1 do
            Game.createItem(37249, 1, Position(positions1[i]))
            addEvent(function()
                Game.createItem(14938, 1, Position(positions1[i]))
            end, tempo*1000)
        end
Now they only appear and are not removed or change position
NOREMOVE.png

Lua:
local function createVortex()
    local positions1 = {
        {x = 33749, y = 31661, z = 14},
        {x = 33743, y = 31662, z = 14},
    }

    local positions2 = {
        {x = 33747, y = 31666, z = 14},
        {x = 33739, y = 31666, z = 14},
    }

    local positions3 = {
        {x = 33751, y = 31663, z = 14},
        {x = 33754, y = 31665, z = 14},
    }

    local positions4 = {
        {x = 33751, y = 31670, z = 14},
        {x = 33745, y = 31671, z = 14},
    }
    local tempo = 10
    if vortexPositions == 0 then
        for i = 1, #positions1 do
            Game.createItem(37249, 1, Position(positions1[i]))
            addEvent(function()
                Game.createItem(17868, 1, Position(positions1[i]))
            end, tempo*1000)
        end
        vortexPositions = 1
    elseif vortexPositions == 1 then
        for i = 1, #positions1 do
            Game.createItem(37249, 1, Position(positions2[i]))
            addEvent(function()
                Game.createItem(17868, 1, Position(positions2[i]))
            end, tempo*1000)
        end
        vortexPositions = 2
    elseif vortexPositions == 2 then
        for i = 1, #positions1 do
            Game.createItem(37249, 1, Position(positions3[i]))
            addEvent(function()
                Game.createItem(17868, 1, Position(positions3[i]))
            end, tempo*1000)
        end
        vortexPositions = 3
    elseif vortexPositions == 3 then
        for i = 1, #positions1 do
            Game.createItem(37249, 1, Position(positions4[i]))
            addEvent(function()
                Game.createItem(17868, 1, Position(positions4[i]))
            end, tempo*1000)
        end
        vortexPositions = 0
    end
    greedTransform = false
    areagreed2 = addEvent(createVortex, tempo*1000)
end
 
Now they only appear and are not removed or change position
View attachment 58251

Lua:
local function createVortex()
    local positions1 = {
        {x = 33749, y = 31661, z = 14},
        {x = 33743, y = 31662, z = 14},
    }

    local positions2 = {
        {x = 33747, y = 31666, z = 14},
        {x = 33739, y = 31666, z = 14},
    }

    local positions3 = {
        {x = 33751, y = 31663, z = 14},
        {x = 33754, y = 31665, z = 14},
    }

    local positions4 = {
        {x = 33751, y = 31670, z = 14},
        {x = 33745, y = 31671, z = 14},
    }
    local tempo = 10
    if vortexPositions == 0 then
        for i = 1, #positions1 do
            Game.createItem(37249, 1, Position(positions1[i]))
            addEvent(function()
                Game.createItem(17868, 1, Position(positions1[i]))
            end, tempo*1000)
        end
        vortexPositions = 1
    elseif vortexPositions == 1 then
        for i = 1, #positions1 do
            Game.createItem(37249, 1, Position(positions2[i]))
            addEvent(function()
                Game.createItem(17868, 1, Position(positions2[i]))
            end, tempo*1000)
        end
        vortexPositions = 2
    elseif vortexPositions == 2 then
        for i = 1, #positions1 do
            Game.createItem(37249, 1, Position(positions3[i]))
            addEvent(function()
                Game.createItem(17868, 1, Position(positions3[i]))
            end, tempo*1000)
        end
        vortexPositions = 3
    elseif vortexPositions == 3 then
        for i = 1, #positions1 do
            Game.createItem(37249, 1, Position(positions4[i]))
            addEvent(function()
                Game.createItem(17868, 1, Position(positions4[i]))
            end, tempo*1000)
        end
        vortexPositions = 0
    end
    greedTransform = false
    areagreed2 = addEvent(createVortex, tempo*1000)
end
Explain how you want your script to work.

I'm not a mind reader. xD
All I did was fix your initial issue.

Also, those crystals are notorious.
They basically go on top of any and all objects, due to how the sprite was created, so I doubt your vortex will go above them.
 
Explain how you want your script to work.

I'm not a mind reader. xD
All I did was fix your initial issue.

Also, those crystals are notorious.
They basically go on top of any and all objects, due to how the sprite was created, so I doubt your vortex will go above them.
This is how the scripts work, but the crystal must go below the vortex, or simply that there is crystalline but when the vortex appears it is removed and then it appears again


something like the vortex and crystals

 
Last edited:
Lua:
You see a large crystal teleporter.
Item ID: 17868
Client ID: 15320
make sure vortexPositions is never 0. make it 1, 2, 3 or 4
Lua:
local function createVortex()
    local positions = {
        {
            {x = 33749, y = 31661, z = 14},
            {x = 33743, y = 31662, z = 14},
        },
        {
            {x = 33747, y = 31666, z = 14},
            {x = 33739, y = 31666, z = 14},
        },
        {
            {x = 33751, y = 31663, z = 14},
            {x = 33754, y = 31665, z = 14},
        },
        {
            {x = 33751, y = 31670, z = 14},
            {x = 33745, y = 31671, z = 14},
        }
    }
    local tempo = 10
    local n = vortexPositions
    for i = 1, #positions[n] do
        local tile = Tile(Position(positions1[n][i]))
        local crystal = tile:getItemById(17868)
        if crystal then
            crystal:transform(37249)
        end
        addEvent(function()
            local vortex = tile:getItemById(37249)
            if vortex then
                vortex:transform(17868)
            end
        end, tempo * 1000)
    end
    n = n + 1
    vortexPositions = n > 4 and 1 or n
    greedTransform = false
    areagreed2 = addEvent(createVortex, tempo * 1000)
end
 
make sure vortexPositions is never 0. make it 1, 2, 3 or 4
Lua:
local function createVortex()
    local positions = {
        {
            {x = 33749, y = 31661, z = 14},
            {x = 33743, y = 31662, z = 14},
        },
        {
            {x = 33747, y = 31666, z = 14},
            {x = 33739, y = 31666, z = 14},
        },
        {
            {x = 33751, y = 31663, z = 14},
            {x = 33754, y = 31665, z = 14},
        },
        {
            {x = 33751, y = 31670, z = 14},
            {x = 33745, y = 31671, z = 14},
        }
    }
    local tempo = 10
    local n = vortexPositions
    for i = 1, #positions[n] do
        local tile = Tile(Position(positions1[n][i]))
        local crystal = tile:getItemById(17868)
        if crystal then
            crystal:transform(37249)
        end
        addEvent(function()
            local vortex = tile:getItemById(37249)
            if vortex then
                vortex:transform(17868)
            end
        end, tempo * 1000)
    end
    n = n + 1
    vortexPositions = n > 4 and 1 or n
    greedTransform = false
    areagreed2 = addEvent(createVortex, tempo * 1000)
end
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/actions/quests/soulwar/greed_lever.lua:callback
...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:22: attempt to get length of a nil value
stack traceback:
        [C]: in function '__len'
        ...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:22: in function 'createVortex'
        ...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:70: in function <...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:53>

this is my complete scripts
Code:
local function createVortex()
    local positions = {
        {
            {x = 33749, y = 31661, z = 14},
            {x = 33743, y = 31662, z = 14},
        },
        {
            {x = 33747, y = 31666, z = 14},
            {x = 33739, y = 31666, z = 14},
        },
        {
            {x = 33751, y = 31663, z = 14},
            {x = 33754, y = 31665, z = 14},
        },
        {
            {x = 33751, y = 31670, z = 14},
            {x = 33745, y = 31671, z = 14},
        }
    }
    local tempo = 10
    local n = vortexPositions
    for i = 1, #positions[n] do
        local tile = Tile(Position(positions1[n][i]))
        local crystal = tile:getItemById(17868)
        if crystal then
            crystal:transform(37249)
        end
        addEvent(function()
            local vortex = tile:getItemById(37249)
            if vortex then
                vortex:transform(17868)
            end
        end, tempo * 1000)
    end
    n = n + 1
    vortexPositions = n > 4 and 1 or n
    greedTransform = false
    areagreed2 = addEvent(createVortex, tempo * 1000)
end
 
Last edited:
Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/actions/quests/soulwar/greed_lever.lua:callback
...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:22: attempt to get length of a nil value
stack traceback:
        [C]: in function '__len'
        ...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:22: in function 'createVortex'
        ...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:70: in function <...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:53>
make sure vortexPositions is never 0. make it 1, 2, 3 or 4
 
vortexPositions = 1
I already put in 1

Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/actions/quests/soulwar/greed_lever.lua:callback
...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:23: attempt to index global 'positions1' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:23: in function 'createVortex'
        ...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:70: in function <...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:53>
 
I already put in 1

Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/actions/quests/soulwar/greed_lever.lua:callback
...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:23: attempt to index global 'positions1' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:23: in function 'createVortex'
        ...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:70: in function <...rver/data/scripts/actions/quests/soulwar/greed_lever.lua:53>
ah oops.
change
Lua:
local tile = Tile(Position(positions1[n][i]))
to
Lua:
local tile = Tile(Position(positions[n][i]))
 
Solution
Back
Top