Humenius

ComputerCraft - Farming Turtle - Touch Screen Test

Dec 12th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. event, side, xPos, yPos = os.pullEvent("monitor_touch")
  2.  
  3. side = "back"
  4. mon = peripheral.wrap( side )
  5. peripheral.call( side, "clear" )
  6.  
  7. function writeCenter(text, y, mon)
  8.   local w, h = mon.getSize() or term.getSize()
  9.   if mon then
  10.     mon.setCursorPos( math.ceil( w/2 - #text/2 + 1 ), y )
  11.     mon.write( text )
  12.   else
  13.     term.setCursorPos( math.ceil( w/2 - #text/2 ), y )
  14.     term.write( text )
  15.   end
  16. end
  17.  
  18. mon.setTextColor( colors.green )
  19. writeCenter( "[Farminfo] ", 2, mon )
  20. mon.setTextColor( colors.yellow )
  21. writeCenter( "Geoffs Status:", 3, mon )
  22. mon.setTextColor( colors.red )
  23. writeCenter( "Not available", 4, mon )
  24.  
  25. mon.setBackgroundColor( colors.white )
  26. mon.setTextColor ( colors.black )
  27. writeCenter( "[Refresh]", 9, mon )
  28. writeCenter( "[Start Turtle]", 11, mon )
  29. mon.setBackgroundColor( colors.black )
  30. mon.setTextColor ( colors.white )
  31.  
  32. while true do
  33.     if yPos == 11 and xPos > 3 and xPos < 19 then
  34.         mon.setCursorPos(1,12)
  35.        
  36.         mon.write("Turtle wird gestartet!")
  37.     end
  38. end
Advertisement
Add Comment
Please, Sign In to add comment