Advertisement
Guest User

SewerLever

a guest
Jun 24th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. local config = {
  2.     bridgePositions = {
  3.         {position = Position(32099, 32205, 8), groundId = 9022, itemId = 4645},
  4.         {position = Position(32100, 32205, 8), groundId = 4616},
  5.         {position = Position(32101, 32205, 8), groundId = 9022, itemId = 4647}
  6.     },
  7.     leverPositions = {
  8.         Position(32098, 32204, 8),
  9.         Position(32104, 32204, 8)
  10.     },
  11.     relocatePosition = Position(32102, 32205, 8),
  12.     relocateMonsterPosition = Position(32103, 32205, 8),
  13.     bridgeId = 5770
  14. }
  15.  
  16. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  17.     local leverLeft, lever = item.itemid == 1945
  18.     for i = 1, #config.leverPositions do
  19.         lever = Tile(config.leverPositions[i]):getItemById(leverLeft and 1945 or 1946)
  20.         if lever then
  21.             lever:transform(leverLeft and 1946 or 1945)
  22.         end
  23.     end
  24.  
  25.     for i, v in pairs(config.bridgePositions) do
  26.         if (Tile(v.position) and
  27.             Tile(v.position):getCreatureCount() > 0) then
  28.             for k, j in pairs(Tile(v.position):getCreatures()) do
  29.                 j:teleportTo(Position(32097, 32205, 8))
  30.             end
  31.         end
  32.     end
  33.     local tile, tmpItem, bridge
  34.     if leverLeft then
  35.         for i = 1, #config.bridgePositions do
  36.             bridge = config.bridgePositions[i]
  37.             tile = Tile(bridge.position)
  38.  
  39.             tmpItem = tile:getGround()
  40.             if tmpItem then
  41.                 tmpItem:transform(config.bridgeId)
  42.             end
  43.  
  44.             if bridge.itemId then
  45.                 tmpItem = tile:getItemById(bridge.itemId)
  46.                 if tmpItem then
  47.                     tmpItem:remove()
  48.                 end
  49.             end
  50.         end
  51.     else
  52.         for i = 1, #config.bridgePositions do
  53.             bridge = config.bridgePositions[i]
  54.             tile = Tile(bridge.position)
  55.  
  56.             tile:getGround():transform(bridge.groundId)
  57.             Game.createItem(bridge.itemId, 1, bridge.position)
  58.         end
  59.     end
  60.     return true
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement