Spatzenhirn123

Enchanting Bookdance

Feb 11th, 2022 (edited)
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. resetTime   = 15
  2. pistonRight = {0, 1,2,3, 7,8,9, 13,14,15}
  3. pistonTop   = {0, 4,5,6, 10,11,12}
  4. updateTime  = 0.5
  5.  
  6. leftPressurePlate ="bottom"
  7. rightPressurePlate="left"
  8. leftPressurePlateLast=false
  9. runningTimer= 0
  10. numberShelfs= 15
  11.  
  12.  
  13. --Loop
  14. while true do
  15.  
  16. --Check for update
  17.     if (redstone.getAnalogInput(leftPressurePlate)>0) and (redstone.getAnalogInput(rightPressurePlate)>0) then
  18.         os.sleep(0.1)
  19.         runningTimer=0
  20.         print("double pressed")
  21.     elseif(leftPressurePlateLast==true) and (redstone.getAnalogInput(rightPressurePlate)>0) then
  22.         numberShelfs=numberShelfs-1
  23.         leftPressurePlateLast=false
  24.         runningTimer=0
  25.         print("right pressed")
  26.     elseif (leftPressurePlateLast==false) and (redstone.getAnalogInput(leftPressurePlate)>0) then
  27.         numberShelfs=numberShelfs-1
  28.         leftPressurePlateLast=true
  29.         runningTimer=0
  30.         print("left pressed")
  31.     elseif (redstone.getAnalogInput(leftPressurePlate)>0) or (redstone.getAnalogInput(rightPressurePlate)>0) then
  32.         if (runningTimer==1000000) then
  33.             runningTimer=0
  34.             leftPressurePlateLast= not leftPressurePlateLast
  35.         end
  36.     else
  37.         runningTimer=runningTimer+1
  38.     end
  39.    
  40. --Processing
  41.     if (numberShelfs<=0) then numberShelfs=15 end
  42.        
  43.     --Top
  44.     pistonTopValue = numberShelfs-8
  45.     if (pistonTopValue<1) then pistonTopValue=1 end
  46.    
  47.     --Right
  48.     pistonRightValue = numberShelfs+1
  49.     if (pistonRightValue>10) then pistonRightValue=10 end
  50.    
  51.     --Set Redstone
  52.     redstone.setAnalogOutput("top",pistonTop[pistonTopValue])
  53.     redstone.setAnalogOutput("right",pistonRight[pistonRightValue])
  54.    
  55.     print(numberShelfs)
  56.     print(runningTimer)
  57.    
  58. --Reset timer
  59.     if (runningTimer>resetTime/updateTime) then
  60.         numberShelfs=15
  61.     end
  62.     if (runningTimer*updateTime>60) then
  63.         runningTimer=1000000
  64.         print("idle")
  65.         os.sleep(5)
  66.     else
  67.         os.sleep(updateTime)
  68.     end
  69. end
Add Comment
Please, Sign In to add comment