What you’ll learn:
In this last exercise, we’ll look at how to use an Advanced Computer and an Advanced Monitor to create a giant touchscreen.
mon = peripheral.wrap("top")
local message1 = "Click here."
local message2 = "Clicked!
while true do
mon.setBackgroundColor(colors.black)
mon.clear()
mon.setTextScale(4)
mon.setCursorPos(4,4)
mon.setTextColor(colors.green)
mon.write(message1)
event, side, x, y = os.pullEvent("monitor_touch")
if x > 4 and x < 15 and y == 4 then
mon.setBackgroundColor(colors.green)
mon.clear()
mon.setCursorPos(4,4)
mon.setTextColor(colors.black)
mon.write(message2)
sleep(3)
end
end