Humenius

Untitled

Dec 13th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.32 KB | None | 0 0
  1. event, side, xPos, yPos = os.pullEvent("monitor_touch") --Touch Screen Grab
  2. mside = "left" -- Modem side
  3. side = "back" -- Monitor side
  4. tID = 1840 -- Geoffs ID
  5. timeout = 600 -- Standby bis Turtle von alleine arbeitet (Default: 600s)
  6. ftimeout = timeout -- Wichtig fuer for-Schleife !!DONT EDIT!!
  7.  
  8. -- Initialisierung des Modems + Monitors
  9. mon = peripheral.wrap( side )
  10. modem = peripheral.wrap ( mside )
  11. peripheral.call( side, "clear" )
  12. rednet.open( "right" )
  13.  
  14. -- Check, ob channel 421 offen
  15. if not modem.isOpen( 421 ) then
  16.     modem.open( 421 )
  17. end
  18.  
  19. function writeCenter(text, y, mon)
  20.   local w, h = mon.getSize() or term.getSize()
  21.   if mon then
  22.     mon.setCursorPos( math.ceil( w/2 - #text/2 + 1 ), y )
  23.     mon.write( text )
  24.   else
  25.     term.setCursorPos( math.ceil( w/2 - #text/2 ), y )
  26.     term.write( text )
  27.   end
  28. end
  29.  
  30. function drawGUI()
  31.   peripheral.call( side, "clear" )
  32.   mon.setTextColor( colors.green )
  33.   writeCenter( "[Farminfo] ", 2, mon )
  34.   mon.setTextColor( colors.yellow )
  35.   writeCenter( "Geoffs Status:", 3, mon )
  36.   mon.setTextColor( colors.red )
  37.   writeCenter( "Not available", 4, mon )
  38.  
  39.   mon.setBackgroundColor( colors.white )
  40.   mon.setTextColor ( colors.black )
  41.   writeCenter( "[Refresh]", 9, mon )
  42.   writeCenter( "[Start Turtle]", 11, mon )
  43.   mon.setBackgroundColor( colors.black )
  44.   mon.setTextColor ( colors.white )
  45. end
  46.  
  47. --[[function checkFarmStart()
  48.   while true do
  49.     if yPos == 11 and xPos > 3 and xPos < 19 then
  50.       mon.setTextColor( colors.yellow )
  51.       writeCenter( "Unterwegs zur Farm", 4, mon )
  52.  
  53.       mon.setTextColor( colors.white )
  54.       writeCenter( "Turtle wurde", 6, mon )
  55.       writeCenter( "gestartet!", 7, mon )
  56.       rednet.send( tID, "start" )
  57.       sleep(5)
  58.  
  59.       writeCenter( "", 6, mon )
  60.       writeCenter( "", 7, mon )
  61.       --goto restart
  62.       return true
  63.       break
  64.     end
  65.   end
  66. end]]--
  67.  
  68.  
  69. drawGUI()
  70. sleep(5)
  71.  
  72. ::continue::
  73. while true do
  74.  
  75.     if yPos == 11 and xPos > 3 and xPos < 19 or timeout == 0 then
  76.     timeout = ftimeout
  77.     mon.setTextColor( colors.yellow )
  78.     writeCenter( "Unterwegs zur Farm", 4, mon )
  79.  
  80.     mon.setTextColor( colors.white )
  81.         writeCenter( "Turtle wurde", 6, mon )
  82.     writeCenter( "gestartet!", 7, mon )
  83.         sleep(5)
  84.  
  85.     writeCenter( "", 6, mon )
  86.     writeCenter( "", 7, mon )
  87.  
  88.   --if checkFarmStart() then
  89.  
  90.     rednet.send( tID, "start" )
  91.     id, msg, dist = rednet.receive()
  92.     if msg == "arrived" then
  93.       mon.setTextColor( colors.yellow )
  94.       writeCenter( "Farmt", 4, mon )
  95.     elseif msg == "back" then
  96.       mon.setTextColor( colors.yellow )
  97.       writeCenter( "Faehrt zurueck", 4, mon )
  98.     elseif msg == "store" then
  99.       mon.setTextColor( colors.yellow )
  100.       writeCenter( "Lagere Items in Chest", 4, mon )
  101.     elseif msg == "end" then
  102.       mon.setTextColor( colors.lime )
  103.       writeCenter( "Fahrt beendet", 4, mon )
  104.       mon.setTextColor( colors.yellow )
  105.       for i=1, ftimeout do
  106.         if timeout == 0 then
  107.           rednet.send( tID, "start" )
  108.           break
  109.           --goto continue
  110.         else
  111.           if timeout == 0 then
  112.           --  goto continue
  113.           end
  114.           writeCenter( "Turtle auf Standby", 5, mon)
  115.           writeCenter( "("..timeout.." s)", 6, mon)
  116.           timeout = timeout - 1
  117.           sleep(1)
  118.         end
  119.       end
  120.     end
  121.   end
  122. end
  123.  
  124. goto continue
Add Comment
Please, Sign In to add comment