Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- function getPSide(peripheralName)
- if peripheralName == nil then
- print("Fehler")
- end
- local peripherals = peripheral.getNames()
- local i = 1
- while i < #peripherals and peripheral.getType(peripherals[i]) ~= peripheralName do
- i = i + 1
- end
- if peripheral.getType(peripherals[i]) == peripheralName then
- return peripherals[i]
- else
- return nil
- end
- end
- end
- s=wrapPs("openperipheral_sensor")[1]
- function scan()
- entity={}
- entity.item={}
- entity.mob={}
- entity.player={}
- entity.minecart={}
- entity.itemFrame={}
- mobs=s.getEntityIds("mob")
- for i=1, #mobs do
- data=nil
- data=s.getEntityData(mobs[i],"mob")
- if data~=nil then
- entity.mob[i]=data.all()
- else
- entity.mob[i]="lost"
- end
- end
- items=s.getEntityIds("item")
- for i=1, #items do
- data=nil
- data=s.getEntityData(items[i],"item")
- if data~=nil then
- entity.item[i]=data.all()
- else
- entity.item[i]="lost"
- end
- end
- players=s.getPlayers()
- for i=1, #players do
- data=nil
- data=s.getPlayerByName(players[i].name)
- if data~=nil then
- entity.player[i]=data.all()
- inv=entity.player[i].player.inventory
- for i2=1, 40 do
- if inv[i2]~=nil then
- fp=fs.open("temp","w")
- itemp=i
- 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[i]="lost"
- end
- end
- minecarts=s.getEntityIds("minecart")
- for i=1, #minecarts do
- data=nil
- data=s.getEntityData(minecarts[i],"minecart")
- if data~=nil then
- entity.minecart[i]=data.all()
- else
- entity.minecart[i]="lost"
- end
- end
- 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[i]=data.all()
- else
- entity.itemFrame[i]="lost"
- 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
- scanned=scan()
- content=""
- term.clear()
- term.setCursorPos(1,1)
- for i=1,#scanned.mob do
- content=content..", "..scanned.mob[i].name
- end
- print(content)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement