local wallPositions = {
{{x=2903, y=2512, z=9}, 1026},
{{x=2902, y=2512, z=9}, 1026},
{{x=2901, y=2512, z=9}, 1026},
{{x=2900, y=2512, z=9}, 1025},
{{x=2900, y=2511, z=9}, 1025},
{{x=2900, y=2510, z=9}, 1025},
{{x=2900, y=2509, z=9}, 1025},
{{x=2900, y=2508, z=9}, 1027},
{{x=2901, y=2508, z=9}, 1026},
{{x=2902, y=2508, z=9}, 1026},
{{x=2903, y=2508, z=9}, 1026},
{{x=2904, y=2508, z=9}, 1026},
{{x=2904, y=2509, z=9}, 1025},
{{x=2904, y=2510, z=9}, 1025},
{{x=2904, y=2511, z=9}, 1025},
{{x=2904, y=2512, z=9}, 1029}
}
local leverPositions = { -- the positions of each lever
[{x=2903, y=2511, z=9}] = 1946,
[{x=2901, y=2511, z=9}] = 1946,
[{x=2901, y=2509, z=9}] = 1946,
[{x=2903, y=2509, z=9}] = 1946
}
local newPos = {x=2942, y=2510, z=9}
local teleportPos = {x=2902, y=2510, z=9}
function onUse(cid, item, frompos, item2, topos)
doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
handleWall(wallPositions, item, 2006, 1, 3)
handleWall(wallPositions, item, 2007, 4, 8)
handleWall(wallPositions, item, 2008, 9, 12)
handleWall(wallPositions, item, 2009, 13, 16)
for position, itemid in pairs(leverPositions) do
if (getThingfromPos(position).itemid ~= itemid) then
local getTeleport = getThingfromPos(teleportPos)
if getTeleport.itemid == TELEPORT_ITEMID then
doRemoveItem(getTeleport.uid)
end
return 1
end
end
doCreateTeleport(1387, newPos, teleportPos)
return 1
end
function handleWall(positions, item, uid, nFrom, nTo)
if item.uid == uid then
for key=nFrom, nTo do
if item.itemid == 1945 then
positions[key][1].stackpos = 1
doRemoveItem(getThingfromPos(positions[key][1]).uid, 1)
else
doCreateItem(positions[key][2], 1, positions[key][1])
end
end
end
end