Posted 11 December 2013 - 03:37 PM
I'm basically making random programs, playing around with functions and such slowly trying to learn as much as I can about ComputerCraft (I'm new) the top half of my program is perfectly fine, but I'm trying to add the X and Y coords of where you click on the screen to the monitor, which I've never even attempted before, I thought I had the just of it but apparently that isn't the case. Here's the code, I'll put a comment on where I started adding and show what I'm trying to do and where.
monitor = peripheral.wrap("right")
monitor.setCursorPos(1,1)
monitor.clear()
monitor.setTextScale(1)
while true do
if rs.getInput("left") == true then
monitor.write("Redstone signal is on.")
break
else
monitor.write("Please turn me on. (Not in that way)")
break
end
end
monitor.setCursorPos(1,2)
monitor.write("This monitor is for testing")
monitor.setCursorPos(1,3)
monitor.write("If you want to see what I'm")
monitor.setCursorPos(1,4)
monitor.write("testing right now hit the lever")
monitor.setCursorPos(1,5)
monitor.write("and type 'test' into the computer")
monitor.setCursorPos(1,7)
cursorX, cursorY = monitor.getCursorPos() --This is where I started adding, this works fine though,
monitor.write("X:"..cursorX.." Y:"..cursorY)
print("X:"..cursorX.." Y:"..cursorY)
while true do --Around here is where things begin to go a bit downhill,
x,y = os.pullEvent(monitor_touch) --This is (I believe) the center of the problem,
if os.pullEvent == monitor_touch then --I was messing around after I couldn't get it right,
monitor.setCursorPos(1,9)
monitor.write("X:"..x.." Y:"..y) --Before I started screwing around this said "Monitor_touch" and "Right" if I remember correctly, that's a big if because I make mistakes,
else
monitor.setTextColor(colors.red) --I don't understand why but this changes the text above apparently?
monitor.write("FAIL") --Again, was messing around after I couldn't get it right,
end
end