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

TFS 1.X+ problem with my shovel script

jackl90

Member
Joined
Jul 25, 2017
Messages
249
Reaction score
12
Hello guys,

my shovel is working on "items" on the floor, i can use shovel in items.

Screenshot of my problem

Imgur


Well... how could add a function to "return false" if have a item on the ground?


This is my script

LUA:
function onUse(player, item, fromPosition, target, toPosition)
    local tile = Tile(toPosition)
    if not tile then
        return false
    end

    local ground = tile:getGround()
    if not ground then
        return false
    end
   
   
    if ground:getId() == 231 then 
        ground:getPosition():sendMagicEffect(3)
        return true
    elseif ground:getId() == 593 then 
        ground:transform(594, 1)
        ground:decay()
        doRelocate(ground:getPosition(), ground:getPosition():moveRel(0,0,1))
        return true
    elseif ground:getId() == 606 then 
        ground:transform(607, 1)
        ground:decay()
        doRelocate(ground:getPosition(), ground:getPosition():moveRel(0,0,1))
        return true
    elseif ground:getId() == 608 then 
        ground:transform(609, 1)
        ground:decay()
        doRelocate(ground:getPosition(), ground:getPosition():moveRel(0,0,1))
    elseif ground:getId() == 614 and math.random(1, 100) <= 50 then
        ground:transform(615, 1)
        ground:decay()
        ground:getPosition():sendMagicEffect(3)
        doRelocate(ground:getPosition(), ground:getPosition():moveRel(0,0,1))
    elseif ground:getId() == 614 then
        ground:getPosition():sendMagicEffect(3)
    elseif ground:getId() == 616 and math.random(1, 100) <= 71 then
        ground:transform(617, 1)
        ground:decay()
        ground:getPosition():sendMagicEffect(3)
        Game.createMonster("scarab", ground:getPosition())
    elseif ground:getId() == 616 then
        ground:getPosition():sendMagicEffect(3)
        Game.createItem(3042, 1, ground:getPosition())
        ground:transform(617, 1)
        ground:decay()
    elseif ground:getId() == 617 then
        ground:getPosition():sendMagicEffect(3)
else
        return false
    end

    return true
end


thanks for help guys :)
 
Solution
just swap out ground for target
LUA:
function onUse(player, item, fromPosition, target, toPosition)
    local tile = Tile(toPosition)
    if not tile then
        return false
    end

    if not target:isItem() then
        return false
    end
   
   
    if target:getId() == 231 then
        target:getPosition():sendMagicEffect(3)
        return true
    elseif target:getId() == 593 then
        target:transform(594, 1)
        target:decay()
        doRelocate(target:getPosition(), target:getPosition():moveRel(0,0,1))
        return true
    elseif target:getId() == 606 then
        target:transform(607, 1)
        target:decay()
        doRelocate(target:getPosition(), target:getPosition():moveRel(0,0,1))
        return true...
just swap out ground for target
LUA:
function onUse(player, item, fromPosition, target, toPosition)
    local tile = Tile(toPosition)
    if not tile then
        return false
    end

    if not target:isItem() then
        return false
    end
   
   
    if target:getId() == 231 then
        target:getPosition():sendMagicEffect(3)
        return true
    elseif target:getId() == 593 then
        target:transform(594, 1)
        target:decay()
        doRelocate(target:getPosition(), target:getPosition():moveRel(0,0,1))
        return true
    elseif target:getId() == 606 then
        target:transform(607, 1)
        target:decay()
        doRelocate(target:getPosition(), target:getPosition():moveRel(0,0,1))
        return true
    elseif target:getId() == 608 then
        target:transform(609, 1)
        target:decay()
        doRelocate(target:getPosition(), target:getPosition():moveRel(0,0,1))
    elseif target:getId() == 614 and math.random(1, 100) <= 50 then
        target:transform(615, 1)
        target:decay()
        target:getPosition():sendMagicEffect(3)
        doRelocate(target:getPosition(), target:getPosition():moveRel(0,0,1))
    elseif target:getId() == 614 then
        target:getPosition():sendMagicEffect(3)
    elseif target:getId() == 616 and math.random(1, 100) <= 71 then
        target:transform(617, 1)
        target:decay()
        target:getPosition():sendMagicEffect(3)
        Game.createMonster("scarab", target:getPosition())
    elseif target:getId() == 616 then
        target:getPosition():sendMagicEffect(3)
        Game.createItem(3042, 1, target:getPosition())
        target:transform(617, 1)
        target:decay()
    elseif target:getId() == 617 then
        target:getPosition():sendMagicEffect(3)
else
        return false
    end

    return true
end
 
Solution

Similar threads

Replies
3
Views
281
Xikini
X
Back
Top