Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.76 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.     local 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 begin CSum=Csum+CDecMX x=x-1 end
  64.             if x<DispX and BuffX<0 then begin CSum=Csum+CIncMX x=x+1 end
  65.             if x>DispX and BuffX>0 then begin CSum=Csum+CDecX  x=x-1 end
  66.             if x<DispX and BuffX>0 then begin CSum=Csum+CIncX  x=x+1 end
  67.            
  68.             if y>DispX and BuffY<0 then begin CSum=Csum+CDecMY y=y-1 end
  69.             if y<DispX and BuffY<0 then begin CSum=Csum+CIncMY y=y+1 end
  70.             if y>DispX and BuffY>0 then begin CSum=Csum+CDecY  y=y-1 end
  71.             if y<DispX and BuffY>0 then begin CSum=Csum+CIncY  y=y+1 end
  72.            
  73.             if z>DispX and BuffZ<0 then begin CSum=Csum+CDecMZ z=z-1 end
  74.             if z<DispX and BuffZ<0 then begin CSum=Csum+CIncMZ z=z+1 end
  75.             if z>DispX and BuffZ>0 then begin CSum=Csum+CDecZ  z=z-1 end
  76.             if z<DispX and BuffZ>0 then begin CSum=Csum+CIncZ  z=z+1 end
  77.            
  78.             impulse(1, CSnum)
  79.             CSnum=0
  80.         end
  81.         BuffX=DispX
  82.         print("finished!")
  83.     end
  84.     function impulse(n, clr)
  85.      for j = 1,n do
  86.       rs.setBundledOutput(SIDE, clr)
  87.       sleep(interval)
  88.       rs.setBundledOutput(SIDE, 0)
  89.       sleep(interval)
  90.      end
  91.     end
  92. function Parser(input)
  93. if input == "exit" then exit()
  94. if input == "dir" then ChDir()
  95. if input == "jmp" then JMP()
  96. if input == "resetdir" then ResetDir()
  97. end
  98.  
  99. function JMP()
  100.      print("jumping...")
  101.       rs.setBundledOutput(SIDE, clr)
  102.       sleep(3*interval)
  103.       rs.setBundledOutput(SIDE, 0)
  104.       sleep(interval)
  105.      print("finished!")
  106.     end
  107. end
  108. repeat
  109. input = read()
  110. Parser(input)
  111. while input !="exit"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement