pink_panther
Excellent OT User
Wondering how/if possible to be able to create an item with a command like /i that will decay/disappear after a set time.
For example, if I wanted to spawn an item that doesn't normally decay, like a steel helmet. But I want the item to decay to 0 (be removed) after a set time.
Is it possible to do this without having to create a copy of the item with a decayTo and duration value in the items.xml?
In theory, wanted to be able to spawn any item and have it disappear after a set time.
I've tried something like this, but doesn't seem to work, though I don't get any errors.
I'm aware of how it could be done with an addEvent callback to find and remove the item from its uid or something, but wondering if it can be done this way instead.
For example, if I wanted to spawn an item that doesn't normally decay, like a steel helmet. But I want the item to decay to 0 (be removed) after a set time.
Is it possible to do this without having to create a copy of the item with a decayTo and duration value in the items.xml?
In theory, wanted to be able to spawn any item and have it disappear after a set time.
I've tried something like this, but doesn't seem to work, though I don't get any errors.
Lua:
local result = Game.createItem(1234, 1, player:getPosition())
if result then
result:decay()
result:setAttribute(ITEM_ATTRIBUTE_DECAYTO, 0)
result:setAttribute(ITEM_ATTRIBUTE_DURATION, 60)
result:setAttribute(ITEM_ATTRIBUTE_DECAYSTATE, true)
end
I'm aware of how it could be done with an addEvent callback to find and remove the item from its uid or something, but wondering if it can be done this way instead.