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

Lua setUniqueId? TFS 1.5 downgrade

Azerty

Active Member
Joined
Apr 15, 2022
Messages
314
Solutions
4
Reaction score
32
How do I set uniqueId for the specified item?

Lua:
local teleportToPosition = Position(30627, 32461, 8)
local bossPosition = Position(30626, 32457, 8)

local function removeTeleport(position)
    local teleportItem = Tile(position):getItemById(1387)
    if teleportItem then
        teleportItem:remove()
        position:sendMagicEffect(CONST_ME_POFF)
        bossPosition:sendMagicEffect(CONST_ME_POFF)
    end
        local parchment = Game.createItem(6022, 1, bossPosition)
        if parchment then
            parchment:setActionId(59567)  <<-----
        end
end

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() == 'numb the weakened' then
    local position = targetMonster:getPosition()
    position:sendMagicEffect(CONST_ME_TELEPORT)
    local item = Game.createItem(1387, 1, position)
    if item:isTeleport() then
        item:setDestination(teleportToPosition)
    end
    targetMonster:say('Numb ran into teleporter! It will disappear in 2 minutes. Enter it!', TALKTYPE_MONSTER_SAY, 0, 0, position)

    --remove portal after 2 min
    addEvent(removeTeleport, 2 * 60 * 1000, position)
    end
    return true
end
 
How do I set uniqueId for the specified item?

Lua:
local teleportToPosition = Position(30627, 32461, 8)
local bossPosition = Position(30626, 32457, 8)

local function removeTeleport(position)
    local teleportItem = Tile(position):getItemById(1387)
    if teleportItem then
        teleportItem:remove()
        position:sendMagicEffect(CONST_ME_POFF)
        bossPosition:sendMagicEffect(CONST_ME_POFF)
    end
        local parchment = Game.createItem(6022, 1, bossPosition)
        if parchment then
            parchment:setActionId(59567)  <<-----
        end
end

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() == 'numb the weakened' then
    local position = targetMonster:getPosition()
    position:sendMagicEffect(CONST_ME_TELEPORT)
    local item = Game.createItem(1387, 1, position)
    if item:isTeleport() then
        item:setDestination(teleportToPosition)
    end
    targetMonster:say('Numb ran into teleporter! It will disappear in 2 minutes. Enter it!', TALKTYPE_MONSTER_SAY, 0, 0, position)

    --remove portal after 2 min
    addEvent(removeTeleport, 2 * 60 * 1000, position)
    end
    return true
end
Lua:
local teleportToPosition = Position(30627, 32461, 8)
local bossPosition = Position(30626, 32457, 8)

local function removeTeleport(position)
    local teleportItem = Tile(position):getItemById(1387)
    if teleportItem then
        teleportItem:remove()
        position:sendMagicEffect(CONST_ME_POFF)
        bossPosition:sendMagicEffect(CONST_ME_POFF)
    end
        local parchment = Game.createItem(6022, 1, bossPosition)
        if parchment then
            parchment:setActionId(59567)
            parchment:setUniqueId(12345)  -- set the uniqueId to 12345
        end
end

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() == 'numb the weakened' then
    local position = targetMonster:getPosition()
    position:sendMagicEffect(CONST_ME_TELEPORT)
    local item = Game.createItem(1387, 1, position)
    if item:isTeleport() then
        item:setDestination(teleportToPosition)
    end
    targetMonster:say('Numb ran into teleporter! It will disappear in 2 minutes. Enter it!', TALKTYPE_MONSTER_SAY, 0, 0, position)

    --remove portal after 2 min
    addEvent(removeTeleport, 2 * 60 * 1000, position)
    end
    return true
end
Added a call to the setUniqueId function on the parchment item, after the call to setActionId.
The setUniqueId function sets the uniqueId of the item to the specified value. In this case, the uniqueId is set to 12345 or whatever.
Also added the setUniqueId function call immediately after the setActionId function call, on the same line as the if parchment then statement.
 
Lua:
local teleportToPosition = Position(30627, 32461, 8)
local bossPosition = Position(30626, 32457, 8)

local function removeTeleport(position)
    local teleportItem = Tile(position):getItemById(1387)
    if teleportItem then
        teleportItem:remove()
        position:sendMagicEffect(CONST_ME_POFF)
        bossPosition:sendMagicEffect(CONST_ME_POFF)
    end
        local parchment = Game.createItem(6022, 1, bossPosition)
        if parchment then
            parchment:setActionId(59567)
            parchment:setUniqueId(12345)  -- set the uniqueId to 12345
        end
end

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() == 'numb the weakened' then
    local position = targetMonster:getPosition()
    position:sendMagicEffect(CONST_ME_TELEPORT)
    local item = Game.createItem(1387, 1, position)
    if item:isTeleport() then
        item:setDestination(teleportToPosition)
    end
    targetMonster:say('Numb ran into teleporter! It will disappear in 2 minutes. Enter it!', TALKTYPE_MONSTER_SAY, 0, 0, position)

    --remove portal after 2 min
    addEvent(removeTeleport, 2 * 60 * 1000, position)
    end
    return true
end
Added a call to the setUniqueId function on the parchment item, after the call to setActionId.
The setUniqueId function sets the uniqueId of the item to the specified value. In this case, the uniqueId is set to 12345 or whatever.
Also added the setUniqueId function call immediately after the setActionId function call, on the same line as the if parchment then statement.
Dont work bro
 
It looks like you are trying to set the uid attribute of the item but it is a protected attribute and cannot be modified. The uid attribute is a unique identifier that is assigned to every item when it is created and cannot be changed.
(and I guess this object builder/item problem) because it's working in my TFS.
 
Back
Top