xXm0dzXx

Untitled

Nov 9th, 2014
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. currentScroll = 0;
  2. turtles = 0;
  3. tIds = {}
  4.  
  5. function clear()
  6. term.clear()
  7. term.setCursorPos(1, 1)
  8. end
  9.  
  10. function writeIn(x, y, text)
  11. local i,j = term.getSize()
  12. --if y < j then
  13. term.setCursorPos(x, y)
  14. write(text);
  15. --end
  16. end
  17.  
  18. function draw()
  19. local x,y = term.getSize()
  20.  
  21. clear()
  22. local posX, posY, posZ = gps.locate();
  23. print("Turtle Manager (#" .. os.getComputerID() .. ") (" .. turtles .. ")");
  24. rednet.open("top")
  25. for i = 0, x do
  26. term.setCursorPos(i,2)
  27. write("-")
  28. end
  29.  
  30. for i = 0, turtles do
  31. --writeIn(1, 3 + (i + currentScroll) % (y - 2), "#" .. index);
  32. writeIn(1, 3 + i, tIds[i .."name"] .. "(#" ..tIds[i]..")")
  33. end
  34.  
  35. currentScroll = (currentScroll + 1);
  36. end
  37.  
  38. function string:split( inSplitPattern, outResults )
  39. if not outResults then
  40. outResults = { }
  41. end
  42. local theStart = 1
  43. local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
  44. while theSplitStart do
  45. table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) )
  46. theStart = theSplitEnd + 1
  47. theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
  48. end
  49. table.insert( outResults, string.sub( self, theStart ) )
  50. return outResults
  51. end
  52.  
  53.  
  54. while true do
  55. local id, message = rednet.receive(1)
  56. if(message ~= nil) then
  57. local sMessage = message:split(":")
  58.  
  59. if(sMessage[0] == "ayylmao") then
  60. local isNew = true;
  61. for i = 0, turtles do
  62. if(tIds[i] == id) then
  63. isNew = false;
  64. end
  65. end
  66. if(isNew)then
  67. tIds[turtles] = id;
  68. tIds[turtles .. "label"] = sMessage[1]
  69. turtles = turtles + 1;
  70. end
  71. end
  72. end
  73. draw(id, message)
  74. end
Advertisement
Add Comment
Please, Sign In to add comment