Advertisement
opencomputerstest2

xray.lua

Apr 29th, 2024
1,035
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.99 KB | None | 0 0
  1. local a={...}local b=a[1]if not b or b==""then error("use: find blockname")end;local c=tonumber(a[2])local d=a[3]if d=="nil"then d=b end;if type(d)~="string"or d==""then d=nil end;local e=tonumber(a[4])if not e or e==""then e=nil end;local f=0.5;local g=true;local h=colors.green;local i=peripheral.find("neuralInterface")assert(i,"missing Neural Interface")assert(i.canvas,"Missing overlay goggles")assert(i.scan,"Missing block scanner")local j=i.canvas()local k=i.canvas3d()j.clear()local l=function()local m=j.addRectangle(0,0,60,20)local n=j.addText({2,6},"")m.setAlpha(122)m.setColor(0,0,0)local function o(p)local q=function(r,s,t)return math.sqrt(r^2+s^2+t^2)end;local u={}for v,w in pairs(p)do u[v]=q(w.x,w.y,w.z)end;local x=math.min(table.unpack(u))local y;local z;for v,w in pairs(p)do if q(w.x,w.y,w.z)==x then y=w;z=v;break end end;return y,z end;local function A(B)local C,D,E=term.getPaletteColor(B)return C*255,D*255,E*255 end;local F;local G;local H=function()local r,s,t=gps.locate(0.2)if r then G={-(r%1-0.5),-(s%1-0.5),-(t%1-0.5)}else G=nil end end;local I=function()F=i.scan()end;while true do parallel.waitForAll(H,I)k.clear()local J={}for v,w in pairs(F)do if type(c)=="number"then if w.name==b and w.metadata==c then table.insert(J,w)end else if w.name==b then table.insert(J,w)end end end;if not next(J)then J='no block "'..b..'" was found'end;do local w,K,L,M,N,O,P;if type(J)~="string"then local Q;if G then Q=k.create(G)else Q=k.create()end;local R=Q.addFrame(vector.new())w,P=o(J)K,L,M=tostring(w.x),tostring(w.y),tostring(w.z)N=K.." "..L.." "..M;O=b.." found at: "..N;for v,w in pairs(J)do if v~=P or not g then local S=R.addItem({w.x,w.y,w.z},d or b)end end;local S=R.addItem({w.x,w.y,w.z},d or b)if g then local T=Q.addBox(w.x-0.6,w.y-0.6,w.z-0.6,1.2,1.2,1.2)T.setDepthTested(false)T.setColor(A(h))T.setAlpha(64)end;R.setDepthTested(false)else O=J end;m.setSize(#O*5+2,20)n.setText(O)end;sleep(f or 0.5)end end;local U,V=pcall(l)if j then j.clear()end;if k then k.clear()end;if not U then error(V,0)end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement