• 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 items sacrificed on the coal

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
931
Solutions
7
Reaction score
127
Location
Brazil
YouTube
caruniawikibr
I'm trying to make the items on the altars be sacrificed, but it's very complicated, if anyone has a script like this or knows how to solve it.
i use tfs .15


1710355612341.png


Lua:
function onUse(cid, item, frompos, item2, topos)
    -- Definindo as posições iniciais dos altares no mapa
    local altar_positions = {
        {x = 33246, y = 31590, z = 11, altar_id = 1485},
        {x = 33253, y = 31588, z = 11, altar_id = 1486},
        {x = 33260, y = 31590, z = 11, altar_id = 1487},
        {x = 33259, y = 31601, z = 11, altar_id = 1488},
        {x = 33247, y = 31601, z = 11, altar_id = 1489}
    }
    
    -- Definindo as posições iniciais dos itens no mapa
    local item_positions = {
        {x = 33246, y = 31590, z = 11, itemid = 5702},
        {x = 33253, y = 31588, z = 11, itemid = 5703},
        {x = 33260, y = 31590, z = 11, itemid = 5700},
        {x = 33259, y = 31601, z = 11, itemid = 3699},
        {x = 33247, y = 31601, z = 11, itemid = 5701}
    }

    -- Verificar se existem 100 itens em cada altar
local todos_itens_presentes = true
for _, altar_info in ipairs(altar_positions) do
    local altar_items_count = 0
    for _, item_info in ipairs(item_positions) do
        local item_on_altar = getTileItemById({x = altar_info.x, y = altar_info.y, z = altar_info.z, itemid = item_info.itemid})
        altar_items_count = altar_items_count + #item_on_altar
    end
    print("Altar ID:", altar_info.altar_id, "Quantidade de Itens:", altar_items_count)
    if altar_items_count < 100 then
        todos_itens_presentes = false
        break
    end
end
    
    -- Se todos os itens estiverem presentes, realizar as ações
    if todos_itens_presentes then
        -- Remover os itens dos altares
        for _, altar_info in ipairs(altar_positions) do
            local altar_items = getTileItemById({x = altar_info.x, y = altar_info.y, z = altar_info.z, itemid = altar_info.altar_id})
            for _, item in ipairs(altar_items) do
                doRemoveItem(item.uid)
            end
        end
        
        -- Remover os itens de cima dos altares
        for _, item_info in ipairs(item_positions) do
            local item_on_altar = getTileItemById({x = item_info.x, y = item_info.y, z = item_info.z, itemid = item_info.itemid})
            for _, item in ipairs(item_on_altar) do
                doRemoveItem(item.uid)
            end
        end
        
        -- Alterar a alavanca
        doTransformItem(item.uid, 1945)
        
        -- Dar ao jogador o item desejado
        doPlayerAddItem(cid, 2646, 1)
        
        -- Informar ao jogador que a operação foi bem sucedida
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você realizou o ritual com sucesso!")
    else
        -- Informar ao jogador que a condição não foi atendida
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você precisa ter 100 itens em cada altar para realizar o ritual.")
    end
end
 
Solution
For anyone wanting the finished script, its here:
Lua:
local config = {
    altars = {
        {x = 32367, y = 32214, z = 7, itemid = 2145, itemcount = 100},
        {x = 32368, y = 32214, z = 7, itemid = 2146, itemcount = 100},
        {x = 32369, y = 32214, z = 7, itemid = 2147, itemcount = 100},
        {x = 32370, y = 32214, z = 7, itemid = 2149, itemcount = 100},
        {x = 32371, y = 32214, z = 7, itemid = 2150, itemcount = 100}
    },
    rewards = {
        {id = 2646, count = 1},
    }
}
    
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item:getId() == 1946 then
        item:transform(1945)
        return true
    end
 
    local altarItems = {}
    for _...
Untested but should work
Make sure you have an action id on your lever, and change it on line 53
Lua:
local altars = {
    {x = 33246, y = 31590, z = 11, itemid = 5702},
    {x = 33253, y = 31588, z = 11, itemid = 5703},
    {x = 33260, y = 31590, z = 11, itemid = 5700},
    {x = 33259, y = 31601, z = 11, itemid = 3699},
    {x = 33247, y = 31601, z = 11, itemid = 5701}
}
 
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    --turn back lever if already used
    if item:getId() == 1946 then
        item:transform(1945)
        return true
    end
 
    --get top item from each tile, check if it matches itemid in the altars tabke
    --store item if successful or transform lever return early if failed
    local altarItems = {}
    for _, altar in ipairs(altars) do
        local altarTile = Tile({x = altar.x, y = altar.y, z = altar.z})
        if altarTile then
            local altarItem = altarTile:getTopVisibleThing()
    
            if not altarItem
            or not altarItem:isItem()
            or altarItem:getId() ~= altar.itemid then
                item:transform(1946)
                return true
            end
    
            table.insert(altarItems, altarItem)
        end
    end
 
    --sacrifice items
    for _, altarItem in ipairs(altarItems) do
        altarItem:remove()
    end
 
    --[[
        this is the success part
        add whatever code you want here
    --]]
    print("success")
 
    --transform lever to used lever
    item:transform(1946)
    return true
end

action:aid(2550) -- set lever actionid here
action:register()
 
Last edited:
Untested but should work
Make sure you have an action id on your lever, and change it on line 53
Lua:
local altars = {
    {x = 33246, y = 31590, z = 11, itemid = 5702},
    {x = 33253, y = 31588, z = 11, itemid = 5703},
    {x = 33260, y = 31590, z = 11, itemid = 5700},
    {x = 33259, y = 31601, z = 11, itemid = 3699},
    {x = 33247, y = 31601, z = 11, itemid = 5701}
}
 
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    --turn back lever if already used
    if item:getId() == 1946 then
        item:transform(1945)
        return true
    end
 
    --get top item from each tile, check if it matches itemid in the altars tabke
    --store item if successful or transform lever return early if failed
    local altarItems = {}
    for _, altar in ipairs(altars) do
        local altarTile = Tile({x = altar.x, y = altar.y, z = altar.z})
        if altarTile then
            local altarItem = altarTile:getTopVisibleThing()
   
            if not altarItem
            or not altarItem:isItem()
            or altarItem:getId() ~= altar.itemid then
                item:transform(1946)
                return true
            end
   
            table.insert(altarItems, altarItem)
        end
    end
 
    --sacrifice items
    for _, altarItem in ipairs(altarItems) do
        altarItem:remove()
    end
 
    --[[
        this is the success part
        add whatever code you want here
    --]]
    print("success")
 
    --transform lever to used lever
    item:transform(1946)
    return true
end

action:aid(2550) -- set lever actionid here
action:register()
no work to me
Post automatically merged:

I managed to get it to remove the items, and win the item, but I only need it to remove it if it has 100 items of each, and the lever cannot be pulled if there are not 100 items of each on top of the positions.

Lua:
function onUse(cid, item, frompos, item2, topos)
    -- Definindo as posições iniciais dos itens no mapa
    local item_positions = {
        {x = 33246, y = 31590, z = 11, itemid = 5702},
        {x = 33253, y = 31588, z = 11, itemid = 5703},
        {x = 33260, y = 31590, z = 11, itemid = 5700},
        {x = 33259, y = 31601, z = 11, itemid = 5699},
        {x = 33247, y = 31601, z = 11, itemid = 5701}
    }

    local itemsRemoved = 100 -- Contador para o número de itens removidos

    -- Verifica se o item utilizado é a alavanca correta
    if item.itemid == 1946 then
        -- Verifica se há itens nas posições especificadas e se estão em cima das pedras de sacrifício
        for _, pos in ipairs(item_positions) do
            local tileItem = getTileItemById(pos, pos.itemid)
            if tileItem then
                -- Remove o item
                doRemoveItem(tileItem.uid)
                itemsRemoved = itemsRemoved + 1
            end
        end

        -- Se pelo menos um item foi removido, concede o item 2646 ao jogador
        if itemsRemoved > 100 then
            doPlayerAddItem(cid, 2646, 1)
        end

        -- Atualiza a alavanca para o próximo estado (1945)
        doTransformItem(item.uid, 1945)
        -- Define a função para reverter a alavanca após um minuto
        addEvent(function()
            doTransformItem(item.uid, 1946)
        end, 60 * 1000) -- 60 segundos * 1000 (para converter para milissegundos)
    end

    return true
end
 
no work to me
Post automatically merged:

I managed to get it to remove the items, and win the item, but I only need it to remove it if it has 100 items of each, and the lever cannot be pulled if there are not 100 items of each on top of the positions.

Lua:
function onUse(cid, item, frompos, item2, topos)
    -- Definindo as posições iniciais dos itens no mapa
    local item_positions = {
        {x = 33246, y = 31590, z = 11, itemid = 5702},
        {x = 33253, y = 31588, z = 11, itemid = 5703},
        {x = 33260, y = 31590, z = 11, itemid = 5700},
        {x = 33259, y = 31601, z = 11, itemid = 5699},
        {x = 33247, y = 31601, z = 11, itemid = 5701}
    }

    local itemsRemoved = 100 -- Contador para o número de itens removidos

    -- Verifica se o item utilizado é a alavanca correta
    if item.itemid == 1946 then
        -- Verifica se há itens nas posições especificadas e se estão em cima das pedras de sacrifício
        for _, pos in ipairs(item_positions) do
            local tileItem = getTileItemById(pos, pos.itemid)
            if tileItem then
                -- Remove o item
                doRemoveItem(tileItem.uid)
                itemsRemoved = itemsRemoved + 1
            end
        end

        -- Se pelo menos um item foi removido, concede o item 2646 ao jogador
        if itemsRemoved > 100 then
            doPlayerAddItem(cid, 2646, 1)
        end

        -- Atualiza a alavanca para o próximo estado (1945)
        doTransformItem(item.uid, 1945)
        -- Define a função para reverter a alavanca após um minuto
        addEvent(function()
            doTransformItem(item.uid, 1946)
        end, 60 * 1000) -- 60 segundos * 1000 (para converter para milissegundos)
    end

    return true
end
It's a revscript, so you need to place it in data/scripts/

And what exactly is meant to happen if all 5 items are removed?
 
no error appears, the lever is pulled and nothing happens


There are 100 items on each altar, there are 5 altars, when you pull the items they should disappear, if there are exactly 100 of each item on each altar. So if it doesn't, the lever can't be pulled.
 
I've just tested this and it works perfectly.....
So again, I will ask....once all the items are removed...what do you want to happen.................

Lua:
local altars = {
    {x = 32367, y = 32214, z = 7, itemid = 2145},
    {x = 32368, y = 32214, z = 7, itemid = 2146},
    {x = 32369, y = 32214, z = 7, itemid = 2147},
    {x = 32370, y = 32214, z = 7, itemid = 2149},
    {x = 32371, y = 32214, z = 7, itemid = 2150}
}
   
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    --turn back lever if already used
    if item:getId() == 1946 then
        item:transform(1945)
        return true
    end
   
    --get top item from each tile, check if it matches itemid in the altars tabke
    --store item if successful, break and set success to false if failed
    local altarItems = {}
    for _, altar in ipairs(altars) do
        local altarTile = Tile({x = altar.x, y = altar.y, z = altar.z})
        if altarTile then
            local altarItem = altarTile:getTopVisibleThing()
           
            if not altarItem
            or not altarItem:isItem()
            or altarItem:getId() ~= altar.itemid then
                item:transform(1946)
                return true
            end
           
            table.insert(altarItems, altarItem)
        end
    end
   
    --sacrifice items
    for _, altarItem in ipairs(altarItems) do
        altarItem:remove()
    end
   
    --this is the success part
    --add whatever code you want here if
   
    item:transform(1946)
    return true
end

action:aid(25634) -- set lever actionid here
action:register()
 
its identical to my previous script, but sure, as long as its working

the problem is that it is pulling any quantity, it needed it to be specifically 100 of each item that is at the top of the script.
change:
Lua:
altarItem:remove()
to
Lua:
altarItem:remove(1)
 
the lever can only be pulled if there are 100 of each item, in each location specified at the top of the script. if yes then player gets any item id.
there are 100 items of each, when I place 99 on one of the altars, then the script acts as if there were 100
 
the lever can only be pulled if there are 100 of each item, in each location specified at the top of the script. if yes then player gets any item id.
there are 100 items of each, when I place 99 on one of the altars, then the script acts as if there were 100
You can specify itemcount in the altars table, otherwise it will only remove 1 of the count

Lua:
local altars = {
    {x = 32367, y = 32214, z = 7, itemid = 2145},
    {x = 32368, y = 32214, z = 7, itemid = 2146},
    {x = 32369, y = 32214, z = 7, itemid = 2147, itemcount = 5},
    {x = 32370, y = 32214, z = 7, itemid = 2149},
    {x = 32371, y = 32214, z = 7, itemid = 2150}
}
  
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    --turn back lever if already used
    if item:getId() == 1946 then
        item:transform(1945)
        return true
    end
  
    --get top item from each tile, check if it matches itemid in the altars tabke
    --store item if successful, break and set success to false if failed
    local altarItems = {}
    for _, altar in ipairs(altars) do
        local altarTile = Tile({x = altar.x, y = altar.y, z = altar.z})
        if altarTile then
            local altarItem = altarTile:getTopVisibleThing()
          
            if not altarItem
            or not altarItem:isItem()
            or altarItem:getId() ~= altar.itemid
            or (altar.itemcount and altarItem:getCount() < altar.itemcount) then
                item:transform(1946)
                return true
            end
          
            table.insert(altarItems, altarItem)
        end
    end
  
    --sacrifice items
    for i, altarItem in ipairs(altarItems) do
        local count = altars[i].itemcount or 1
        altarItem:remove(count)
    end
  
    player:addItem(2646, 1)
  
    --transform lever to used lever
    item:transform(1946)
    return true
end

action:aid(25634) -- set lever actionid here
action:register()
 
You can specify itemcount in the altars table, otherwise it will only remove 1 of the count

Lua:
local altars = {
    {x = 32367, y = 32214, z = 7, itemid = 2145},
    {x = 32368, y = 32214, z = 7, itemid = 2146},
    {x = 32369, y = 32214, z = 7, itemid = 2147, itemcount = 5},
    {x = 32370, y = 32214, z = 7, itemid = 2149},
    {x = 32371, y = 32214, z = 7, itemid = 2150}
}
 
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    --turn back lever if already used
    if item:getId() == 1946 then
        item:transform(1945)
        return true
    end
 
    --get top item from each tile, check if it matches itemid in the altars tabke
    --store item if successful, break and set success to false if failed
    local altarItems = {}
    for _, altar in ipairs(altars) do
        local altarTile = Tile({x = altar.x, y = altar.y, z = altar.z})
        if altarTile then
            local altarItem = altarTile:getTopVisibleThing()
         
            if not altarItem
            or not altarItem:isItem()
            or altarItem:getId() ~= altar.itemid then
                item:transform(1946)
                return true
            end
         
            table.insert(altarItems, altarItem)
        end
    end
 
    --sacrifice items
    for i, altarItem in ipairs(altarItems) do
        local count = altars[i].itemcount or 1
        altarItem:remove(count)
    end
 
    player:addItem(2646, 1)
 
    --transform lever to used lever
    item:transform(1946)
    return true
end

action:aid(25634) -- set lever actionid here
action:register()

need to add
or altarItem:getCount() < 100 in your loop to confirm the stack is large enough.
 
There are 5 altars, with 100 items each, I just need to remove them and receive an item id 2540 for example. If you have 99 then you don't receive anything or remove anything. only if you have 100 in each.
 
ive re-edited my code, but its better because you can have different counts of different items...

So set each itemcount to 100...
 
try!
Lua:
local altars = {
    {x = 32367, y = 32214, z = 7, itemid = 2145, requiredCount = 100},
    {x = 32368, y = 32214, z = 7, itemid = 2146, requiredCount = 100},
    {x = 32369, y = 32214, z = 7, itemid = 2147, requiredCount = 100},
    {x = 32370, y = 32214, z = 7, itemid = 2149, requiredCount = 100},
    {x = 32371, y = 32214, z = 7, itemid = 2150, requiredCount = 100}
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    --turn back lever if already used
    if item:getId() == 1946 then
        item:transform(1945)
        return true
    end

    local allItemsCorrect = true
    for _, altar in ipairs(altars) do
        local altarTile = Tile({x = altar.x, y = altar.y, z = altar.z})
        if altarTile then
            local altarItem = altarTile:getTopVisibleThing()

            if not altarItem
            or not altarItem:isItem()
            or altarItem:getId() ~= altar.itemid
            or altarItem:getCount() < altar.requiredCount then
                allItemsCorrect = false
                break
            end
        else
            allItemsCorrect = false
            break
        end
    end

    if allItemsCorrect then
        for _, altar in ipairs(altars) do
            local altarTile = Tile({x = altar.x, y = altar.y, z = altar.z})
            local altarItem = altarTile:getTopVisibleThing()
            altarItem:remove(altar.requiredCount)
        end

        player:addItem(2540, 1) -- Reward item id 2540
    end

    --transform lever to used lever
    item:transform(1946)
    return true
end

action:aid(25634) -- set lever actionid here
action:register()
 
I did exactly but nothing happened
Lua:
local altars = {
        {x = 33246, y = 31590, z = 11, itemid = 5702, itemcount = 100},
        {x = 33253, y = 31588, z = 11, itemid = 5703, itemcount = 100},
        {x = 33260, y = 31590, z = 11, itemid = 5700, itemcount = 100},
        {x = 33259, y = 31601, z = 11, itemid = 5699, itemcount = 100},
        {x = 33247, y = 31601, z = 11, itemid = 5701, itemcount = 100}
}
 
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    --turn back lever if already used
    if item:getId() == 1946 then
        item:transform(1945)
        return true
    end
 
    --get top item from each tile, check if it matches itemid in the altars tabke
    --store item if successful, break and set success to false if failed
    local altarItems = {}
    for _, altar in ipairs(altars) do
        local altarTile = Tile({x = altar.x, y = altar.y, z = altar.z})
        if altarTile then
            local altarItem = altarTile:getTopVisibleThing()
          
            if not altarItem
            or not altarItem:isItem()
            or altarItem:getId() ~= altar.itemid
            or (altar.itemcount and altarItem:getCount() < altar.itemcount) then
                item:transform(1946)
                return true
            end
          
            table.insert(altarItems, altarItem)
        end
    end
 
    --sacrifice items
    for i, altarItem in ipairs(altarItems) do
        local count = altars[i].itemcount or 1
        altarItem:remove(count)
    end
 
    player:addItem(2646, 1)
 
    --transform lever to used lever
    item:transform(1946)
    return true
end

action:aid(17000) -- set lever actionid here
action:register()
Post automatically merged:

try!
Lua:
local altars = {
    {x = 32367, y = 32214, z = 7, itemid = 2145, requiredCount = 100},
    {x = 32368, y = 32214, z = 7, itemid = 2146, requiredCount = 100},
    {x = 32369, y = 32214, z = 7, itemid = 2147, requiredCount = 100},
    {x = 32370, y = 32214, z = 7, itemid = 2149, requiredCount = 100},
    {x = 32371, y = 32214, z = 7, itemid = 2150, requiredCount = 100}
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    --turn back lever if already used
    if item:getId() == 1946 then
        item:transform(1945)
        return true
    end

    local allItemsCorrect = true
    for _, altar in ipairs(altars) do
        local altarTile = Tile({x = altar.x, y = altar.y, z = altar.z})
        if altarTile then
            local altarItem = altarTile:getTopVisibleThing()

            if not altarItem
            or not altarItem:isItem()
            or altarItem:getId() ~= altar.itemid
            or altarItem:getCount() < altar.requiredCount then
                allItemsCorrect = false
                break
            end
        else
            allItemsCorrect = false
            break
        end
    end

    if allItemsCorrect then
        for _, altar in ipairs(altars) do
            local altarTile = Tile({x = altar.x, y = altar.y, z = altar.z})
            local altarItem = altarTile:getTopVisibleThing()
            altarItem:remove(altar.requiredCount)
        end

        player:addItem(2540, 1) -- Reward item id 2540
    end

    --transform lever to used lever
    item:transform(1946)
    return true
end

action:aid(25634) -- set lever actionid here
action:register()
Lua Script Error: [Scripts Interface]
C:\Users\holer\Desktop\Carunia - Copia\data\scripts\actions\demonlegs.lua:callback
...sktop\Carunia - Copia\data\scripts\actions\demonlegs.lua:27: attempt to compare number with nil
stack traceback:
[C]: in function '__lt'
...sktop\Carunia - Copia\data\scripts\actions\demonlegs.lua:27: in function <...sktop\Carunia - Copia\data\scripts\actions\demonlegs.lua:11>
 
I did exactly but nothing happened
Lua:
local altars = {
        {x = 33246, y = 31590, z = 11, itemid = 5702, itemcount = 100},
        {x = 33253, y = 31588, z = 11, itemid = 5703, itemcount = 100},
        {x = 33260, y = 31590, z = 11, itemid = 5700, itemcount = 100},
        {x = 33259, y = 31601, z = 11, itemid = 5699, itemcount = 100},
        {x = 33247, y = 31601, z = 11, itemid = 5701, itemcount = 100}
}
 
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    --turn back lever if already used
    if item:getId() == 1946 then
        item:transform(1945)
        return true
    end
 
    --get top item from each tile, check if it matches itemid in the altars tabke
    --store item if successful, break and set success to false if failed
    local altarItems = {}
    for _, altar in ipairs(altars) do
        local altarTile = Tile({x = altar.x, y = altar.y, z = altar.z})
        if altarTile then
            local altarItem = altarTile:getTopVisibleThing()
        
            if not altarItem
            or not altarItem:isItem()
            or altarItem:getId() ~= altar.itemid
            or (altar.itemcount and altarItem:getCount() < altar.itemcount) then
                item:transform(1946)
                return true
            end
        
            table.insert(altarItems, altarItem)
        end
    end
 
    --sacrifice items
    for i, altarItem in ipairs(altarItems) do
        local count = altars[i].itemcount or 1
        altarItem:remove(count)
    end
 
    player:addItem(2646, 1)
 
    --transform lever to used lever
    item:transform(1946)
    return true
end

action:aid(17000) -- set lever actionid here
action:register()
Post automatically merged:


Lua Script Error: [Scripts Interface]
C:\Users\holer\Desktop\Carunia - Copia\data\scripts\actions\demonlegs.lua:callback
...sktop\Carunia - Copia\data\scripts\actions\demonlegs.lua:27: attempt to compare number with nil
stack traceback:
[C]: in function '__lt'
...sktop\Carunia - Copia\data\scripts\actions\demonlegs.lua:27: in function <...sktop\Carunia - Copia\data\scripts\actions\demonlegs.lua:11>
I just tested it and it worked fine....

player:addItem(2646, 1)
Is this what you wanted added if its successful?
 
For anyone wanting the finished script, its here:
Lua:
local config = {
    altars = {
        {x = 32367, y = 32214, z = 7, itemid = 2145, itemcount = 100},
        {x = 32368, y = 32214, z = 7, itemid = 2146, itemcount = 100},
        {x = 32369, y = 32214, z = 7, itemid = 2147, itemcount = 100},
        {x = 32370, y = 32214, z = 7, itemid = 2149, itemcount = 100},
        {x = 32371, y = 32214, z = 7, itemid = 2150, itemcount = 100}
    },
    rewards = {
        {id = 2646, count = 1},
    }
}
    
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item:getId() == 1946 then
        item:transform(1945)
        return true
    end
 
    local altarItems = {}
    for _, altar in ipairs(config.altars) do
        local altarTile = Tile({x = altar.x, y = altar.y, z = altar.z})
        if altarTile then
            local altarItem = altarTile:getTopVisibleThing()
          
            if not altarItem
            or not altarItem:isItem()
            or altarItem:getId() ~= altar.itemid
            or (altar.itemcount and altarItem:getCount() < altar.itemcount) then
                item:transform(1946)
                return true
            end
          
            table.insert(altarItems, altarItem)
        end
    end
 
    for i, altarItem in ipairs(altarItems) do
        local count = config.altars[i].itemcount or 1
        altarItem:remove(count)
    end
    
    local inbox = player:getInbox()
    for _, reward in ipairs(config.rewards) do
        if not player:addItem(reward.id, reward.count) and inbox then
            inbox:addItem(reward.id, reward.count)
        end
    end
 
    item:transform(1946)
    return true
end

action:aid(25634) -- set lever actionid here
action:register()
 
Solution
Back
Top