• 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 Please help with action script

Eldora

Banned User
Joined
Oct 19, 2009
Messages
604
Reaction score
26
Need to add this function:

Lua:
function onUseShovel(player, item, fromPosition, target, toPosition, isHotkey)
    local targetId, targetActionId = target.itemid, target.actionid
    if isInArray(holes, targetId) then
        target:transform(targetId + 1)
        target:decay()

    elseif isInArray({231, 9059}, targetId) then
        local rand = math.random(100)
        if target.actionid == 100 and rand <= 20 then
            target:transform(489)
            target:decay()
        elseif rand == 1 then
            Game.createItem(2159, 1, toPosition)
        elseif rand > 95 then
            Game.createMonster("Scarab", toPosition)
        end
        toPosition:sendMagicEffect(CONST_ME_POFF)

into this action script:

Lua:
local holes = {468, 481, 483, 7932}
local holeId = {294, 369, 370, 383, 392, 408, 409, 427, 428, 430, 462, 469, 470, 482, 484, 485, 489, 924, 3135, 3136}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local groundTile = getThingfromPos(toPosition)
    if isInArray(holes, itemEx.itemid) == TRUE then
        doTransformItem(itemEx.uid, itemEx.itemid + 1)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 2739 then
        doTransformItem(itemEx.uid, 2737)
        doCreateItem(2694, 1, toPosition)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 2782 then
        doTransformItem(itemEx.uid, 2781)
        doDecayItem(itemEx.uid)
    elseif itemEx.itemid == 1499 then
        doRemoveItem(itemEx.uid)
    elseif (itemEx.uid <= 65535 or itemEx.actionid > 0) and (itemEx.itemid == 355 or itemEx.itemid == 9025) then
        doTransformItem(itemEx.uid, 392)
        doDecayItem(itemEx.uid)
    elseif itemEx.uid == 60001 then
        doTeleportThing(cid, {x=329, y=772, z=10})
        doSendMagicEffect({x=329, y=772, z=10},10)
    elseif groundTile.itemid == 384 or groundTile.itemid == 418 or groundTile.itemid == 8278 then
        doTeleportThing(cid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z - 1}, FALSE)
    elseif isInArray(holeId, itemEx.itemid) == TRUE then
        toPosition.z = toPosition.z + 1
        tile = Tile(toPosition)
        if tile then
            local thing = tile:getTopVisibleThing()
            if thing:isPlayer() or thing:isMonster() then
                if Tile(toPosition:moveUpstairs()):hasFlag(TILESTATE_PROTECTIONZONE) and thing:isPzLocked() then
                    return false
                end
                return thing:teleportTo(toPosition, false)
            end
            if thing:isItem() and thing:getType():isMovable() then
                return thing:moveTo(toPosition:moveUpstairs())
            end
        end

        doPlayerSendCancel(cid, "Sorry, not possible.")
        return true

        end
    return TRUE
end
 
Lua:
local holes = {468, 481, 483, 7932}
local holeId = {294, 369, 370, 383, 392, 408, 409, 427, 428, 430, 462, 469, 470, 482, 484, 485, 489, 924, 3135, 3136}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local groundTile = getThingfromPos(toPosition)

    if isInArray(holes, target.itemid) then
        target:transform(target.itemid + 1)
        target:decay()
    elseif isInArray({231, 9059}, target.itemid) then
        local rand = math.random(100)
        if target.actionid == 100 and rand <= 20 then
            target:transform(489)
            target:decay()
        elseif rand == 1 then
            Game.createItem(2159, 1, toPosition)
        elseif rand > 95 then
            Game.createMonster("Scarab", toPosition)
        end
        toPosition:sendMagicEffect(CONST_ME_POFF)    
    elseif target.itemid == 2739 then
        target:transform(2737)
        target:decay()
        Game.createItem(2694, 1, toPosition)    
    elseif target.itemid == 2782 then
        target:transform(2781)
        target:decay()    
    elseif target.itemid == 1499 then
        target:remove()
    elseif (target.uid <= 65535 or target.actionid > 0) and (target.itemid == 355 or target.itemid == 9025) then
        target:transform(392)
        target:decay()    
    elseif target.uid == 60001 then
        player:teleportTo(Position(329, 772, 10))
        Position(329, 772, 10):sendMagicEffect(10)
    elseif groundTile.itemid == 384 or groundTile.itemid == 418 or groundTile.itemid == 8278 then
        player:teleportTo(Position(toPosition.x, toPosition.y + 1, toPosition.z - 1), false)
    elseif isInArray(holeId, target.itemid) == TRUE then
        toPosition.z = toPosition.z + 1
        tile = Tile(toPosition)
        if tile then
            local thing = tile:getTopVisibleThing()
            if thing:isPlayer() or thing:isMonster() then
                if Tile(toPosition:moveUpstairs()):hasFlag(TILESTATE_PROTECTIONZONE) and thing:isPzLocked() then
                    return false
                end
                return thing:teleportTo(toPosition, false)
            end
            if thing:isItem() and thing:getType():isMovable() then
                return thing:moveTo(toPosition:moveUpstairs())
            end
        end
    else
        return false
    end
        
    return true
end
 
Back
Top