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

Evilor

Member
Joined
Oct 17, 2016
Messages
39
Reaction score
10
Hello, can someone please help me with this bug?

data/actions/scripts/tools/shovel.lua:47: attempt to get length of global 'POOLS' (a nil value)
stack traceback:
data/actions/scripts/tools/shovel.lua:47: in function <data/actions/scripts/tools/shovel.lua:21>
 
Hello, can someone please help me with this bug?

data/actions/scripts/tools/shovel.lua:47: attempt to get length of global 'POOLS' (a nil value)
stack traceback:
data/actions/scripts/tools/shovel.lua:47: in function <data/actions/scripts/tools/shovel.lua:21>
post the code?
lol
 
post the code?
lol
Was on my phone, this is the code.
Code:
local TILE_SAND = 231
local ITEM_SCARAB_COIN = 2159
local TUMB_ENTRANCE = 25001
local SCARAB_TILE = 25002
local SAND_HOLE = 489
local duration = 5*60000 -- 5 minutes

local function __doTransformHole__(parameters)
    local thing = getTileItemById(parameters.pos, SAND_HOLE)
    local newItem = doTransformItem(thing.uid, parameters.oldType)
    if parameters.oldaid ~= 0 and newItem then
        doSetItemActionId(thing.uid, parameters.oldaid)
    end  
end

local function __resetTile__(parameters)
    local thing = getTileItemById(parameters.pos, TILE_SAND)
    doSetItemActionId(thing.uid, SCARAB_TILE)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (isInArray(CLOSED_HOLE, itemEx.itemid) ) then
        doTransformItem(itemEx.uid, itemEx.itemid + 1)
    elseif (itemEx.itemid == TILE_SAND) then
        if (itemEx.actionid == TUMB_ENTRANCE) then
            if (math.random(1, 5) == 1) then
                doTransformItem(itemEx.uid, SAND_HOLE)
                addEvent(__doTransformHole__, duration, {oldType = itemEx.itemid, pos = toPosition, oldaid = itemEx.actionid})
                if itemEx.actionid ~= 0 then
                    doSetItemActionId(itemEx.uid, itemEx.actionid)
                end
            end
        elseif (itemEx.actionid == SCARAB_TILE) then
            addEvent(__resetTile__, 30*60000, {pos = toPosition})
            doSetItemActionId(itemEx.uid, 101)
            if (math.random(1, 20) == 1) then
                doCreateItem(ITEM_SCARAB_COIN, toPosition)
            else
                doSummonCreature("Scarab", toPosition)
            end
        end
        doSendMagicEffect(toPosition, CONST_ME_POFF)
    else
        return false
    end

    for i = 1, #POOLS do
        local pool = getTileItemById(toPosition, POOLS[i]).uid
        if pool > 0 then
            doRemoveItem(pool,1)
        end
    end

    doDecayItem(itemEx.uid)
    return true
end
This is the bugged part
Code:
    for i = 1, #POOLS do
        local pool = getTileItemById(toPosition, POOLS[i]).uid
        if pool > 0 then
            doRemoveItem(pool,1)
        end
    end
 
The problem itself wouldn't be fixed with what @Znote wrote. The error explicitly says that the global variable "POOLS"' is nil, which would mean that this variable is not declared (most likely at least or accessing something you didn't intend or other). This is where your problem is derived from, not "pool" that's why you should use clear, concise and concrete variable names to increase and mantain good readability in your code
 
Last edited:
why would a shovel remove splashes/water, you don't even need that loop in the code
where did you get this from?
you should look for the POOLS table (if you got it from somewhere) if you insist on having that loop
6SIOxwf.png
 
Back
Top