Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.find('monitor')
- if monitor then
- monitor.setTextScale(0.5)
- term.redirect(monitor)
- end
- local stressSide = 'left'
- local speedSide = 'back'
- local speed = 0
- local stress = 0
- local stressInput=0
- local width,height=term.getSize()
- local barLength=width-2
- local speedValues={
- [1]=4,
- [2]=8,
- [3]=12,
- [4]=16,
- [5]=20,
- [6]=26,
- [7]=32,
- [8]=48,
- [9]=64,
- [10]=80,
- [11]=104,
- [12]=128,
- [13]=160,
- [14]=192,
- [15]=256,
- }
- local stressComments={
- [1]='Is it plugged in?',
- [2]='Is it plugged in?',
- [3]='Is it plugged in?',
- [4]='Low-Stress',
- [5]='Low-Stress',
- [6]='Low-Stress',
- [7]='Moderate Stress',
- [8]='Moderate Stress',
- [9]='Moderate Stress',
- [10]='High Stress',
- [11]='High Stress',
- [12]='High Stress',
- [13]='Dangeometer\'s in the red',
- [14]='Dangeometer\'s in the red',
- [15]='Dangeometer\'s in the red',
- [16]='Overstressed',
- }
- local stressColors={
- [1]={colors.white,colors.lightGray},
- [2]={colors.white,colors.lightGray},
- [3]={colors.white,colors.lightGray},
- [4]={colors.lime,colors.green},
- [5]={colors.lime,colors.green},
- [6]={colors.lime,colors.green},
- [7]={colors.yellow,colors.orange},
- [8]={colors.yellow,colors.orange},
- [9]={colors.yellow,colors.orange},
- [10]={colors.orange,colors.red},
- [11]={colors.orange,colors.red},
- [12]={colors.orange,colors.red},
- [13]={colors.red,colors.black},
- [14]={colors.red,colors.black},
- [15]={colors.red,colors.black},
- [16]={colors.red,colors.red},
- }
- term.setBackgroundColor(colors.black)
- term.clear()
- while true do
- sleep()
- term.setCursorPos(2,3)
- speed = speedValues[redstone.getAnalogInput(speedSide)]
- stressInput = redstone.getAnalogInput(stressSide)
- if not speed then
- speed = 0
- end
- if not stressInput then
- stressInput = 0
- end
- stress = stressInput/15
- term.setBackgroundColor(colors.black)
- term.clearLine()
- term.setTextColor(colors.blue)
- for x = 1,barLength do
- if x < ((speed/255)*barLength) then
- term.setBackgroundColor(colors.cyan)
- write(string.char(127))
- else
- term.setBackgroundColor(colors.gray)
- write(' ')
- end
- end
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(2,2)
- term.clearLine()
- write('Speed: '..speed..' RPM')
- term.setCursorPos(2,5)
- term.clearLine()
- write('Stress: '..math.floor(stress*100)..'% - '..stressComments[stressInput+1])
- term.setCursorPos(2,6)
- term.clearLine()
- term.setTextColor(stressColors[stressInput+1][2])
- for x = 1,barLength do
- if x < (stress*barLength) then
- term.setBackgroundColor(stressColors[stressInput+1][1])
- write(string.char(127))
- else
- term.setBackgroundColor(colors.gray)
- write(' ')
- end
- end
- end
- --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement