Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Global variables
- --21 send, 22-receive
- mouseWidth = 0
- mouseHeight = 0
- ------------------
- StartLine = 1
- currentLine = StartLine
- MaxLine = 12
- ------------------
- --initialize
- monitor = peripheral.wrap("right")
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write("INITIALIZE")
- --
- modem = peripheral.wrap("bottom")
- modem.open(21)
- --Write On/Off button
- function WriteButtons(IsOn)
- monitor.setTextColor(colors.white)
- if IsOn == true then
- monitor.setBackgroundColour((colours.lime))
- monitor.setCursorPos(24,2)
- monitor.write(" ")
- monitor.setCursorPos(24,3)
- monitor.write(" ON ")
- monitor.setCursorPos(24,4)
- monitor.write(" ")
- else
- monitor.setBackgroundColour((colours.red))
- monitor.setCursorPos(24,2)
- monitor.write(" ")
- monitor.setCursorPos(24,3)
- monitor.write(" OFF ")
- monitor.setCursorPos(24,4)
- monitor.write(" ")
- end
- monitor.setBackgroundColour((colours.black))
- end
- --Check mouse to button click
- function checkClickPosition()
- if mouseWidth >= 24 and mouseWidth <= 28 and mouseHeight >= 2 and mouseHeight <= 4 then
- --WriteButtons(IsOnFlag)
- --UpdateSensors()
- end
- end
- --
- function DrawMessage(Text)
- if (currentLine > MaxLine) then
- currentLine = StartLine
- monitor.clear()
- end
- DrawTextLine(colors.white, currentLine, Text)
- currentLine = currentLine + 1
- end
- --
- function DrawTextLine(Color, Line, TextH)
- monitor.setCursorPos(1,Line)
- monitor.setTextColor(Color)
- monitor.write(TextH)
- end
- ------------------
- w,h=monitor.getSize()
- print(w)
- print(h)
- repeat
- --local myTimer = os.startTimer(1)
- event,p1,p2,p3,p4,p5 = os.pullEvent()
- if event=="monitor_touch" then
- mouseWidth = p2 -- sets mouseWidth
- mouseHeight = p3 -- and mouseHeight
- checkClickPosition() -- this runs our function
- end
- --
- if (event=="modem_message") then
- --event, side, channel, replyChannel, message, distance
- DrawMessage(p4)
- end
- --
- --if event=="timer" then
- --
- --end
- until event=="char" and p1==("q")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement