ecco7777

CC Sensor Scan function

Mar 9th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.10 KB | None | 0 0
  1. s=peripheral.wrap("left")
  2.  
  3. function scan()
  4. entity={}
  5. entity.item={}
  6. entity.mob={}
  7. entity.player={}
  8. entity.minecart={}
  9. entity.itemFrame={}
  10.  
  11. mobs=s.getEntityIds("mob")
  12. for i=1, #mobs do
  13. data=nil
  14. data=s.getEntityData(mobs[i],"mob")
  15. if data~=nil then
  16. entity.mob[i]=data.all()
  17. else
  18. entity.mob[i]="lost"
  19. end
  20. end
  21.  
  22. items=s.getEntityIds("item")
  23. for i=1, #items do
  24. data=nil
  25. data=s.getEntityData(items[i],"item")
  26. if data~=nil then
  27. entity.item[i]=data.all()
  28. else
  29. entity.item[i]="lost"
  30. end
  31. end
  32.  
  33. players=s.getPlayers()
  34. for i=1, #players do
  35. data=nil
  36. data=s.getPlayerByName(players[i].name)
  37. if data~=nil then
  38. entity.player[i]=data.all()
  39. inv=entity.player[i].player.inventory
  40. for i2=1, 40 do
  41. if inv[i2]~=nil then
  42. fp=fs.open("temp","w")
  43. itemp=i
  44. i2temp=i2
  45. error=true
  46. fp.write("entity.player[itemp].player.inventory[i2temp]=inv[i2temp].all() error=false")
  47. fp.close()
  48. shell.run("temp")
  49. shell.run("rm temp")
  50. if error then
  51. entity.player[itemp].player.inventory[i2temp]=nil
  52. end
  53. end
  54. end
  55. else
  56. entity.player[i]="lost"
  57. end
  58. end
  59.  
  60. minecarts=s.getEntityIds("minecart")
  61. for i=1, #minecarts do
  62. data=nil
  63. data=s.getEntityData(minecarts[i],"minecart")
  64. if data~=nil then
  65. entity.minecart[i]=data.all()
  66. else
  67. entity.minecart[i]="lost"
  68. end
  69. end
  70.  
  71. itemFrames=s.getEntityIds("item_frame")
  72. for i=1, #itemFrames do
  73. data=nil
  74. data=s.getEntityData(itemFrames[i],"item_frame")
  75. if data~=nil then
  76. entity.itemFrame[i]=data.all()
  77. else
  78. entity.itemFrame[i]="lost"
  79. end
  80. end
  81.  
  82. return entity
  83. end
  84.  
  85. function string.cut(txt,char)
  86. while string.find(txt,char) do
  87. txt=string.sub(txt,1,string.find(txt,char)-1)..string.sub(txt,string.find(txt,char)+1,#txt)
  88. end
  89. return txt
  90. end
  91.  
  92. function format(txt)
  93. txt=string.cut(txt,'\n')
  94. txt=string.cut(txt,'\r')
  95. txt=string.cut(txt,'\t')
  96. txt=string.cut(txt," ")
  97. txt=string.sub(txt,1,4000)
  98. return txt
  99. end
  100.  
  101. --txr=textutils.serialise(scan())
  102. scan()
  103. for i=1,#entity.player do
  104. text=format(textutils.serialize(entity.player[i].player))
  105. a=http.post("http://www.gecco34.bplaced.net/Stuff/filewriter.php?message="..text.."&file=./scanner/"..entity.player[i].name..".txt")
  106. print(a)
  107. end
Add Comment
Please, Sign In to add comment