local config = {
req_item = {2148, 10}, -- Required item and count
portal_from = {x = 1000, y = 1000, z = 7}, -- Where portal will spawn
portal_to = {x = 1000, y = 1000, z = 7}, -- Where portals destination is
duration = 60 -- How long portal will exist in seconds
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 1946 then
return false
end
if player:getItemCount(config.req_item[1]) < config.req_item[2] then
return player:sendCancelMessage("You do not have enough of the required item.")
end
local portal_uid = doCreateTeleport(1387, config.portal_to, config.portal_from)
if not portal_uid then
print("ERROR: Portal cannot be created on position.")
return false
end
-- player:removeItem(config.req_item[1], config.req_item[2])
item:transform(1946)
addEvent(function()
local portal, lever = Tile(config.portal_from):getItemById(1387), Item(item.uid)
if portal and lever then
portal:remove()
lever:transform(1945)
end
end, config.duration * 1000)
return true
end