View difference between Paste ID: wd2hMtDc and awMT344F
SHOW: | | - or go back to the newest paste.
1
local monitor = peripheral.find('monitor')
2
if monitor then
3
    monitor.setTextScale(0.5)
4
    term.redirect(monitor)
5
end
6
7
local stressSide = 'left'
8
local speedSide = 'back'
9
local speed = 0
10
local stress = 0
11
local stressInput=0
12
local width,height=term.getSize()
13
local barLength=width-2
14
15
local speedValues={
16
[1]=4,
17
[2]=8,
18
[3]=12,
19
[4]=16,
20
[5]=20,
21
[6]=26,
22
[7]=32,
23
[8]=48,
24
[9]=64,
25
[10]=80,
26
[11]=104,
27
[12]=128,
28
[13]=160,
29
[14]=192,
30
[15]=256,
31
}
32
local stressComments={
33
    [1]='Is it plugged in?',
34
    [2]='Is it plugged in?',
35
    [3]='Is it plugged in?',
36
    [4]='Low-Stress',
37
    [5]='Low-Stress',
38
    [6]='Low-Stress',
39
    [7]='Moderate Stress',
40
    [8]='Moderate Stress',
41
    [9]='Moderate Stress',
42
    [10]='High Stress',
43
    [11]='High Stress',
44
    [12]='High Stress',
45
    [13]='Dangeometer\'s in the red',
46
    [14]='Dangeometer\'s in the red',
47
    [15]='Dangeometer\'s in the red',
48
    [16]='Overstressed',
49
}
50
51
local stressColors={
52
    [1]={colors.white,colors.lightGray},
53
    [2]={colors.white,colors.lightGray},
54
    [3]={colors.white,colors.lightGray},
55
    [4]={colors.lime,colors.green},
56
    [5]={colors.lime,colors.green},
57
    [6]={colors.lime,colors.green},
58
    [7]={colors.yellow,colors.orange},
59
    [8]={colors.yellow,colors.orange},
60
    [9]={colors.yellow,colors.orange},
61
    [10]={colors.orange,colors.red},
62
    [11]={colors.orange,colors.red},
63
    [12]={colors.orange,colors.red},
64
    [13]={colors.red,colors.black},
65
    [14]={colors.red,colors.black},
66
    [15]={colors.red,colors.black},
67
    [16]={colors.red,colors.red},
68
}
69
70
term.setBackgroundColor(colors.black)
71
term.clear()
72
while true do
73
    sleep()
74
    term.setCursorPos(2,3)
75
    speed = speedValues[redstone.getAnalogInput(speedSide)]
76
    stressInput = redstone.getAnalogInput(stressSide)
77
    if not speed then
78
        speed = 0
79
    end
80
    if not stressInput then
81
        stressInput = 0
82
    end
83
    stress = stressInput/15
84
    term.setBackgroundColor(colors.black)
85
    term.clearLine()
86
    term.setTextColor(colors.blue)
87
    for x = 1,barLength do
88
        if x < ((speed/255)*barLength) then
89
            term.setBackgroundColor(colors.cyan)
90
            write(string.char(127))
91
        else
92
            term.setBackgroundColor(colors.gray)
93
            write(' ')
94
        end
95
    end
96
    term.setBackgroundColor(colors.black)
97
    term.setTextColor(colors.white)
98
    term.setCursorPos(2,2)
99
    term.clearLine()
100
    write('Speed: '..speed..' RPM')
101
    term.setCursorPos(2,5)
102
    term.clearLine()
103
    write('Stress: '..math.floor(stress*100)..'% - '..stressComments[stressInput+1])
104
    term.setCursorPos(2,6)
105
    term.clearLine()
106
    term.setTextColor(stressColors[stressInput+1][2])
107
    for x = 1,barLength do
108
        if x < (stress*barLength) then
109
            term.setBackgroundColor(stressColors[stressInput+1][1])
110
            write(string.char(127))
111
        else
112
            term.setBackgroundColor(colors.gray)
113
            write(' ')
114
        end
115
    end
116
end
117
118
--