• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua for not Work...

milbradt

New Member
Joined
Dec 25, 2011
Messages
177
Solutions
1
Reaction score
4
Code:
CONFIG = {
[1272] = {x = 82, y = 173, z = 7},
[1111] = {x = 82, y = 175, z = 7},
[1111] = {x = 82, y = 174, z = 7},
[1111] = {x = 82, y = 172, z = 7},
}
for itemid, offset in pairs(CONFIG) do
    local item = getTileItemById(offset, itemid)
    if item.uid > 0 then
     doRemoveItem(item.uid)
    end
end
 
was not it.
they said that the index is repeated ...
Code:
[1111] = {x = 82, y = 175, z = 7},
[1111] = {x = 82, y = 174, z = 7},
[1111] = {x = 82, y = 172, z = 7},
You know how to fix the config?
 
New idea,
post your tfs,
what the script is intended to do,
any errors you receive, when using the script, or when you load the script from your console.

That'll make a good starting place to work from. :P
 
As samco said, an array can only have one index, but in that index you can more arrays.
The correct way to do this would be like this;
Code:
local config = {
    [1272] = {x = 82, y = 173, z = 7},
    [1111] = {
        {x = 82, y = 175, z = 7},
        {x = 82, y = 174, z = 7},
        {x = 82, y = 172, z = 7}
    }
}

for itemid, positions in pairs(config) do
    if type(positions) == "array" then
        for i = 1, #positions do
            local item = getTileItemById(positions[i], itemid)
            if isItem(item.uid) then
                doRemoveItem(item.uid)
            end
        end
    else
        local item = getTileItemById(positions, itemid)
        if isItem(item.uid) then
            doRemoveItem(item.uid)
        end
    end
end

You can now iterate through the array and find all the positions, aswell as only use one position like with item 1272.
 
Back
Top