Advertisement
Guest User

startup

a guest
Feb 26th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. local p1 = 'left'
  2. local p2 = 'top'
  3. local p3 = 'bottom'
  4. local p4 = 'back'
  5. local p5 = 'right'
  6.  
  7. local p1State = false
  8. local p2State = false
  9. local p3State = false
  10. local p4State = false
  11. local p5State = false
  12.  
  13. function togglePiston(index)
  14.     if index == 1 then
  15.         p1State = not p1State
  16.         rs.setOutput(p1, p1State)
  17.     elseif index == 2 then
  18.         p2State = not p2State
  19.         rs.setOutput(p2, p2State)
  20.     elseif index == 3 then
  21.         p3State = not p3State
  22.         rs.setOutput(p3, p3State)
  23.     elseif index == 4 then
  24.         p4State = not p4State
  25.         rs.setOutput(p4, p4State)
  26.     elseif index == 5 then
  27.         p5State = not p5State
  28.         rs.setOutput(p5, p5State)
  29.     end
  30. end
  31.  
  32. function extendPistons()
  33.     togglePistion(1)
  34.     sleep(0.25)
  35.     togglePistion(3)
  36.     sleep(0.25)
  37.     togglePistion(5)
  38. end
  39.  
  40. function retractPistons()
  41.     togglePistion(5)
  42.     sleep(0.25)
  43.     togglePistion(3)
  44.     sleep(0.25)
  45.     togglePistion(4)
  46.     sleep(0.25)
  47.     togglePistion(4)
  48.     sleep(0.25)
  49.     togglePistion(1)
  50.     sleep(0.25)
  51.     togglePistion(2)
  52.     sleep(0.25)
  53.     togglePistion(2)
  54.     sleep(0.25)
  55.     togglePistion(3)
  56.     sleep(0.25)
  57.     togglePistion(3)
  58. end
  59.  
  60. print('Press and hold CTRL+T to stop')
  61.  
  62. while true do
  63.     extendPistons()
  64.     sleep(1)
  65.     retractPistons()
  66.     sleep(5)
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement