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
- end
- function scan(s)
- 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 eval(command)
- fp=fs.open("eval","w")
- fp.writeLine(command)
- fp.close()
- shell.run("eval")
- shell.run("rm eval")
- end
- s=wrapPs("openperipheral_sensor")
- p=wrapPs("openperipheral_bridge")
- g=p[1]
- g.clear()
- function showGrid()
- local x=0
- local y=0
- g.clear()
- while y<=1000 do
- while x<=1000 do
- g.addText(x+1,1,x,0)
- x=x+50
- end
- g.addText(1,y+1,y,0)
- y=y+10
- end
- g.sync()
- end
- function showPlayerInfo()
- scan(s[1])
- local y=1
- local i
- g.clear()
- if #entity.player>0 then
- for i=1,#entity.player do
- local player=entity.player[i]
- if player.living.lookingAt==nil then
- player.living.lookingAt={}
- player.living.lookingAt.position={x=0,y=0,z=0}
- end
- content={player.position.x, player.position.y, player.position.z, player.living.yaw, player.living.pitch, player.living.lookingAt.position.x, player.living.lookingAt.position.y, player.living.lookingAt.position.z}
- for ic=1,#content do
- g.addText(1,y,content[ic],0)
- y=y+10
- end
- end
- g.sync()
- end
- end
- function getPositions()
- scan(s[1])
- pVec={}
- pLookVec={}
- pXAngle={}
- pYAngle={}
- for i=1, #entity.player do
- player=entity.player[i]
- pVec[i]=vector.new(player.position.x, player.position.y, player.position.z)
- pLookVec[i]=vector.new(player.living.lookingAt.position.x, player.living.lookingAt.position.y, player.living.lookingAt.position.z)
- pXAngle[i]=player.living.yaw
- pYAngle[i]=player.living.pitch
- end
- obj=vector.new(0,2,0)
- end
- function setScreenSize(x,y)
- screenX=x
- screenY=y
- end
- function showObj()
- g.clear()
- getPositions()
- objY=screenY/2
- U=pVec[1]
- O=obj
- UO=O:sub(U)
- UU=U:sub(vector.new(math.cos(pXAngle[1])*U.x,U.y,math.sin(pXAngle[1])*U.z))
- alpha=math.acos((UO:cross(UU))/(UO:length()*UU:length()))
- beta=180-(alpha+90)
- OO=O:sub(vector.new(math.cos(beta)*O.x,O.y,math.sin(beta)*O.z))
- --objX=
- end
- function test()
- setScreenSize(950,490)
- getPositions()
- showObj()
- end
- function main()
- while true do
- showPlayerInfo()
- sleep(0)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement