Posted 11 October 2013 - 12:27 AM
so i have a simle issue im not understanding here,
i have this script its working just fine BUT, wwhen i touch the shot on the screen to exit the program and return to the shell nothing happens. but if i change the shell.exit() to and thing like print("this one works") it will show it on the computer but not the screen.
so any idea what i can do to get the button to exit the program and go back to shell when clicked?
Incase your wondering yes its a tut. program from youtube (im trying to learn)
i have this script its working just fine BUT, wwhen i touch the shot on the screen to exit the program and return to the shell nothing happens. but if i change the shell.exit() to and thing like print("this one works") it will show it on the computer but not the screen.
so any idea what i can do to get the button to exit the program and go back to shell when clicked?
Incase your wondering yes its a tut. program from youtube (im trying to learn)
mouseWidth = 0
mouseHeight = 0
monitor = peripheral.wrap("left")
monitor.clear()
monitor.setCursorPos(1,1)
w,h=monitor.getSize()
print(w)
print(h)
monitor.setBackgroundColour((colours.lime))
monitor.setCursorPos(2,2)
monitor.write(" ON ")
monitor.setCursorPos(2,4)
monitor.write(" OFF ")
monitor.setBackgroundColour((colours.black))
function checkClickPosition()
if mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 2 then
-- button one clicked
shell.run("todo")
-- turns redstone connected to the right on
elseif mouseWidth > 1 and mouseWidth < 8 and mouseHeight == 4 then
-- button two clicked
shell.exit()
-- turns redstone connected to the left off
end -- ends the if loop
end -- ends the function
repeat
event,p1,p2,p3 = os.pullEvent()
if event=="monitor_touch" then
mouseWidth = p2 -- sets mouseWidth
mouseHeight = p3 -- and mouseHeight
checkClickPosition() -- this runs our function
end
until event=="char" and p1==("x")