mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 19:19:21 +01:00
1 line
2.9 KiB
Lua
1 line
2.9 KiB
Lua
local a,b,c,d,e,f,g,h,i,j=2,10,9,-100,{cobblestone=1,sandstone=1,stone=1,dirt=1,gravel=1,hardened_clay=1,nether_brick=1,sand=1,soul_sand=1,netherrack=1},{diamond_pickaxe=1,iron_pickaxe=1},math.abs,function(k)k=component.list(k)()return k and component.proxy(k)or nil end,function()return computer.energy()/computer.maxEnergy()end,function(table,l)return table[l]or table[l:gsub("minecraft:","")]end;local m,n,o,p=h("robot"),h("geolyzer"),h("inventory_controller"),h("generator")local q,r,s,t,u,v,w,x,y=0,0,0,0,m.inventorySize(),m.swing,m.select,n.scan,o.getStackInInternalSlot;local z,A=function(B)m.turn(B)t=t+(B and 1 or-1)t=t>3 and 0 or t<0 and 3 or t end,function(C)while true do local D,E=v(C)if D or E=="air"then D,E=m.move(C)if D then if C==0 or C==1 then r=r+(C==1 and 1 or-1)else q,s=q+(t==0 and 1 or t==2 and-1 or 0),s+(t==1 and 1 or t==3 and-1 or 0)end;break end else if E=="block"then while true do computer.beep(1500,1)end end end end end;local function F(G)local H=t-G;if H~=0 then local I=H>2;if H<=0 then I=-H<=2 end;while t~=G do z(I)end end end;local J,K=function(L,M,N)L,M,N=L-q,M-r,N-s;if M~=0 then for O=1,g(M)do A(M>0 and 1 or 0)end end;if L~=0 then F(L>0 and 0 or 2)for O=1,g(L)do A(3)end end;if N~=0 then F(N>0 and 1 or 3)for O=1,g(N)do A(3)end end end,function(P)local Q=0;for O=1,u do local R=y(O)if R then local S=j(e,R.name)if P and S or not P and not j(f,R.name)then w(O)m.drop(S and 0 or 3)Q=Q+1 end end end;return Q end;local function T()J(0,r,0)J(0,0,0)for O=0,3 do local U=o.getInventorySize(3)if U and U>3 then K()return else z(true)end end;K(true)end;w(1)A(0)local V=x(1,0)[33]for O=0,3 do if V>0 then if v(3)and x(1,0)[33]==0 then break end else if m.place(3)and x(1,0)[33]>0 then break end end;z(false)end;local W,X,Y,Z,_,a0,a1=0,0,0,1,1;for a2=1,c do a0,a1=W*8,X*8;J(a0,-1,a1)while true do local a3,a4,a5,a6,a7,a8=q,s,1,{},n.scan(a0-q,a1-s,-1,8,8,1)for a9=0,7 do for aa=0,7 do if a7[a5]>=a and a7[a5]<=b then table.insert(a6,a0+aa)table.insert(a6,a1+a9)elseif a7[a5]<-0.4 then a8=true end;a5=a5+1 end end;if#a6>0 then while#a6>0 do local ab,ac,ad=1,math.huge;for O=1,#a6,2 do ad=math.sqrt((a6[O]-q)^2+(a6[O+1]-s)^2)if ad<ac then ab,ac=O,ad end end;J(a6[ab],r,a6[ab+1])v(0)for O=1,2 do table.remove(a6,ab)end end else end;if p and p.count()==0 then for O=1,u do w(O)if p.insert()then break end end end;if m.durability()<=0.2 then for O=1,u do local R=y(O)if R and j(f,R.name)and R.damage/R.maxDamage<0.8 then w(O)o.equip()break end end end;local Q=0;for O=1,u do if m.count(O)==0 then Q=Q+1 end end;if Q<=1 then Q=Q+K(true)end;if Q<=3 or i()<=0.2 then local ae,af,ag,ah=q,r,s,t;T()if i()<=0.2 then while i()<0.99 do computer.pullSignal(1)end end;J(ae,af,ag)F(ah)end;if a8 or r<=d then break else A(0)end end;W,X=W+(Y==0 and 1 or Y==2 and-1 or 0),X+(Y==1 and 1 or Y==3 and-1 or 0)if(Y==0 or Y==2)and g(W)>=Z or(Y==1 or Y==3)and g(X)>=Z then _=_+1;if _>5 then Z,_=Z+1,1 else Y=Y+1;if Y>3 then Y=0 end end end end;T()F(0) |