Untitled - MARKUP 1.09 KB
                                
                                    local itemsOnTile
 
function getItemsOnTile()
    for _, tile in ipairs(g_map.getTiles(posz())) do
        if distanceFromPlayer(tile:getPosition()) < 1 then
            itemsOnTile = tile:getItems()
        end
    end
 
    for i, item in ipairs(itemsOnTile) do
        schedule(100 + i * 50, function()
            openContainer(item)
        end)
    end
end
 
function openContainer(container)
    if not container:isContainer() then return end
    g_game.use(container)
end
 
onKeyPress(function(keys)
    if keys == "Up" then
        schedule(100, getItemsOnTile)
    end
 
    if keys == "Down" then
        schedule(100, getItemsOnTile)
    end
 
    if keys == "Left" then
        schedule(100, getItemsOnTile)
    end
 
    if keys == "Right" then
        schedule(100, getItemsOnTile)
    end
end)
 
onContainerOpen(function(container, previousContainer)
    local items = container:getItems()
 
    for i, item in ipairs(items) do
        if item then g_game.use(item) end
    end
end)
                                
                            

Paste Hosted With By Wklejamy.pl