Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rside= 'top'
- Mside= ''
- rc= peripheral.wrap(Rside)
- m = peripheral.wrap(Mside)
- if (m ~= nil) then term.redirect(m) end
- function drawLevel(x,y,nowlevel,maxLevel,name,color)
- X,Y= term.getSize()
- deltaY= Y-(Y-y)
- k1= maxLevel/deltaY
- k2= math.ceil(nowlevel/k1)
- medium= math.ceil(k2/2)
- if (name ~= nil) then length= #name+1 end
- for i=1,k2 do
- paintutils.drawLine(x,y-i,x+length,y-i,color)
- end
- term.setCursorPos(x+1,y-medium)
- term.setTextColor(16384)
- io.write(name)
- term.setTextColor(1)
- paintutils.drawPixel(X,Y,32768)
- term.setCursorPos(x,y-deltaY+1)
- io.write(nowlevel..'/'..maxLevel)
- end
- 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
- X,Y= term.getSize()
- 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
- Button[#Button]['color']= 8192
- 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
- if (Button[i]['status'] == false) then
- Button[i]['funcT']()
- Button[i]['status']= true
- Button[#Button]['color']= 16384
- else
- Button[i]['funcF']()
- Button[i]['status']= false
- Button[#Button]['color']= 8192
- 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'],Button[i]['color'])
- 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'],Button[i]['color'])
- term.setCursorPos(Button[i]['x'],Button[i]['y'])
- io.write(Button[i]['nameT'])
- paintutils.drawPixel(X,Y,32768)
- end
- end
- end
- function off() rs.setOutput(Rside,false) end
- function on() rs.setOutput(Rside,true) end
- c= 0
- heat= 0
- Output= 0
- Button:new(12,10,'Stop','Start',on,off)
- os.startTimer(1)
- while true do
- Button:draw()
- drawLevel(1,19,rc.getHeat(),rc.getMaxHeat(),'Heat',16)
- drawLevel(21,19,rc.getEUOutput(),2048,'Output')
- event,a,b,c= os.pullEvent()
- if (event == 'mouse_click') then Button:update(b,c) end
- if (event == 'timer') then os.startTimer(1) end
- cs()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement