Coding Help - Stone braking weapon.

CesarZ

Active Member
Joined
Sep 20, 2012
Messages
222
Solutions
2
Reaction score
43
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

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,244
Solutions
71
Reaction score
545
Location
Hell
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

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,407
Solutions
361
Reaction score
3,514
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)
 
OP
CesarZ

CesarZ

Active Member
Joined
Sep 20, 2012
Messages
222
Solutions
2
Reaction score
43
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
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,407
Solutions
361
Reaction score
3,514
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
 
Top