-- Coordinates for creating the teleport
local tpCreate = {x=1, y=1, z=1}
-- Destination of the teleport
local tpDest = {x=1, y=1, z=1}
-- IDs of teleport
local tpID = 1387
function onUse(cid, item, frompos, item2, topos)
if (item.itemid == 1945) then -- Creating teleport, switch flipped to left
local nextTile = {x=tpCreate.x, y=tpCreate.y + 1, z=tpCreate.z}
doRelocate(tpCreate, nextTile) -- Move all movable items or creatures 1 SQM south
doCreateTeleport(tpID, tpDest, tpCreate)
doTransformItem(item.uid, 1946)
elseif (item.itemid == 1946) then -- Closing door, switch flipped to right
doRemoveItem(getTileItemById(tpCreate, tpID).uid)
doTransformItem(item.uid, 1945)
end
return true
end