local config = {
[50113] = Position(32696, 31453, 13),
[50114] = Position(32692, 31453, 13),
[50115] = Position(32687, 31452, 13),
[50116] = Position(32682, 31455, 13),
[50117] = Position(32688, 31456, 13),
[50118] = Position(32692, 31459, 13),
[50119] = Position(32696, 31461, 13),
[50120] = Position(32695, 31464, 13),
[50121] = Position(32690, 31465, 13),
[50122] = Position(32684, 31464, 13),
[50123] = Position(32688, 31469, 13)
}
local function revertLever(position)
local tile = Tile(position)
if tile then
local leverItem = tile:getItemById(10045)
if leverItem then
leverItem:transform(10044)
end
end
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local railPosition = config[item.uid]
if not railPosition then
return false
end
if item:getId() ~= 10044 then
return false
end
local tile = Tile(railPosition)
if not tile then
return false
end
local topTopItem = tile:getTopTopItem()
if not topTopItem then
return false
end
-- Transform Rail
local topTopItemId = topTopItem:getId()
topTopItem:transform(topTopItemId ~= 7130 and topTopItemId + 1 or 7121)
-- Transform Lever
item:transform(10045)
-- Scheduled Event (Revert Lever)
addEvent(revertLever, 4000, toPosition)
return true
end