Advertisement
Tribble1991

Travelhub Control

Aug 1st, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Variables --
  2. local mouseWidth = 0
  3. local mouseHeight = 0
  4.  
  5. local currentDestination = "None"
  6. local currentPlayer = "None"
  7.  
  8. local Turtle = 3
  9.  
  10. --Set turtle connection --
  11. rednet.open("bottom")
  12.  
  13. --Set monitor properties
  14. local monitor = peripheral.wrap("back")
  15. monitor.setBackgroundColor(colors.black)
  16. monitor.clear()
  17.  
  18. function setcurrentDestinationData()
  19. --Write first list of destinations
  20.     monitor.setCursorPos(2,2)
  21.     if currentDestination == "Tribble" then
  22.         monitor.setBackgroundColor((colors.green))
  23.     else
  24.         monitor.setBackgroundColor((colors.red))
  25.     end
  26.     monitor.write("  Tribble         ")
  27.  
  28.     monitor.setCursorPos(2,4)
  29.     if currentDestination == "PietervBerkel" then
  30.         monitor.setBackgroundColor((colors.green))
  31.     else
  32.         monitor.setBackgroundColor((colors.red))
  33.     end
  34.     monitor.write("  PietervBerkel   ")
  35.  
  36.  
  37.     monitor.setCursorPos(2,6)
  38.     if currentDestination == "Razyr" then
  39.         monitor.setBackgroundColor((colors.green))
  40.     else
  41.         monitor.setBackgroundColor((colors.red))
  42.     end
  43.     monitor.write("  Razyr           ")
  44.  
  45.     monitor.setCursorPos(2,8)
  46.     if currentDestination == "GrooteMoeite" then
  47.         monitor.setBackgroundColor((colors.green))
  48.     else
  49.         monitor.setBackgroundColor((colors.red))
  50.     end
  51.     monitor.write("  GrooteMoeite    ")
  52.  
  53.     monitor.setCursorPos(2,10)
  54.     if currentDestination == "Louw" then
  55.         monitor.setBackgroundColor((colors.green))
  56.         else
  57.         monitor.setBackgroundColor((colors.red))
  58.     end
  59.     monitor.write("  Louw            ")
  60.  
  61.     monitor.setCursorPos(2,12)
  62.     if currentDestination == "Ace_Of_Knaves" then
  63.         monitor.setBackgroundColor((colors.green))
  64.         else
  65.         monitor.setBackgroundColor((colors.red))
  66.     end
  67.     monitor.write("  Ace_Of_Knaves   ")
  68.  
  69.     monitor.setCursorPos(2,14)
  70.     if currentDestination == "None" then
  71.         monitor.setBackgroundColor((colors.green))
  72.         else
  73.         monitor.setBackgroundColor((colors.red))
  74.     end
  75.     monitor.write("  None           ")
  76. end
  77.  
  78. -- Perform clicked action --
  79. function checkClickPosition()
  80.     -- 1st Row --
  81.     if(mouseWidth > 1 and mouseWidth < 20 and mouseHeight == 2) then
  82.         currentDestination = "Tribble"
  83.         setcurrentDestinationData()    
  84.         sendTurtleMessage(1)
  85.     -- 1st Row --
  86.     elseif(mouseWidth > 1 and mouseWidth < 20 and mouseHeight == 4) then
  87.         currentDestination = "PietervBerkel"
  88.         setcurrentDestinationData()    
  89.         sendTurtleMessage(2)
  90.     -- 1st Row --
  91.     elseif(mouseWidth > 1 and mouseWidth < 20 and mouseHeight == 6) then
  92.         currentDestination = "Razyr"
  93.         setcurrentDestinationData()    
  94.         sendTurtleMessage(3)
  95.     -- 2nd Row --
  96.     elseif(mouseWidth > 1 and mouseWidth < 20 and mouseHeight == 8) then
  97.         currentDestination = "GrooteMoeite"
  98.         setcurrentDestinationData()
  99.         sendTurtleMessage(4)   
  100.     -- 3rd Row --
  101.     elseif(mouseWidth > 1 and mouseWidth < 20 and mouseHeight == 10) then
  102.         currentDestination = "Louw"
  103.         setcurrentDestinationData()
  104.         sendTurtleMessage(5)       
  105.     -- 4th Row --
  106.     elseif(mouseWidth > 1 and mouseWidth < 20 and mouseHeight == 12) then
  107.         currentDestination = "Ace_Of_Knaves"
  108.         setcurrentDestinationData()
  109.         sendTurtleMessage(6)   
  110.     -- 5th Row --
  111.     elseif(mouseWidth > 1 and mouseWidth < 20 and mouseHeight == 14) then
  112.         currentDestination = "None"
  113.         setcurrentDestinationData()
  114.         sendTurtleMessage(7)
  115.     end
  116.  
  117.     sleep(5)
  118.     currentDestination = "None"
  119.     setcurrentDestinationData()
  120. end
  121.  
  122. -- Send message --
  123. function sendTurtleMessage(Message)
  124.     rednet.send(Turtle,Message)
  125. end
  126.  
  127. --First time data setup --
  128. setcurrentDestinationData()
  129.  
  130.  
  131. function monitorActivities()
  132.     event,p1,p2,p3 = os.pullEvent()
  133.     if event == "monitor_touch" then
  134.         mouseWidth = p2
  135.         mouseHeight = p3
  136.         checkClickPosition()
  137.     end    
  138. end
  139.  
  140. repeat
  141.     monitorActivities()
  142. until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement