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

Coding Help - Stone braking weapon.

CesarZ

Well-Known Member
Joined
Sep 20, 2012
Messages
268
Solutions
4
Reaction score
63
I'm starting to work on "action" scripting now, and I don't exactly know how to start the script. This is what i have. im using TFs 1.3. Thanks for your help.

i also think it has to do with the (target == 1304) because the other functions are not showing. I also tried (target == itemId(1304))

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local player = Player()
    if (target == 1304) then -- if (target is equal to stoneID)
        target:remove(1304)  -- Remove stone
        target:addItem(1336)   -- add little stones on target spot
        target:sendMagicEffect(CONST_ME_POFF)   -- effects
        target:say("Boom!.",TALKTYPE_MONSTER_SAY )    -- effect
    else -- otherwise
        player:say("You can't break this.",TALKTYPE_MONSTER_SAY )    -- effect
    end
    return true
end
 
Solution
Lua:
local config = {
    largeStone = 1304,
    smallStones = 1336
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target:isItem() then
        return true
    end

    if not (target:getId() == config.largeStone) then
        player:say("You can't break this.", TALKTYPE_MONSTER_SAY)
        return true
    end

    -- Remove stone
    target:remove()

    -- add little stones on target spot
    Game.createItem(config.smallStones, 1, toPosition)
    toPosition:sendMagicEffect(CONST_ME_POFF)
    player:say("Boom!", TALKTYPE_MONSTER_SAY, false, nil, toPosition)
    return true
end
Lua:
local config = {
    largeStone = 1304,
    smallStones = 1336
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target:isItem() then
        return true
    end

    if not (target:getId() == config.largeStone) then
        player:say("You can't break this.", TALKTYPE_MONSTER_SAY)
        return true
    end

    -- Remove stone
    target:remove()

    -- add little stones on target spot
    Game.createItem(config.smallStones, 1, toPosition)
    toPosition:sendMagicEffect(CONST_ME_POFF)
    player:say("Boom!", TALKTYPE_MONSTER_SAY, false, nil, toPosition)
    return true
end
 
Solution
Lua:
local config = {
    largeStone = 1304,
    smallStones = 1336
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target:isItem() then
        return true
    end

    if not (target:getId() == config.largeStone) then
        player:say("You can't break this.", TALKTYPE_MONSTER_SAY)
        return true
    end

    -- Remove stone
    target:remove()

    -- add little stones on target spot
    Game.createItem(config.smallStones, 1, toPosition)
    toPosition:sendMagicEffect(CONST_ME_POFF)
    player:say("Boom!", TALKTYPE_MONSTER_SAY, false, nil, toPosition)
    return true
end
you should transform the item instead of remove and add. xP
target:transform(config.smallStones)
 
This work pretty well. You guys come up with mad coding ways to get it done. I feel mad basic with my shitty codes lol. I will get there eventually if i don't start having anxiety attacks.
When its the 8th try and the code don't pass I have to post it lol. Otherwise i end up with a headache.

Thanks man
 
This work pretty well. You guys come up with mad coding ways to get it done. I feel mad basic with my shitty codes lol. I will get there eventually if i don't start having anxiety attacks.
When its the 8th try and the code don't pass I have to post it lol. Otherwise i end up with a headache.

Thanks man
Don't worry, we've all been there.

I used to post like 17 questions an hour for @Limos to explain the most basic shit to me. xD
 
Lua:
local config = {
    largeStone = 1304,
    smallStones = 1336
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target:isItem() then
        return true
    end

    if not (target:getId() == config.largeStone) then
        player:say("You can't break this.", TALKTYPE_MONSTER_SAY)
        return true
    end

    -- Remove stone
    target:remove()

    -- add little stones on target spot
    Game.createItem(config.smallStones, 1, toPosition)
    toPosition:sendMagicEffect(CONST_ME_POFF)
    player:say("Boom!", TALKTYPE_MONSTER_SAY, false, nil, toPosition)
    return true
end
Is it possible to make the stone that was broken reappear after a while?
 
Back
Top