Posted 06 May 2018 - 07:45 AM
I am trying to make a program which will display black until the monitor is clicked, and turn into blue. Like a light switch.
local cmon = peripheral.wrap("top")
local state = 0
local cmon = peripheral.wrap("top")
local state = 0
while true do
if state==1 then
cmon.setBackgroundColor(colors.blue)
cmon.clear()
else
cmon.setBackgroundColor(colors.black)
cmon.clear()
end
event, side, x,y = os.pullEvent()
if event == "monitor_touch" then
if state==0 then
local state = 1
end
if state==1 then
local state = 0
end
end
end