Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. -- CONFIGURAÇÕES --
  2. local doors= {14155, 14154, 14153, 14152}
  3. local door_pos= {x=1386, y=736, z=7}
  4. -- FIM CONFIGURAÇÕES --
  5. print("door_pos :"..door_pos.x)
  6. local top_left= {x=door_pos.x - 3, y=door_pos.y - 2, z=door_pos.z}
  7. local bottom_right= {x=door_pos.x, y=door_pos.y + 2, z=door_pos.z}
  8.  
  9. local function areThereCreaturesInArea(top_left, bottom_right) 
  10. for x= top_left.x, bottom_right.x
  11. do     
  12. for y= top_left.y, bottom_right.y
  13. do         
  14. if isCreature(getTopCreature({x=x, y=y, z=top_left.z}).uid) then               
  15. return true        
  16. end    
  17. end
  18. end    
  19. return false
  20. end
  21. local function open(pos, i)
  22. if i < #doors then  current = doors[i]  next_ = doors[i+1] 
  23. local door = getTileItemById(pos, current) 
  24. if door.uid > 0 then       
  25. doTransformItem(door.uid, next_)       
  26. addEvent(open, 200, pos, i+1)  
  27. end
  28. end
  29. end
  30. local function close_(pos, i)
  31. if areThereCreaturesInArea(top_left, bottom_right)
  32. then   
  33. return
  34. true
  35. end
  36. if i <= #doors and i > 1 then  
  37. current = doors[i]  next_ = doors[i-1]     
  38. local door = getTileItemById(pos, current) 
  39. if door.uid > 0 then       
  40. doTransformItem(door.uid, next_)       
  41. addEvent(close_, 200, pos, i-1)
  42. end
  43. end
  44. end
  45. function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)  
  46. for i = 1, #doors do       
  47. local door = getTileItemById(door_pos, doors[i])       
  48. if door.uid > 0 then           
  49. open(door_pos, i)          
  50. break      
  51. end
  52. end
  53. return true
  54. end
  55. function onStepOut(cid, item, position, lastPosition, fromPosition, toPosition, actor) 
  56. close_(door_pos, #doors)   
  57. return true
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement