Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ================ INIT ================ --
- Rside= 'top'
- rc= peripheral.wrap(Rside)
- if (rc == nil) then error(Rside,' not found.') end
- -- ================ ClearScreen ================ --
- function cs()
- X,Y= term.getSize()
- for y=1,Y do
- for x=1,X do
- paintutils.drawPixel(x,y,32768)
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- end
- -- ================ Buttons ================ --
- Button= {}
- function Button:new(x,y,nameT,nameF,funcT,funcF)
- Button[#Button+1]= {}
- Button[#Button]['x']= x
- Button[#Button]['y']= y
- Button[#Button]['nameT']= nameT
- Button[#Button]['nameF']= nameF
- Button[#Button]['funcT']= funcT
- Button[#Button]['funcF']= funcF
- Button[#Button]['status']= false
- end
- function Button:nowName(count)
- if (Button[count]['status'] == false) then return Button[count]['nameF'] end
- if (Button[count]['status'] == true) then return Button[count]['nameT'] end
- end
- function Button:update(x,y)
- for i=1,#Button do
- length= Button[i]['x']+#Button:nowName(i)
- if (x > Button[i]['x'] and x < length and y == Button[i]['y']) then
- DLine= {}
- DLine.COUNT= 1
- if (Button[i]['status'] == false) then
- Button[i]['funcT']()
- Button[i]['status']= true
- else
- Button[i]['funcF']()
- Button[i]['status']= false
- end
- end
- end
- end
- function Button:draw()
- for i=1,#Button do
- term.setCursorPos(Button[i]['x'],Button[i]['y'])
- if (Button[i]['status'] == false) then
- paintutils.drawLine(Button[i]['x'],Button[i]['y'],Button[i]['x']+#Button:nowName(i),Button[i]['y'],8192)
- term.setCursorPos(Button[i]['x'],Button[i]['y'])
- io.write(Button[i]['nameF'])
- paintutils.drawPixel(X,Y,32768)
- else
- paintutils.drawLine(Button[i]['x'],Button[i]['y'],Button[i]['x']+#Button:nowName(i),Button[i]['y'],8192)
- term.setCursorPos(Button[i]['x'],Button[i]['y'])
- io.write(Button[i]['nameT'])
- paintutils.drawPixel(X,Y,32768)
- end
- end
- end
- -- ================ DLine ================ --
- DLine= {}
- DLine.COUNT= 1
- DLine.maxLevel= 0
- DLine.k1= 0
- DLine.Color= ''
- function config(maxLevel,color)
- X,Y= term.getSize()
- k1= math.ceil(maxLevel/(Y-1))
- DLine.maxLevel= maxLevel
- DLine.k1= k1
- DLine.Color= color
- end
- function add(nowlevel)
- X,Y= term.getSize()
- if (DLine.COUNT < X) then DLine.COUNT= DLine.COUNT+1 end
- if DLine.COUNT >= X then table.remove(DLine,1) s() end
- DLine[#DLine+1]= {}
- DLine[#DLine]['x']= DLine.COUNT
- DLine[#DLine]['y']= (Y+1)-math.ceil(nowlevel/DLine.k1)+1
- if (DLine[#DLine]['y'] > Y) then DLine[#DLine]['y']= Y end
- end
- function s( )
- for i=1,#DLine do
- DLine[i]['x']= DLine[i]['x']-1
- end
- end
- -- ================ GUI ================ --
- function draw()
- for i=1,#DLine do
- paintutils.drawPixel(DLine[i]['x'],DLine[i]['y'],16)
- end
- end
- function heats()
- heat= rc.getHeat()
- config(10000,16)
- draw()
- add(heat)
- end
- function EUOutputs()
- output= rc.getEUOutput()
- config(2048,2048)
- draw()
- add(output)
- end
- function setHeat()
- STATUS= 'heat'
- end
- function setEU()
- STATUS= 'EUOutput'
- end
- function on()
- rs.setOutput(Rside,true)
- end
- function off()
- rs.setOutput(Rside,false)
- end
- -- ================ MAIN ================ --
- config(10000)
- Button:new(1,1,'Heat','Heat',setHeat,setHeat)
- Button:new(15,1,'EUOutput','UOutput',setEU,setEU)
- Button:new(25,1,'Stop','Start',on,off)
- STATUS= 'heat'
- os.startTimer(1)
- while true do
- event,a,b,c= os.pullEvent()
- if (event == 'timer') then
- cs()
- if (STATUS == 'heat') then
- heats()
- end
- if (STATUS == 'EUOutput') then
- EUOutputs()
- end
- Button:draw()
- draw()
- os.startTimer(1)
- end
- if (event == 'mouse_click') then Button:update(b,c) end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement