xXm0dzXx

Untitled

Nov 9th, 2014
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 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. if(tIds[i] ~= nil) then
  33. writeIn(1, 3 + i, tIds[i .."name"] .. "(#" ..tIds[i]..")")
  34. end
  35. end
  36.  
  37. currentScroll = (currentScroll + 1);
  38. end
  39.  
  40. function string:split( inSplitPattern, outResults )
  41. if not outResults then
  42. outResults = { }
  43. end
  44. local theStart = 1
  45. local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
  46. while theSplitStart do
  47. table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) )
  48. theStart = theSplitEnd + 1
  49. theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
  50. end
  51. table.insert( outResults, string.sub( self, theStart ) )
  52. return outResults
  53. end
  54.  
  55.  
  56. while true do
  57. local id, message = rednet.receive(1)
  58. if(message ~= nil) then
  59. local sMessage = message:split(":")
  60.  
  61. if(sMessage[0] == "ayylmao") then
  62. local isNew = true;
  63. for i = 0, turtles do
  64. if(tIds[i] == id) then
  65. isNew = false;
  66. end
  67. end
  68. if(isNew)then
  69. tIds[turtles] = id;
  70. tIds[turtles .. "label"] = sMessage[1]
  71. turtles = turtles + 1;
  72. end
  73. end
  74. end
  75. draw(id, message)
  76. end
Advertisement
Add Comment
Please, Sign In to add comment