Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------- Setup & Configuration ----------
- -- Boot Sequence --
- sp1 = peripheral.wrap("speaker_11")
- sp2 = peripheral.wrap("speaker_12")
- sp3 = peripheral.wrap("speaker_13")
- --Declare what speakers to use
- monitor = peripheral.wrap("top")
- --Declare where the monitor is
- monitor.clear()
- --Clear the monitor
- monitor.setCursorPos(1, 1)
- --Set the cursor position to the top left
- -- Variable Creation --
- w,h = monitor.getSize()
- --Grab the monitor dimensions
- mouseWidth = 0
- mouseHeight = 0
- --Mouse position on screen
- monitorPosX, monitorPosY = monitor.getCursorPos()
- --Grab the current monitor text position
- on = false
- --Is the alarm currently on?
- quit = false
- --A variable used to exit the program
- quitTimeout = false
- --Also used to end the program
- -- Status Message --
- term.setCursorPos(1, 1)
- term.clear()
- print("")
- print("Program Running: Beats by Dewrot")
- print("")
- print("Monitor Width:", w)
- print("Monitor Height:", h)
- print("")
- print("Monitor Position:", "("..monitorPosX..","..monitorPosY..")")
- print("")
- print("Status: Off")
- print("")
- print("")
- print("")
- term.setTextColor((colors.yellow))
- print("Press 'X' to end program anytime.")
- term.setTextColor((colors.white))
- -------------- Draw the Screen --------------
- -- Button Creation --
- function drawScreen()
- monitor.setBackgroundColor((colors.black))
- --Makes sure the background is black
- monitor.setCursorPos(1,1)
- monitor.write("Beats")
- --Name of the program
- monitor.setBackgroundColor((colors.red))
- --Sets background of text to red
- monitor.setCursorPos(7,1)
- monitor.write("*")
- --The "EXIT" button
- if on ~= true then
- monitor.setBackgroundColor((colors.gray))
- monitor.setCursorPos(2,3)
- monitor.write(" ON ")
- --The "ON" button
- monitor.setBackgroundColor((colors.lime))
- monitor.setCursorPos(2,5)
- monitor.write(" OFF ")
- --The "OFF" button
- monitor.setBackgroundColor((colors.black))
- elseif on == true then
- monitor.setBackgroundColor((colors.lime))
- monitor.setCursorPos(2,3)
- monitor.write(" ON ")
- monitor.setBackgroundColor((colors.gray))
- monitor.setCursorPos(2,5)
- monitor.write(" OFF ")
- monitor.setBackgroundColor((colors.black))
- elseif quitTimeout == true then
- monitor.setCursorPos(1,1)
- monitor.setBackgroundColor((colors.black))
- monitor.clear()
- end
- end
- -- Placing Screen Elements --
- drawScreen()
- --------------- Button Logic ---------------
- -- Button Functions --
- function checkClickPosition()
- if mouseWidth == 7 and mouseHeight == 1 then
- --Red X button was pressed
- quit = true
- --Set the quit variable to true
- os.startTimer(0.1)
- elseif mouseWidth > 1 and mouseWidth < 7 and mouseHeight == 3 then
- --On button was pressed
- if on == true then
- return
- elseif on ~= true then
- on = true
- term.setCursorPos(9,9)
- term.write("On ")
- os.startTimer(0.1)
- end
- elseif mouseWidth > 1 and mouseWidth < 7 and mouseHeight == 5 then
- --Off button was pressed
- if on == true then
- on = false
- term.setCursorPos(9,9)
- term.write("Off")
- elseif on ~= true then
- return
- end
- end
- end
- repeat
- event,p1,p2,p3 = os.pullEvent()
- if event=="monitor_touch" then
- mouseWidth = p2
- mouseHeight = p3
- checkClickPosition()
- drawScreen()
- elseif event=="char" and p1 =="x" then
- term.clear()
- term.setCursorPos(1,1)
- monitor.clear()
- monitor.setCursorPos(1,1)
- quitTimeout = true
- elseif on and event=="timer" and quit== false then
- sp1.playSound("biomemakeover:red_rose", 3.0, 1)
- sp2.playSound("biomemakeover:red_rose", 3.0, 1)
- sp3.playSound("bimoemakeover:red_rose", 1.5, 1)
- os.startTimer(125.10)
- elseif quit==true then
- term.clear()
- term.setCursorPos(1,1)
- monitor.clear()
- monitor.setCursorPos(1,1)
- quitTimeout = true
- end
- until quitTimeout==true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement