• 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 TFS 1.2 Nostalrius Files - Creating Teleport upon kill with UID

froy

Active Member
Joined
Sep 30, 2009
Messages
151
Solutions
3
Reaction score
36
Using this code:


Code:
local teleportToPosition = Position(32001, 32625, 7)

local function removeTeleport(position)
    local teleportItem = Tile(position):getItemById(1949)
    if teleportItem then
        teleportItem:remove()
        position:sendMagicEffect(CONST_ME_POFF)
    end
end

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster or targetMonster:getName():lower() ~= 'orshabaal' then
        return true
    end

    local position = targetMonster:getPosition()
    position:sendMagicEffect(CONST_ME_TELEPORT)
    local item = Game.createItem(1949, 1, position)   
    doItemSetAttribute(create,"uid",1004)     
    if item:isTeleport() then
        item:setDestination(teleportToPosition)
    end
    targetMonster:say('test has been defeated, claim your rewards, mortals! It will disappear in 2 minutes.', TALKTYPE_MONSTER_SAY, 0, 0, position)

    --remove portal after 1 min
    addEvent(removeTeleport, 2 * 30 * 1000, position)
    return true
end
I do not get any error when running the exe but I assume
Code:
    doItemSetAttribute(create,"uid",1004)
is the reason why I'm getting this error when killing the monster in the script.

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/teleportkill.lua:onKill
data/creaturescripts/scripts/teleportkill.lua:20: attempt to call global 'doItemSetAttribute' (a nil value)
stack traceback:
        [C]: in function 'doItemSetAttribute'
        data/creaturescripts/scripts/teleportkill.lua:20: in function <data/creaturescripts/scripts/teleportkill.lua:11>

Any hints?
 
Solution
Problem solved, since Nostalrius is using Movement ID on teleports you'd be using

Code:
 item:setAttribute(ITEM_ATTRIBUTE_MOVEMENTID, 1004)
Can you use action id instead of unique id?

Lua:
doItemSetAttribute(create,"uid",1004)
to
Lua:
item:setAttribute(ITEM_ATTRIBUTE_ACTIONID, 1004)
 
Problem solved, since Nostalrius is using Movement ID on teleports you'd be using

Code:
 item:setAttribute(ITEM_ATTRIBUTE_MOVEMENTID, 1004)
 
Solution
Back
Top