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

Hole id 7932 not working

Raikou

Well-Known Member
Joined
Jul 18, 2007
Messages
145
Solutions
2
Reaction score
54
So i`m trying to make use of this hole, but it doesnt want to open (use shovel and transform to 7933).
These are my server settings:
Items:
XML:
    <item id="7932" article="a" name="large hole"/>
    <item id="7933" article="a" name="large hole">
        <attribute key="floorchange" value="down" />
        <attribute key="decayTo" value="7932" />
        <attribute key="duration" value="600" />
    </item>

Actions:
XML:
    <action itemid="2554" script="tools/shovel.lua" />

Shovel:
Lua:
local holes = {468, 481, 483, 7932}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local tile = Tile(toPosition)
    if not tile then
        return false
    end

    local ground = tile:getGround()
    if not ground then
        return false
    end

    local groundId = ground:getId()
    if table.contains(holes, groundId) then
        ground:transform(groundId + 1)
        ground:decay()

        toPosition.z = toPosition.z + 1
        tile:relocateTo(toPosition)
    elseif groundId == 231 then
        local randomValue = math.random(1, 100)
        if randomValue == 1 then
            Game.createItem(2159, 1, toPosition)
        elseif randomValue > 95 then
            Game.createMonster("Scarab", toPosition)
        end
        toPosition:sendMagicEffect(CONST_ME_POFF)
    else
        return false
    end

    return true
end
 
Solution
Lua:
local holes = {468, 481, 483, 7932}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target then
        if table.contains(holes, target.itemid) then
            target:transform(target.itemid + 1)
            target:decay()
        elseif target.itemid == 231 then
            local rand = math.random(1, 100)
            if rand == 1 then
                Game.createItem(2159, 1, toPosition)
            elseif rand > 95 then
                Game.createMonster("Scarab", toPosition)
            end
            toPosition:sendMagicEffect(CONST_ME_POFF)
        else
            return false
        end
    else
        return false
    end
    return true
end
Lua:
local holes = {468, 481, 483, 7932}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target then
        if table.contains(holes, target.itemid) then
            target:transform(target.itemid + 1)
            target:decay()
        elseif target.itemid == 231 then
            local rand = math.random(1, 100)
            if rand == 1 then
                Game.createItem(2159, 1, toPosition)
            elseif rand > 95 then
                Game.createMonster("Scarab", toPosition)
            end
            toPosition:sendMagicEffect(CONST_ME_POFF)
        else
            return false
        end
    else
        return false
    end
    return true
end
 
Last edited:
Solution
Lua:
local holes = {468, 481, 483, 7932}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target then
        if table.contains(holes, target.itemid) then
            target:transform(target.itemid + 1)
            target:decay()
           
            toPosition.z = toPosition.z + 1
            tile:relocateTo(toPosition)
        elseif target.itemid == 231 then
            local rand = math.random(1, 100)
            if rand == 1 then
                Game.createItem(2159, 1, toPosition)
            elseif rand > 95 then
                Game.createMonster("Scarab", toPosition)
            end
            toPosition:sendMagicEffect(CONST_ME_POFF)
        else
            return false
        end
    else
        return false
    end
    return true
end
That's it, it worked out well, thank you!
Post automatically merged:

Lua:
local holes = {468, 481, 483, 7932}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target then
        if table.contains(holes, target.itemid) then
            target:transform(target.itemid + 1)
            target:decay()
           
            toPosition.z = toPosition.z + 1
            tile:relocateTo(toPosition)
        elseif target.itemid == 231 then
            local rand = math.random(1, 100)
            if rand == 1 then
                Game.createItem(2159, 1, toPosition)
            elseif rand > 95 then
                Game.createMonster("Scarab", toPosition)
            end
            toPosition:sendMagicEffect(CONST_ME_POFF)
        else
            return false
        end
    else
        return false
    end
    return true
end

Oh it does give a console error:

Lua Script Error: [Action Interface]
data/actions/scripts/tools/shovel.lua:eek:nUse
data/actions/scripts/tools/shovel.lua:9: attempt to index global 'tile' (a nil value)
stack traceback:
[C]: in function '__index'
data/actions/scripts/tools/shovel.lua:9: in function <data/actions/scripts/tools/shovel.lua:2>

Lua:
toPosition.z = toPosition.z + 1

I removed that line and it works okay.
 
Last edited:
Back
Top