View difference between Paste ID: Wbq1HJh8 and v1KDM9BV
SHOW: | | - or go back to the newest paste.
1
local mon = peripheral.wrap("left")
2
local son = peripheral.wrap("top")
3
term.redirect(mon)
4
local reactor
5
local link = false
6
local wifi = peripheral.wrap("right")
7
wifi.open(16)
8
9
local function reset()
10
    term.setBackgroundColor(colors.black)
11
    term.clear()
12
end
13
14
local function energie()
15
    term.setBackgroundColor(colors.black)
16
    term.setCursorPos(2,23)
17
    local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
18
    term.write("Stock Energie : "..message.." %")
19
end
20
21
local function tactile(xmin,xmax, ymin, ymax)
22
    os.startTimer(0.5)
23
    event, side, xPos, yPos = os.pullEvent("monitor_touch")
24
    if xPos <= xmax and xPos >= xmin and yPos <= ymax and yPos >= ymin then
25
        return true
26
    end
27
end
28
29
local function prod()
30
    term.setBackgroundColor(colors.black)
31
    term.setTextColor(colors.white)
32
    if peripheral.find("BigReactors-Reactor") then
33
        link = true
34
        reactor = peripheral.find("BigReactors-Reactor")
35
    else link = false end
36
    if link == true then
37
        local rf = reactor.getEnergyProducedLastTick()
38
        local fuel = reactor.getFuelAmount()/1000
39
        local isOk = reactor.getActive()
40
        local temp = reactor.getFuelTemperature()
41
        term.setBackgroundColor(colors.black)
42
        term.setCursorPos(4,27)
43
        term.clearLine()
44
        term.write("Link : ok")
45
        wifi.transmit(10,20,isOk)
46
        if isOk == true then
47
            term.setCursorPos(4,28)
48
            term.clearLine()
49
            term.write("Status : Allumé")
50
        else
51
            term.setCursorPos(4,28)
52
            term.clearLine()
53
            term.write("Status : Eteint")
54
        end
55
        term.setCursorPos(4,29)
56
        term.clearLine()
57
        term.write("Prod : "..math.ceil(rf/1000).." KRF/t")
58
        term.setCursorPos(4,30)
59
        term.write("Fuel : "..math.floor(fuel).." B")
60
        term.setCursorPos(4,31)
61
        term.clearLine()
62
        term.write("Heat : "..math.ceil(temp).." °C")
63
    elseif link == false then
64
        term.setCursorPos(4,27)
65
        term.clearLine()
66
        term.write("Link : error")
67
        term.setCursorPos(4,28)
68
        term.clearLine()
69
        term.write("Status : error")
70
        term.setCursorPos(4,29)
71
        term.clearLine()
72
        term.write("Prod : xxx")
73
        term.setCursorPos(4,30)
74
        term.clearLine()
75
        term.write("Fuel : xxx")
76
        term.setCursorPos(4,31)
77
        term.clearLine()
78
        term.write("Heat : xxx")
79
    end
80
    term.setCursorPos(10,26)
81
    term.write("Réacteur")
82
    paintutils.drawBox(2,25,24,32,colors.lightGray)
83
    
84
    paintutils.drawFilledBox(26,25,30,27,colors.green)
85
    term.setTextColor(colors.black) 
86
    term.setCursorPos(27,26)
87
    term.write("ON")   
88
    paintutils.drawFilledBox(26,30,30,32,colors.red)
89
    term.setCursorPos(27,31)
90
    term.write("OFF")
91
    term.setBackgroundColor(colors.black)
92
    term.setTextColor(colors.white)
93
    --if tactile(26,30,25,27) == true then
94
    --    reactor.setActive(true) 
95
    --end
96
    --if tactile(26,30,30,32) == true then
97
    --    reactor.setActive(false)
98
    --end
99
end
100
101
local function erreur()
102
    term.setBackgroundColor(colors.black)
103
    term.setCursorPos(3,5)
104
    term.setTextColor(colors.red)
105
    mon.setTextScale(3.5)
106
    term.write("Connexion Perdue")
107
end
108
109
local function chest() 
110
    term.setBackgroundColor(colors.black)
111
    if refinedstorage.isConnected()  == true then
112
        mon.setTextScale(1)
113
        term.setTextColor(colors.white)
114
        term.setCursorPos(1,1)
115
        local tbl = refinedstorage.getStorages()
116
        local t = tbl.total.item.capacity
117
        local u = tbl.total.item.usage
118
        local p = (u * 100) / t
119
        local x = 14
120
        local temp = 14
121
        
122
        if temp ~= x then
123
            if p < 10 then x = 11
124
            elseif p > 10 and p < 20 then x = 14 
125
            elseif p > 20 and p < 30 then x = 19
126
            elseif p > 30 and p < 40 then x = 24
127
            elseif p > 40 and p < 50 then x = 29
128
            elseif p > 50 and p < 60 then x = 34
129
            elseif p > 60 and p < 70 then x = 39
130
            elseif p > 70 and p < 80 then x = 44
131
            elseif p > 80 and p < 90 then x = 39
132
            elseif p > 90 and p < 100 then x = 54
133
            elseif p == 100 then x = 59
134
            end
135
            temp = x   
136
        else
137
            if p < 10 then x = 11
138
            elseif p > 10 and p < 20 then x = 14
139
            elseif p > 20 and p < 30 then x = 19
140
            elseif p > 30 and p < 40 then x = 24
141
            elseif p > 40 and p < 50 then x = 29
142
            elseif p > 50 and p < 60 then x = 34
143
            elseif p > 60 and p < 70 then x = 39
144
            elseif p > 70 and p < 80 then x = 44
145
            elseif p > 80 and p < 90 then x = 49
146
            elseif p > 90 and p < 100 then x = 54
147
            elseif p == 100 then x = 59
148
            end
149
        end
150
            
151
        
152
        if p < 50 then couleur = colors.green
153
        elseif p > 50 and p < 80 then couleur = colors.orange
154
        elseif p > 80 then couleur = colors.red
155
        end
156
157
        term.setCursorPos(2,24)
158
        volt = refinedstorage.getEnergyUsage()
159
        term.write("Conso Applied : "..math.ceil(volt).." RF/tick")
160
        
161
        paintutils.drawBox(10,2,60,8,colors.lightGray)
162
        if temp < x then
163
            paintutils.drawFilledBox(11,3,x,7,couleur)
164
        else
165
            --paintutils.drawFilledBox(2,4,6,6,colors.black)
166
            paintutils.drawFilledBox(11,3,59,7,colors.black)
167
            paintutils.drawFilledBox(11,3,x,7,couleur)
168
        end
169
        
170
        term.setBackgroundColor(colors.black)
171
        paintutils.drawFilledBox(64,4,68,6,colors.black)
172
        term.setCursorPos(65,5)
173
        term.write(math.ceil(p).."%")
174
        paintutils.drawFilledBox(2,4,6,6,colors.black)
175
        term.setCursorPos(3,5)
176
        term.write(math.ceil(u/1000).."K")    
177
178
        os.sleep(1)
179
    end
180
    if refinedstorage.isConnected() == false then    
181
        erreur()
182
    end
183
end
184
185
reset()
186
while true do
187
    chest()
188
    --energie()
189
    if refinedstorage.isConnected() == true then
190
        prod()
191
    end  
192
end