Guest User

lever.lua

a guest
Nov 8th, 2017
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. local wallPosition = Position(33398, 32468, 8) --wall position
  2. local wall = 1546 --wall ID
  3. local revertTime = 1 * 60 * 1000 --time: 1=1min
  4.  
  5. local function revertWall()
  6. Game.createItem(wall, 1, wallPosition)
  7. wallPosition:sendMagicEffect(CONST_ME_POFF)
  8. end
  9.  
  10. local function revertLever(position)
  11. local leverItem = Tile(position):getItemById(1946)
  12. if leverItem then
  13. leverItem:transform(1945)
  14. end
  15. end
  16.  
  17. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  18. if item.itemid == 1945 then
  19. local removeWall = Tile(wallPosition):getItemById(wall)
  20. if removeWall then
  21. removeWall:remove()
  22. wallPosition:sendMagicEffect(CONST_ME_POFF)
  23. addEvent(revertWall, revertTime)
  24. end
  25.  
  26. item:transform(1946)
  27. addEvent(revertLever, revertTime, toPosition)
  28. end
  29. return true
  30. end
Advertisement
Add Comment
Please, Sign In to add comment