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

Who i can add more X and Y here

felipe carvalho

New Member
Joined
Mar 13, 2020
Messages
27
Reaction score
0
Lua:
local flowerPosition = {
    Position(32326, 32059, 10),
    Position(32315, 32064, 10)
}

local function bloom()
        
    local item = Tile(flowerPosition):getItemById(9421)
    if item then
        item:transform(18229)
        flowerPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
    end

    addEvent(bloom,60 * 60)

end
function onStartup()
    bloom()
    return true
end

i need to put more positions but when i put one more there is a bug in the console
1584863369550.png
 
Solution
You are turning flower position into an array of positions.

Tile expects a position. You are feeding it the entire array.

I would rename flowerPosition to flowerPositions so that the plural word acts as a reminder to you.

Usage would be something like
Lua:
    Tile(flowerPositions[i])

See the [i]? The array[member] notation is how you access members of the array.

I think what you are trying to do is iterate over the members of the array of positions to check for these stones you keep talking about in other threads? You're going to want to use a for loop.
Lua:
local function list_iter (t)
    local i =...
You are turning flower position into an array of positions.

Tile expects a position. You are feeding it the entire array.

I would rename flowerPosition to flowerPositions so that the plural word acts as a reminder to you.

Usage would be something like
Lua:
    Tile(flowerPositions[i])

See the [i]? The array[member] notation is how you access members of the array.

I think what you are trying to do is iterate over the members of the array of positions to check for these stones you keep talking about in other threads? You're going to want to use a for loop.
Lua:
local function list_iter (t)
    local i = 0
    local n = table.getn(t)
    return function ()
        i = i + 1
        if i <= n then return t[i] end
    end
end

local stonePositions = {
    Position(32326, 32059, 10),
    Position(32315, 32064, 10)
}

local function checkTile(position)
    local stone = Tile(position):getItemById(9421)
    if stone then
        stone:transform(18229)
        position:sendMagicEffect(CONST_ME_MAGIC_RED)
    end
end

local function findStoneTiles()
    for position in list_iter(stonePositions) do
        checkTile(position)
    end

    addEvent(findStoneTiles, 60 * 60)
end

function onStartup()
    findStoneTiles()
    return true
end


Citations:
Programming in Lua : 11.1 (https://www.lua.org/pil/11.1.html)
Programming in Lua : 7.1 (https://www.lua.org/pil/7.1.html)
 
Solution
Back
Top