Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- whitelist="Thor_schuss,ecco7777,Totoro7111,StonebubbleLP,Chrissi19961,papabass1988,DeathSkorpion,Websn,xkiller324,Valerius2101,16puma11,Lichtes"
- blacklist= ""
- side="back"
- function wrapPs(peripheralName)
- periTab={}
- sideTab={}
- if peripheralName==nil then
- print("Fehler")
- end
- local peripherals = peripheral.getNames()
- local i2 = 1
- for i =1, #peripherals do
- if peripheral.getType(peripherals[i])==peripheralName then
- periTab[i2]=peripheral.wrap(peripherals[i])
- sideTab[i2]=peripherals[i]
- i2=i2+1
- end
- end
- if periTab~={} then
- return periTab,sideTab
- else
- return nil
- end
- end
- function scan(s,mode)
- if mode==nil then
- mode="all"
- end
- if mode=="mob" or mode=="all" then
- mobs=s.getEntityIds("mob")
- for i=1, #mobs do
- data=nil
- data=s.getEntityData(mobs[i],"mob")
- if data~=nil then
- entity.mob[#entity.mob+1]=data.all()
- else
- entity.mob[#entity.mob+1]="lost"
- end
- end
- end
- if mode=="item" or mode=="all" then
- items=s.getEntityIds("item")
- for i=1, #items do
- data=nil
- data=s.getEntityData(items[i],"item")
- if data~=nil then
- entity.item[#entity.item+1]=data.all()
- else
- entity.item[#entity.item+1]="lost"
- end
- end
- end
- if mode=="player" or mode=="all" then
- players=s.getPlayers()
- for i=1, #players do
- data=nil
- data=s.getPlayerByName(players[i].name)
- if data~=nil then
- entity.player[#entity.player+1]=data.all()
- inv=entity.player[#entity.player].player.inventory
- for i2=1, 40 do
- if inv[i2]~=nil then
- fp=fs.open("temp","w")
- itemp=#entity.player
- i2temp=i2
- error=true
- fp.write("entity.player[itemp].player.inventory[i2temp]=inv[i2temp].all() error=false")
- fp.close()
- shell.run("temp")
- shell.run("rm temp")
- if error then
- entity.player[itemp].player.inventory[i2temp]=nil
- end
- end
- end
- else
- entity.player[#entity.player+1]="lost"
- end
- end
- end
- if mode=="minecart" or mode=="all" then
- minecarts=s.getEntityIds("minecart")
- for i=1, #minecarts do
- data=nil
- data=s.getEntityData(minecarts[i],"minecart")
- if data~=nil then
- entity.minecart[#entity.minecart+1]=data.all()
- else
- entity.minecart[#entity.minecart+1]="lost"
- end
- end
- end
- if mode=="frame" or mode=="all" then
- itemFrames=s.getEntityIds("item_frame")
- for i=1, #itemFrames do
- data=nil
- data=s.getEntityData(itemFrames[i],"item_frame")
- if data~=nil then
- entity.itemFrame[#entity.itemFrame+1]=data.all()
- else
- entity.itemFrame[#entity.itemFrame+1]="lost"
- end
- end
- end
- return entity
- end
- function string.cut(txt,char)
- while string.find(txt,char) do
- txt=string.sub(txt,1,string.find(txt,char)-1)..string.sub(txt,string.find(txt,char)+1,#txt)
- end
- return txt
- end
- function format(txt)
- txt=string.cut(txt,'\n')
- txt=string.cut(txt,'\r')
- txt=string.cut(txt,'\t')
- txt=string.cut(txt," ")
- txt=string.sub(txt,1,4000)
- return txt
- end
- function scanAll(mode)
- s=wrapPs("openperipheral_sensor")
- entity={}
- entity.item={}
- entity.mob={}
- entity.player={}
- entity.minecart={}
- entity.itemFrame={}
- for i42=1,#s do
- scan(s[i42],mode)
- term.clear()
- term.setCursorPos(1,1)
- term.write(math.floor(100/#s*i42).."%")
- end
- end
- while true do
- ownerOnline=false
- intruderOnline=false
- scanAll("player")
- for i=1,#entity.player do
- if string.find(whitelist,entity.player[i].name)~=nil then
- ownerOnline=true
- end
- 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
- intruderOnline=true
- end
- end
- if ownerOnline==false and intruderOnline then
- rs.setOutput(side,true)
- else
- rs.setOutput(side,false)
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement