Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.96 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.     BuffX=0
  23.         BuffY=0
  24.         BuffZ=0
  25.     function resetDir()
  26.         impulse(63,CDecX)
  27.         impulse(63,CDecMX)
  28.         impulse(63,CDecY)
  29.         impulse(63,CDecMY)
  30.         impulse(63,CDecZ)
  31.         impulse(63,CDecMZ)
  32.         impulse(24,MULDec)
  33.     end
  34.     function ChDir()
  35.         local sx=""
  36.         local sy=""
  37.         local sz=""
  38.         print("X")
  39.         BuffX=read()
  40.         print("Y")
  41.         BuffY=read()
  42.         print("Z")
  43.         BuffZ=read()
  44.         print("M")
  45.         MUL=read()
  46.         SetDir()
  47.     end
  48. function SetDir()
  49.     CSum=0
  50.     if abs(BuffX)>abs(BuffY) then n=abs(BuffX) else n=abs(BuffY)
  51.     if n<abs(BuffZ) then n=abs(BuffZ)
  52.         if BuffX>0 and DispX<0 then impulse(DispX,CDecX)
  53.         if BuffX<0 and DispX>0 then impulse(DispX,CDecMX)
  54.         if BuffY>0 and DispY<0 then impulse(DispY,CDecY)
  55.         if BuffY<0 and DispY>0 then impulse(DispY,CDecMY)
  56.         if BuffZ>0 and DispZ<0 then impulse(DispZ,CDecZ)
  57.         if BuffZ<0 and DispZ>0 then impulse(DispZ,CDecMZ)
  58.         x=BuffX
  59.         y=BuffY
  60.         z=BuffZ
  61.         for j = 1,n do
  62.            
  63.             if x>DispX and BuffX<0 then
  64.             begin
  65.             CSum=CSum+CDecMX
  66.             x=x-1
  67.             end
  68.             if x<DispX and BuffX<0 then
  69.             begin
  70.             CSum=CSum+CIncMX
  71.             x=x+1
  72.             end
  73.             if x>DispX and BuffX>0 then
  74.             begin
  75.             CSum=CSum+CDecX
  76.             x=x-1
  77.             end
  78.             if x<DispX and BuffX>0 then
  79.             begin
  80.             CSum=CSum+CIncX
  81.             x=x+1
  82.             end
  83.            
  84.             if y>DispX and BuffY<0 then
  85.             begin
  86.             CSum=CSum+CDecMY
  87.             y=y-1
  88.             end
  89.             if y<DispX and BuffY<0 then
  90.             begin
  91.             CSum=CSum+CIncMY
  92.             y=y+1
  93.             end
  94.             if y>DispX and BuffY>0 then
  95.             begin
  96.             CSum=CSum+CDecY
  97.             y=y-1
  98.             end
  99.             if y<DispX and BuffY>0 then
  100.             begin
  101.             CSum=CSum+CIncY
  102.             y=y+1
  103.             end
  104.            
  105.             if z>DispX and BuffZ<0 then
  106.             begin
  107.             CSum=CSum+CDecMZ
  108.             z=z-1
  109.             end
  110.             if z<DispX and BuffZ<0 then
  111.             begin
  112.             CSum=CSum+CIncMZ
  113.             z=z+1
  114.             end
  115.             if z>DispX and BuffZ>0 then
  116.             begin
  117.             CSum=CSum+CDecZ
  118.             z=z-1
  119.             end
  120.             if z<DispX and BuffZ>0 then
  121.             begin
  122.             CSum=CSum+CIncZ
  123.             z=z+1
  124.             end
  125.            
  126.             impulse(1, CSnum)
  127.             CSnum=0
  128.         end
  129.         BuffX=DispX
  130.         print("finished!")
  131.     end
  132.     function impulse(n, clr)
  133.      for j = 1,n do
  134.       rs.setBundledOutput(SIDE, clr)
  135.       sleep(interval)
  136.       rs.setBundledOutput(SIDE, 0)
  137.       sleep(interval)
  138.      end
  139.     end
  140. function Parser(input)
  141. if input == "exit" then exit()
  142. if input == "dir" then ChDir()
  143. if input == "jmp" then JMP()
  144. if input == "resetdir" then ResetDir()
  145. end
  146.  
  147. function JMP()
  148.      print("jumping...")
  149.       rs.setBundledOutput(SIDE, clr)
  150.       sleep(3*interval)
  151.       rs.setBundledOutput(SIDE, 0)
  152.       sleep(interval)
  153.      print("finished!")
  154.     end
  155. end
  156. repeat
  157. input = read()
  158. Parser(input)
  159. while input !="exit"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement