Advertisement
Guest User

pt

a guest
Aug 27th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.50 KB | None | 0 0
  1. os.loadAPI("button")
  2. scanner=peripheral.wrap("back")
  3. monitor=peripheral.wrap("monitor_11")
  4. bridge=peripheral.wrap("right")
  5.  
  6. local players={"UnstoppableN","theonlyraellol"}
  7. local args={...}
  8. local pos={0,0,0}
  9. player=args[1]
  10. ypos=1
  11. maxLines=39;
  12. startX=3827
  13. startY=60
  14. startZ=-1285
  15. buttonXstart=5
  16. buttonXsize=20
  17. buttonYstart=5
  18. buttonYsize=5
  19. counter=1
  20.  
  21.  
  22. function newWrite(text)
  23.         monitor.setCursorPos(1,ypos)
  24.         monitor.write(tostring(text))
  25.         ypos=ypos+1
  26.         if(ypos>maxLines) then
  27.                 read()
  28.                 monitor.clear()
  29.                 ypos=0
  30.         end
  31.        
  32. end
  33.  
  34. function checkPlayer()
  35.         if(player==nil) then
  36.                 print("What is the player's name? ")
  37.                 player=read()
  38.         end
  39. end
  40.  
  41. function postition(content)
  42.                    
  43.                                 for x,y in pairs(content) do
  44.                                         if(x=="x") then
  45.                                                 y=y+startX
  46.                                         elseif(x=="y") then
  47.                                                 y=y+startY
  48.                                         elseif(x=="z") then
  49.                                                 y=y+startZ
  50.                                         end
  51.                                            y=math.floor(y)
  52.                                                                        newWrite(x.." "..tostring(y))
  53.                                         pos[counter]=y
  54.           counter=counter+1
  55.                                 end
  56.                                
  57. end
  58.  
  59. function mainShort()
  60.         monitor.clear()
  61.    
  62.        monitor.setCursorPos(1,1)
  63.         checkPlayer()
  64.  
  65.         --print("Searching data for:" .. player)
  66.         data=scanner.getPlayerData(player)
  67.  
  68.         if not (data == nil) then
  69.  
  70.                 for key,content in pairs(data) do
  71.                        
  72.                         if(key=="position") then
  73.                                 postition(content)
  74.                                counter=1
  75.                         end
  76.                 end
  77.         else
  78.                 newWrite("player "..player.." not found")
  79.         end
  80.  
  81. end
  82.  
  83.  
  84. function main()
  85.         monitor.clear()
  86.          
  87.         checkPlayer()
  88.          
  89.         print("Searching data for:" .. player)
  90.         data=scanner.getPlayerData(player)
  91.          
  92.         if not (data== nil) then
  93.                 for key,content in pairs(data) do
  94.                        
  95.                         if(key=="position") then
  96.                                 postition(content)
  97.                                 counter=1
  98.                         elseif(type(content)=="table") then
  99.                                
  100.                                 for x,y in pairs(content) do
  101.                                         if(type(y)=="table") then      
  102.                                                 for a,b in pairs(y) do
  103.                                                         if(type(b) == "table") then
  104.                                                                 for c,d in pairs(b) do
  105.                                                                         newWrite(c.." " ..tostring(d))
  106.                                                                 end
  107.                                                         else
  108.                                                                 newWrite(a.." "..tostring(b))
  109.                                                         end
  110.                                                 end
  111.                                         else
  112.                                                 newWrite(x.." "..tostring(y))
  113.                                         end
  114.                                 end
  115.                         else
  116.                                 newWrite(key.." "..tostring(content))
  117.                         end
  118.                 end
  119.         else
  120.                 newWrite("Player "..player.." not found")
  121.         end
  122. end
  123.  
  124. function fillTable()
  125. for i=1,#players do
  126.  
  127. button.setTable(players[i], test, buttonXstart, buttonXstart+buttonXsize, buttonYstart, buttonYsize)
  128. buttonYstart=buttonYstart+buttonYsize
  129. end
  130. button.screen()
  131. end
  132.  
  133. function test()
  134. print("hello world!")
  135. end
  136.  
  137. function listPlayers()
  138. button.heading("test")
  139. end
  140.  
  141.  
  142.  function tracking()
  143.      while true do
  144.   ypos=1
  145.      mainShort()
  146.      sleep(3)
  147.      bridge.clear()
  148.          for i=1,3 do
  149. bridge.addBox(1, 1, 60, 40, 0xFFFF00, 0.2)       
  150. bridge.addText(5, 0+i*10,pos[i], 0x000000)
  151.          end
  152.      end
  153.  end
  154. --executed code
  155. --fillTable()
  156. --listPlayers()
  157. --screen()
  158. --mainShort()
  159. tracking()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement