• 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.2 Looking for action transform item to x item

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
873
Solutions
2
Reaction score
49
Hi
does anyone have an action script that would lets say transform items and would give x random ammount of item (1 to 8) once u click on it so basically it would be

(Pressing use on this item) 3500id (Grown Tree) --> 3501id (Cut tree Off) --> 3502id (Growing tree) -->3503id (Growing tree) --> 3500id (Back to grown tree)

and it would have timer that takes x time to transform to it lets say like 1 minute
 
Solution
View attachment bandicam 2022-04-10 13-29-36-649.mp4

Lua:
local tree = {
    [3500] = {growingStates = {3501, 3502, 3503}, growingTime = 2, giveItems = {itemId = 2148, maxAmount = 8}}, -- 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...
View attachment bandicam 2022-04-10 13-29-36-649.mp4

Lua:
local tree = {
    [3500] = {growingStates = {3501, 3502, 3503}, growingTime = 2, giveItems = {itemId = 2148, maxAmount = 8}}, -- 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:addItem(index.giveItems.itemId, math.random(index.giveItems.maxAmount))
    addEvent(growTree, 1000 * index.growingTime, item:getId(), item:getPosition())
    item:transform(index.growingStates[1])
    return true
end

for v, k in pairs(tree) do
    action:id(v)
end
action:register()
 
Solution
View attachment 66913

Lua:
local tree = {
    [3500] = {growingStates = {3501, 3502, 3503}, growingTime = 2, giveItems = {itemId = 2148, maxAmount = 8}}, -- 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:addItem(index.giveItems.itemId, math.random(index.giveItems.maxAmount))
    addEvent(growTree, 1000 * index.growingTime, item:getId(), item:getPosition())
    item:transform(index.growingStates[1])
    return true
end

for v, k in pairs(tree) do
    action:id(v)
end
action:register()
Thanks xikini :D

ezgif-5-e84294dc70.gif
 
View attachment 66913

Lua:
local tree = {
    [3500] = {growingStates = {3501, 3502, 3503}, growingTime = 2, giveItems = {itemId = 2148, maxAmount = 8}}, -- 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:addItem(index.giveItems.itemId, math.random(index.giveItems.maxAmount))
    addEvent(growTree, 1000 * index.growingTime, item:getId(), item:getPosition())
    item:transform(index.growingStates[1])
    return true
end

for v, k in pairs(tree) do
    action:id(v)
end
action:register()
what an insane release
 
How can I make the process start using a item on it instead of just clicking on it?
For example use a axe on the tree to start the process of transformation
 
Back
Top