Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local rbt=component.proxy(component.list("robot")())
- local ns,nx,ny,nz,rm,rt,ma=0,0,0,0,rbt.move,rbt.turn,math.abs
- function id(a,b) return math.floor(a/b) end
- function n_u() if rm(1) then nz=nz+1 end end
- function n_d() if rm(0) then nz=nz-1 end end
- function n_f() if rm(3) then nx,ny=nx+(1-ns%2)*(1-2*id(ns,2)),ny+(ns%2)*(1-2*id(ns,2)) end end
- function n_r() rt(true); ns=(ns+1)%4 end
- function n_l() rt(false); ns=(ns+3)%4 end
- function t_t(is) local tf=n_l; if ((is-ns)+4)%4<2 then tf=n_r end while(ns~=is) do n_l() end end
- function n_t(x,y,z)
- local fz,dz,sx,dx,sy,dy=n_d,ma(z-nz),2,ma(x-nx),3,ma(y-ny)
- if z>nz then fz=n_u end
- for i=1,dz,1 do fz() end
- if x>nx then sx=0 end
- t_t(sx)
- for i=1,dx,1 do n_f() end
- if y>ny then sy=1 end
- t_t(sy)
- for i=1,dy,1 do n_f() end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement