Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- resetTime = 15
- pistonRight = {0, 1,2,3, 7,8,9, 13,14,15}
- pistonTop = {0, 4,5,6, 10,11,12}
- updateTime = 0.5
- leftPressurePlate ="bottom"
- rightPressurePlate="left"
- leftPressurePlateLast=false
- runningTimer= 0
- numberShelfs= 15
- --Loop
- while true do
- --Check for update
- if (redstone.getAnalogInput(leftPressurePlate)>0) and (redstone.getAnalogInput(rightPressurePlate)>0) then
- os.sleep(0.1)
- runningTimer=0
- print("double pressed")
- elseif(leftPressurePlateLast==true) and (redstone.getAnalogInput(rightPressurePlate)>0) then
- numberShelfs=numberShelfs-1
- leftPressurePlateLast=false
- runningTimer=0
- print("right pressed")
- elseif (leftPressurePlateLast==false) and (redstone.getAnalogInput(leftPressurePlate)>0) then
- numberShelfs=numberShelfs-1
- leftPressurePlateLast=true
- runningTimer=0
- print("left pressed")
- elseif (redstone.getAnalogInput(leftPressurePlate)>0) or (redstone.getAnalogInput(rightPressurePlate)>0) then
- if (runningTimer==1000000) then
- runningTimer=0
- leftPressurePlateLast= not leftPressurePlateLast
- end
- else
- runningTimer=runningTimer+1
- end
- --Processing
- if (numberShelfs<=0) then numberShelfs=15 end
- --Top
- pistonTopValue = numberShelfs-8
- if (pistonTopValue<1) then pistonTopValue=1 end
- --Right
- pistonRightValue = numberShelfs+1
- if (pistonRightValue>10) then pistonRightValue=10 end
- --Set Redstone
- redstone.setAnalogOutput("top",pistonTop[pistonTopValue])
- redstone.setAnalogOutput("right",pistonRight[pistonRightValue])
- print(numberShelfs)
- print(runningTimer)
- --Reset timer
- if (runningTimer>resetTime/updateTime) then
- numberShelfs=15
- end
- if (runningTimer*updateTime>60) then
- runningTimer=1000000
- print("idle")
- os.sleep(5)
- else
- os.sleep(updateTime)
- end
- end
Add Comment
Please, Sign In to add comment