Advertisement
NanoBob

(old) NanoGlasses

Sep 21st, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.03 KB | None | 0 0
  1. blackList={
  2. ["Doc_Jason"]=true,
  3. ["iTzBruin"]=true,
  4. }
  5. whiteList={
  6. ['darkbobo00']=true,
  7. ['dark_sjoerd']=true,
  8. ['Lekkerdie']=true,
  9. ['mastersnake20']=true,
  10. ['skye333']=true,
  11. }
  12.  
  13. local pcX=-910
  14. local pcZ=-1833
  15. local distances={}
  16. sensor=peripheral.wrap("left")
  17. monitor=peripheral.wrap("back")
  18. glasses=peripheral.wrap("right")
  19.  
  20.  
  21. while true do
  22.   for name,__ in pairs(blackList) do
  23.     data=sensor.getPlayerData(name)
  24.     if data~=nil then
  25.       local pos=data['position']
  26.       local x=pos['x']
  27.       local z=pos['z']
  28.       x=math.floor(pcX+x+0.5)
  29.       z=math.floor(pcZ+z+0.5)
  30.       distance=math.floor(math.sqrt((x-pcX)^2+(z-pcZ)^2)+0.5)
  31.       distances[name]={['x']=x,['z']=z,['d']=distance}
  32.       print(name.." : "..x..","..z..","..distance)
  33.     end
  34.   end
  35.   for name,__ in pairs(whiteList) do
  36.     data=sensor.getPlayerData(name)
  37.     if data~=nil then
  38.       local pos=data['position']
  39.       local x=pos['x']
  40.       local z=pos['z']
  41.       x=math.floor(pcX+x+0.5)
  42.       z=math.floor(pcZ+z+0.5)
  43.       distance=math.floor(math.sqrt((x-pcX)^2+(z-pcZ)^2)+0.5)
  44.       distances[name]={['x']=x,['z']=z,['d']=distance}
  45.       print(name.." : "..x..","..z..","..distance)
  46.     end
  47.   end
  48.  
  49.   local nameIndex=1
  50.   local monitorX,monitorY=monitor.getSize()
  51.   monitor.clear()
  52.   glasses.clear()
  53.   for name,information in pairs(distances) do
  54.     monitor.setCursorPos(1,nameIndex)
  55.     local x=information['x']
  56.     local z=information['z']
  57.     local distance=information['d']
  58.     if whiteList[name] then
  59.         monitor.setTextColor(8192)
  60.         glasses.addText(5,nameIndex*10,name..": "..x..","..z.."  Distance :"..distance,8192)
  61.     elseif blackList[name] then
  62.         monitor.setTextColor(16384)
  63.         glasses.addText(5,nameIndex*10,name..": "..x..","..z.."  Distance :"..distance,16384)
  64.     end
  65.     stringLength=glasses.getStringWidth(name..": "..x..","..z.."  Distance :"..distance)
  66.     glasses.addBox(0,10,stringLength+10,nameIndex*10,0.1,0.2)
  67.     name=string.sub(name,1,6)
  68.     monitor.write(name..": "..x..","..z.."  Distance :"..distance)
  69.     nameIndex=nameIndex+1
  70.   end
  71.   sleep(2)
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement