• 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 addEvent to change itemid

Fredrikli

Member
Joined
May 26, 2010
Messages
133
Reaction score
7
Code:
function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 9827 then
        doChangeTypeItem(item.uid, 9828)
        addEvent(doChangeTypeItem, 3 * 1000, item.uid, 9827)
    end
end

When i use the lever, it should just stay "used" for 3 seconds, and then return to it's original state.

After 3 seconds i get this in my console:

Code:
[Error - Action Interface]
In a timer event called from:
data/action/scripts/lever.lua:onUse
Description:
(LuaInterface::luaGetThing) Thing not found

What am I doing wrong?

Thanks in advance!
 
You can't use item.uid in addEvent unless the item has an uniqueid added in the map editor.

To change the item using addEvent you can use getTileItemById in a new function, so it gets the uid from there.
Code:
local function changeBack(pos, itemid, transformid)
     return doTransformItem(getTileItemById(pos, transformid).uid, itemid)
end

addEvent(changeBack, 3 * 1000, topos, item.itemid, 9828)
 
Back
Top