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

Target not decaying

dewral

Veteran OT User
Joined
Dec 4, 2019
Messages
345
Solutions
10
Reaction score
372
Hello i'm using this code - TFS 1.2 Looking for action transform item to x item (https://otland.net/threads/tfs-1-2-looking-for-action-transform-item-to-x-item.280505/#post-2691316)
It's working great but i wanna make that i need seed to start the growing
Im using this for seed

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target.itemid == 6314 then
        target:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
        target:transform(6313)
        return true
    end
end

But after transform it's not decaying anymore :/
I'm using tfs 1.5 7.72
 
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target.itemid == 6314 then
        target:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
        target:transform(6313)
        target:decay(target.itemid)
        return true
    end
end
 
Thanks for replying, already tried those ways before but it doesn't seem to work i don't know why
Here is a video : https://im5.ezgif.com/tmp/ezgif-5-9da132149a.mp4
Is like something blocking to do decay?

There is code for growing

Lua:
local tree = {
    [6310] = {growingStates = {6313, 6312, 6311, 6322}, growingTime = 2, giveItems = {itemId = 6415, maxAmount = 100}}, -- growing time is in seconds.
    --[1111] = {growingStates = {2222, 3333, 4444}, growingTime = 5, giveItems = {itemid, maxAmount}},
    --[2222] = {growingStates = {3333, 4444, 5555}, growingTime = 5, giveItems = {itemid, maxAmount}}
}

local function growTree(treeItemId, position)
    local growing = tree[treeItemId].growingStates
    for i = 1, #growing - 1 do
        local item = Tile(position):getItemById(growing[i])
        if item then
            item:transform(growing[i + 1])
            addEvent(growTree, 1000 * tree[treeItemId].growingTime, treeItemId, position)
            return
        end
    end
    local item = Tile(position):getItemById(growing[#growing])
    item:transform(treeItemId)
    return
end

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local index = tree[item:getId()]
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You have collected your weed.")
    player:addItem(index.giveItems.itemId, math.random(index.giveItems.maxAmount))
    addEvent(growTree, 1000 * index.growingTime, item:getId(), item:getPosition())
    item:transform(6314)
    return true
end

for v, k in pairs(tree) do
    action:id(v)
end
action:register()
Post automatically merged:

Just target:decay()
Now i tried and it's working haha.
Thank you for help
 
Last edited:
Back
Top