Advertisement
Guest User

test

a guest
Jun 24th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.64 KB | None | 0 0
  1. whitelist="Thor_schuss,ecco7777,Totoro7111,StonebubbleLP,Chrissi19961,papabass1988,DeathSkorpion,Websn,xkiller324,Valerius2101,16puma11,Lichtes"
  2. blacklist= ""
  3.  
  4.  
  5. side="back"
  6. function wrapPs(peripheralName)
  7. periTab={}
  8. sideTab={}
  9. if peripheralName==nil then
  10. print("Fehler")
  11. end
  12. local peripherals = peripheral.getNames()
  13. local i2 = 1
  14. for i =1, #peripherals do
  15. if peripheral.getType(peripherals[i])==peripheralName then
  16. periTab[i2]=peripheral.wrap(peripherals[i])
  17. sideTab[i2]=peripherals[i]
  18. i2=i2+1
  19. end
  20. end
  21. if periTab~={} then
  22. return periTab,sideTab
  23. else
  24. return nil
  25. end
  26. end
  27.  
  28. function scan(s,mode)
  29. if mode==nil then
  30. mode="all"
  31. end
  32.  
  33. if mode=="mob" or mode=="all" then
  34. mobs=s.getEntityIds("mob")
  35. for i=1, #mobs do
  36. data=nil
  37. data=s.getEntityData(mobs[i],"mob")
  38. if data~=nil then
  39. entity.mob[#entity.mob+1]=data.all()
  40. else
  41. entity.mob[#entity.mob+1]="lost"
  42. end
  43. end
  44. end
  45.  
  46. if mode=="item" or mode=="all" then
  47. items=s.getEntityIds("item")
  48. for i=1, #items do
  49. data=nil
  50. data=s.getEntityData(items[i],"item")
  51. if data~=nil then
  52. entity.item[#entity.item+1]=data.all()
  53. else
  54. entity.item[#entity.item+1]="lost"
  55. end
  56. end
  57. end
  58.  
  59. if mode=="player" or mode=="all" then
  60. players=s.getPlayers()
  61. for i=1, #players do
  62. data=nil
  63. data=s.getPlayerByName(players[i].name)
  64. if data~=nil then
  65. entity.player[#entity.player+1]=data.all()
  66. inv=entity.player[#entity.player].player.inventory
  67. for i2=1, 40 do
  68. if inv[i2]~=nil then
  69. fp=fs.open("temp","w")
  70. itemp=#entity.player
  71. i2temp=i2
  72. error=true
  73. fp.write("entity.player[itemp].player.inventory[i2temp]=inv[i2temp].all() error=false")
  74. fp.close()
  75. shell.run("temp")
  76. shell.run("rm temp")
  77. if error then
  78. entity.player[itemp].player.inventory[i2temp]=nil
  79. end
  80. end
  81. end
  82. else
  83. entity.player[#entity.player+1]="lost"
  84. end
  85. end
  86. end
  87.  
  88. if mode=="minecart" or mode=="all" then
  89. minecarts=s.getEntityIds("minecart")
  90. for i=1, #minecarts do
  91. data=nil
  92. data=s.getEntityData(minecarts[i],"minecart")
  93. if data~=nil then
  94. entity.minecart[#entity.minecart+1]=data.all()
  95. else
  96. entity.minecart[#entity.minecart+1]="lost"
  97. end
  98. end
  99. end
  100.  
  101. if mode=="frame" or mode=="all" then
  102. itemFrames=s.getEntityIds("item_frame")
  103. for i=1, #itemFrames do
  104. data=nil
  105. data=s.getEntityData(itemFrames[i],"item_frame")
  106. if data~=nil then
  107. entity.itemFrame[#entity.itemFrame+1]=data.all()
  108. else
  109. entity.itemFrame[#entity.itemFrame+1]="lost"
  110. end
  111. end
  112. end
  113.  
  114. return entity
  115. end
  116.  
  117. function string.cut(txt,char)
  118. while string.find(txt,char) do
  119. txt=string.sub(txt,1,string.find(txt,char)-1)..string.sub(txt,string.find(txt,char)+1,#txt)
  120. end
  121. return txt
  122. end
  123.  
  124.  
  125. function format(txt)
  126. txt=string.cut(txt,'\n')
  127. txt=string.cut(txt,'\r')
  128. txt=string.cut(txt,'\t')
  129. txt=string.cut(txt," ")
  130. txt=string.sub(txt,1,4000)
  131. return txt
  132. end
  133.  
  134. function scanAll(mode)
  135.     s=wrapPs("openperipheral_sensor")
  136.     entity={}
  137.     entity.item={}
  138.     entity.mob={}
  139.     entity.player={}
  140.     entity.minecart={}
  141.     entity.itemFrame={}
  142.         for i42=1,#s do
  143.             scan(s[i42],mode)
  144.  
  145.             term.clear()
  146.             term.setCursorPos(1,1)
  147.             term.write(math.floor(100/#s*i42).."%")
  148.         end
  149. end
  150.  
  151.  
  152.  
  153. while true do
  154. ownerOnline=false
  155. intruderOnline=false
  156. scanAll("player")
  157.     for i=1,#entity.player do
  158.         if string.find(whitelist,entity.player[i].name)~=nil then
  159.             ownerOnline=true
  160.         end
  161.        
  162.         if string.find(whitelist,entity.player[i].name)==nil and string.find(blacklist,entity.player[i].name)~=nil or #blacklist==0 and  string.find(whitelist,entity.player[i].name)==nil then
  163.             intruderOnline=true
  164.         end
  165.     end
  166.         if ownerOnline==false and intruderOnline then
  167.         rs.setOutput(side,true)
  168.         else
  169.         rs.setOutput(side,false)
  170.         end
  171.         sleep(1)
  172. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement