Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("bg")
- os.loadAPI("button")
- term.clear()
- m = peripheral.wrap("monitor_1")
- m2 = peripheral.wrap("monitor_2")
- cell = peripheral.wrap("tile_blockcapacitorbank_name_0")
- m.clear()
- m2.clear()
- function filltable()
- m.clear()
- button.clearTable()
- button.screen()
- sleep(0.2)
- if page == 1 then
- button.clearTable()
- sleep(0.2)
- button.setTable("Energy",statef," ",2,9,2,4)
- button.setTable("Time",time," ",2,9,6,8)
- elseif page == 2 then
- button.setTable("Day",sday," ",2,8,2,4)
- button.setTable("Night",snight," ",2,8,6,8)
- button.setTable("Back",start," ",38,44,18,20)
- end
- end
- function getClick()
- event,side,x,y = os.pullEvent("monitor_touch")
- button.checkxy(x,y)
- end
- function statef()
- button.toggleButton("Energy")
- if a == true then
- rs.setOutput("back",false)
- a = false
- else
- rs.setOutput("back",true)
- a = true
- end
- end
- function start()
- page = 1
- button.clearTable()
- a = false
- x = true
- rs.setOutput("back",false)
- --filltable()
- --button.screen()
- start2()
- sleep(2)
- end
- function start2()
- page = 1
- filltable()
- button.screen()
- if x == true then
- x = false
- button.toggleButton("Energy")
- end
- loop = true
- parallel.waitForAny(
- function()
- while loop do
- getClick()
- sleep(0.2)
- end
- end,
- function()
- while loop do
- if a == false then
- e = cell.getEnergyStored()
- m.setCursorPos(11,3)
- m.write(e)
- sleep(0.2)
- else
- m.setCursorPos(11,3)
- m.write(" ")
- sleep(0.2)
- end
- end
- end
- )
- end
- start()
- function time()
- page = 2
- sleep(0.2)
- button.clearTable()
- button.screen()
- sleep(0.2)
- filltable()
- button.screen()
- parralel.waitForAny(
- function()
- t = os.time()
- m.setCursorPos()
- m.write("Current time: "..t)
- sleep(0.2)
- end,
- function()
- getClick()
- end
- )
- end
- function sday()
- button.flash("Day")
- if t <= 6 then
- rs.setOutput("left",true)
- sleep(100)
- rs.setOutput("left",false)
- elseif time >= 18 then
- rs.setOutput("left",true)
- sleep(20)
- rs.setOutput("left",false)
- end
- end
- function snight()
- button.flash("Night")
- if t >= 12 and t <= 18 then
- rs.setOutput("left",true)
- sleep(10)
- rs.setOutput("left",false)
- elseif t >= 6 and t <= 12 then
- rs.setOutput("left",true)
- sleep(20)
- rs.setOutput("left",false)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement