Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.71 KB | None | 0 0
  1.     CIncX=colors.yellow    
  2.     CDecX=colors.blue
  3.     CIncMX=colors.white
  4.     CDecMX=colors.red
  5.     DispX=0
  6.     CIncY=colors.cyan
  7.     CDecY=colors.green  
  8.     CIncMY=colors.purple
  9.     CDecMY=colors.magenta
  10.     DispY=0
  11.     CIncZ=colors.orange
  12.     CDecZ=colors.lightBlue
  13.     CIncMZ=colors.gray
  14.     CDecMZ=colors.black
  15.     DispZ=0
  16.     PWR=colors.brown
  17.     MULInc=colors.pink
  18.     MULDec=colors.lime
  19.     interval = 0.2
  20.     Side="bottom"
  21.     MUL=0
  22.     function resetDir()
  23.         impulse(63,CDecX)
  24.         impulse(63,CDecMX)
  25.         impulse(63,CDecY)
  26.         impulse(63,CDecMY)
  27.         impulse(63,CDecZ)
  28.         impulse(63,CDecMZ)
  29.         impulse(24,MULDec)
  30.     end
  31.     function ChDir()
  32.         local sx=""
  33.         local sy=""
  34.         local sz=""
  35.         print("X")
  36.         DispX=read()
  37.         print("Y")
  38.         DispY=read()
  39.         print("Z")
  40.         DispZ=read()
  41.         print("M")
  42.         MUL=read()
  43.         SetDir()
  44.     end
  45. function SetDir()
  46.     local CSum=0
  47.     if abs(BuffX)>abs(BuffY) then n=abs(BuffX) else n=abs(BuffY)
  48.     if n<abs(BuffZ) then n=abs(BuffZ)
  49.         if BuffX>0 and DispX<0 then impulse(DispX,CDecX)
  50.         if BuffX<0 and DispX>0 then impulse(DispX,CDecMX)
  51.         if BuffY>0 and DispY<0 then impulse(DispY,CDecY)
  52.         if BuffY<0 and DispY>0 then impulse(DispY,CDecMY)
  53.         if BuffZ>0 and DispZ<0 then impulse(DispZ,CDecZ)
  54.         if BuffZ<0 and DispZ>0 then impulse(DispZ,CDecMZ)
  55.         x=BuffX
  56.         y=BuffY
  57.         z=BuffZ
  58.         for j = 1,n do
  59.            
  60.             if x>DispX and BuffX<0 then begin CSum=Csum+CDecMX x=x-1 end
  61.             if x<DispX and BuffX<0 then begin CSum=Csum+CIncMX x=x+1 end
  62.             if x>DispX and BuffX>0 then begin CSum=Csum+CDecX  x=x-1 end
  63.             if x<DispX and BuffX>0 then begin CSum=Csum+CIncX  x=x+1 end
  64.            
  65.             if y>DispX and BuffY<0 then begin CSum=Csum+CDecMY y=y-1 end
  66.             if y<DispX and BuffY<0 then begin CSum=Csum+CIncMY y=y+1 end
  67.             if y>DispX and BuffY>0 then begin CSum=Csum+CDecY  y=y-1 end
  68.             if y<DispX and BuffY>0 then begin CSum=Csum+CIncY  y=y+1 end
  69.            
  70.             if z>DispX and BuffZ<0 then begin CSum=Csum+CDecMZ z=z-1 end
  71.             if z<DispX and BuffZ<0 then begin CSum=Csum+CIncMZ z=z+1 end
  72.             if z>DispX and BuffZ>0 then begin CSum=Csum+CDecZ  z=z-1 end
  73.             if z<DispX and BuffZ>0 then begin CSum=Csum+CIncZ  z=z+1 end
  74.            
  75.             impulse(1, CSnum)
  76.             CSnum=0
  77.         end
  78.         BuffX=DispX
  79.     end
  80.     function impulse(n, clr)
  81.      for j = 1,n do
  82.       rs.setBundledOutput(SIDE, clr)
  83.       sleep(interval)
  84.       rs.setBundledOutput(SIDE, 0)
  85.       sleep(interval)
  86.      end
  87.     end
  88. function Parser(input)
  89. if input == "exit" then exit()
  90. if input == "dir" then ChDir()
  91. if input == "jmp" then JMP()
  92. if input == "resetdir" then ResetDir()
  93. end
  94.  
  95. function JMP()
  96.      print("jumping...")
  97.       rs.setBundledOutput(SIDE, clr)
  98.       sleep(3*interval)
  99.       rs.setBundledOutput(SIDE, 0)
  100.       sleep(interval)
  101.      print("finished!")
  102.     end
  103. end
  104. repeat
  105. input = read()
  106. Parser(input)
  107. while input !="exit"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement