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

Solved Error in script [TFS 1.2]

flaviiojr

Active Member
Joined
Jan 20, 2017
Messages
230
Solutions
13
Reaction score
39
When giving use in the lever it appears this error:

0sNUWpJ.png


As if I were missing a variable, but I do not know what it is
can you help me? Thank you very much in advance !

LUA:
local config = {
    [1945] = {
        sacrifices = {
            {position = Position(32878, 32270, 14), itemId = 2016},
            {position = Position(32881, 32267, 14), itemId = 2168},
            {position = Position(32881, 32273, 14), itemId = 6300},
            {position = Position(32884, 32270, 14), itemId = 1487}
        },
        wells = {
            {position = Position(32874, 32263, 14), itemId = 3729, transformId = 3733},
            {position = Position(32875, 32263, 14), itemId = 3730, transformId = 3734},
            {position = Position(32874, 32264, 14), itemId = 3731, transformId = 3735},
            {position = Position(32875, 32264, 14), itemId = 3732, transformId = 3736}
        }
    },
    [1946] = {
        wells = {
            {position = Position(32874, 32263, 14), itemId = 3733, transformId = 3729},
            {position = Position(32875, 32263, 14), itemId = 3734, transformId = 3730},
            {position = Position(32874, 32264, 14), itemId = 3735, transformId = 3731},
            {position = Position(32875, 32264, 14), itemId = 3736, transformId = 3732}
        }
    }
}

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

    item:transform(item.itemid == 1945 and 1946 or 1945)

    local wellItem
    for i = 1, #lever.wells do
        wellItem = Tile(lever.wells[i].position):getItemById(lever.wells[i].itemId)
        if wellItem then
            wellItem:transform(well.transformId)
        end
    end

    if lever.sacrifices then
        local sacrificeItems, sacrificeItem = true
        for i = 1, #lever.sacrifices do
            sacrificeItem = Tile(lever.sacrifices[i].position):getItemById(lever.sacrifices[i].itemId)
            if not sacrificeItem then
                sacrificeItems = false
                break
            end
        end

        if not sacrificeItems then
            return true
        end

        local stonePosition = Position(32881, 32270, 14)
        local stoneItem = Tile(stonePosition):getItemById(1355)
        if stoneItem then
            stoneItem:remove()
        end

        local teleportExists = Tile(stonePosition):getItemById(1387)
        if not teleportExists then
            local newItem = Game.createItem(1387, 1, stonePosition)
            if newItem then
                newItem:setActionId(9031)
            end
        end
    end
    return true
end
 
On line 38:
LUA:
wellItem:transform(well.transformId)

Use levers.wells not well.
 
Now instead of transforming the item, it disappears and does not come back anymore, it ceases to exist ...
No error appears on the console @WibbenZ

BUMP
 
Last edited by a moderator:
seems that you're trying use variable "well" instead "wells" that you declared...
Code:
wellItem:transform(well.transformId)
??
 
ofc I don't change anything, I'm showing to you where the variable is called when it don't exist
now I'll change

wellItem:transform(wells.transformId)

understand?
 
ofc I don't change anything, I'm showing to you where the variable is called when it don't exist
now I'll change

wellItem:transform(wells.transformId)

understand?
Aah man, I understand, and I've already made the change, but the same error is occurring ..
 
Back
Top