• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Few script bugs tfs 1.2

Don't forget to update your shovel script as well, since it's supposed to transform the wagon to item id 10037, and not create item id 8749 on top of it.

Code:
local config = {
    [7131] = {directionOffset = Position(1, 0, 0), endPosition = Position(32717, 31492, 11)},
    [10037] = {directionOffset = Position(-1, 0, 0), endPosition = Position(32699, 31492, 11)}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local wagonConfig = config[item.itemid]
    if not wagonConfig then
        return false
    end

    local wagonPosition = item:getPosition()
    if wagonPosition == wagonConfig.endPosition then
        return false
    end

    player:say("SQUEEEEAK", TALKTYPE_MONSTER_SAY, false, player, wagonPosition)
    item:moveTo(wagonPosition + wagonConfig.directionOffset)
    return true
end

Code:
local config = {
    [50113] = Position(32696, 31453, 13),
    [50114] = Position(32692, 31453, 13),
    [50115] = Position(32687, 31452, 13),
    [50116] = Position(32682, 31455, 13),
    [50117] = Position(32688, 31456, 13),
    [50118] = Position(32692, 31459, 13),
    [50119] = Position(32696, 31461, 13),
    [50120] = Position(32695, 31464, 13),
    [50121] = Position(32690, 31465, 13),
    [50122] = Position(32684, 31464, 13),
    [50123] = Position(32688, 31469, 13)
}

local function revertLever(position)
    local tile = Tile(position)
    if tile then
        local leverItem = tile:getItemById(10045)
        if leverItem then
            leverItem:transform(10044)
        end
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local railPosition = config[item.uid]
    if not railPosition then
        return false
    end

    if item:getId() ~= 10044 then
        return false
    end

    local tile = Tile(railPosition)
    if not tile then
        return false
    end

    local topTopItem = tile:getTopTopItem()
    if not topTopItem then
        return false
    end

    -- Transform Rail
    local topTopItemId = topTopItem:getId()
    topTopItem:transform(topTopItemId ~= 7130 and topTopItemId + 1 or 7121)

    -- Transform Lever
    item:transform(10045)

    -- Scheduled Event (Revert Lever)
    addEvent(revertLever, 4000, toPosition)
    return true
end
 
@Ninja thanks, also I'm sorry I forget to post a script.

coalLevers.lua
Script: http://pastebin.com/k43GHYBL
Error: http://3.1m.yt/S5PW8l.png

I don't understand why crucible are in nil value, if possible could you explain?
It becomes a nil value because it were incapable of finding an item by id 8641. That's why it's important that you verify whether the item exists or not before you proceed to check its action id, and other things.
Code:
local config = {
    [50108] = {actionId = 50122, wagonPos = Position(32696, 31495, 11)},
    [50109] = {actionId = 50123, wagonPos = Position(32694, 31495, 11)},
    [50110] = {actionId = 50124, wagonPos = Position(32692, 31495, 11)},
    [50111] = {actionId = 50125, wagonPos = Position(32690, 31495, 11)}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local leverConfig = config[item.uid]
    if not leverConfig then
        return false
    end

    local tile = Tile(Position(32699, 31494, 11))
    if not tile then
        return false
    end

    local crucibleItem = tile:getItemById(8641)
    if crucibleItem and crucibleItem.actionid == 50121 then
        local wagonItem = Game.createItem(7132, 1, leverConfig.wagonPos)
        if wagonItem then
            wagonItem:setActionId(leverConfig.actionId)
        end

        crucibleItem:transform(8642)
    end

    item:transform(item.itemid == 10044 and 10045 or 10044)
    return true
end
 
Back
Top