• 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.X+ Set uniqueid to created item

Raikou

Well-Known Member
Joined
Jul 18, 2007
Messages
145
Solutions
2
Reaction score
54
I have a quest that consists in destroying an item/object.
After it's destroyed I want to let it respawn with uniqueid, but i cant get it to work.

Lua:
function createEgg(position)
    print('Egg has respawned')
    Game.createItem(14820, 1, position)
   
    local egg = Tile(position):getItemById(14820)
    egg:setAttribute(IITEM_ATTRIBUTE_UNIQUEID, 6603)
  
end

This is what i came up with so far.
 
Last edited:
Lua:
IITEM_ATTRIBUTE_UNIQUEID
is misspelled.

Lua:
ITEM_ATTRIBUTE_UNIQUEID

Yea i found that out just now as well, but did gave me a new error.

Code:
(Unknown scriptfile)
LuaScriptInterface::luaItemSetAttribute(). Attempt to set protected key "uid"
stack traceback:
        [C]: in function 'setAttribute'
        data/actions/scripts/tools/eggwhopper.lua:5: in function <data/actions/scripts/tools/eggwhopper.lua:1>
Post automatically merged:

Just for the record here is the whole script:
Lua:
function createEgg(position)
    print('Egg has respawned')
    Game.createItem(14820, 1, position)
    local egg = Tile(position):getItemById(14820)
    egg:setAttribute(ITEM_ATTRIBUTE_UNIQUEID, 6603)
    
end


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    if target.uid == 6603 and target:getId() == 14820 and player:getStorageValue(6602) ~= 1 and player:getStorageValue(6602) ~=2  then
        player:say('You hit the egg, it`s quite sturdy...', TALKTYPE_MONSTER_SAY)
        player:setStorageValue(6602,1)
        
        return true
    end

    if target.uid == 6603 and target:getId() == 14820 and player:getStorageValue(6602) == 1  then
        player:say('You hit the egg again, something inside does not like it...', TALKTYPE_MONSTER_SAY)
        player:setStorageValue(6602,2)
        
        return true
    end

    if target.uid == 6603 and target:getId() == 14820 and player:getStorageValue(6602) == 2 and player:getStorageValue(6603) ~=1 then
        target:remove()
        print('Egg has been destroyed')
        Game.createMonster('Spidris Elite', Position(904, 1080, 7))
        player:say('You have destroyed the egg, there is a scary monster in it though...', TALKTYPE_MONSTER_SAY)
        player:setStorageValue(6603,1)
        player:setStorageValue(6600,3)   
        addEvent(createEgg, 1 * 10 * 1000, toPosition)
        return true
    end
    

    --return destroyItem(player, target, toPosition)
end
 
Back
Top