Xoandbit

Base computer

Jul 7th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.95 KB | None | 0 0
  1.  n=1
  2.  nosaukumi={"#1 Generatori","Sektors #2"}
  3.  computer_id={2,24}
  4.  sleep(4)
  5.  
  6.  
  7.  a=peripheral.wrap("right")
  8.  term.redirect(a)
  9.  a.setTextScale(1)
  10.  
  11.  
  12.  x=30
  13.  y=2
  14.  laiki={}
  15.  aktivs={}
  16.  
  17.  
  18.   for i=1,n do
  19.  laiki[i]=os.clock()
  20.  aktivs[i]="OFF"
  21.  end
  22.  
  23.   term.clear()
  24.   term.setCursorPos(5,5)
  25.   term.write("ieladejas")
  26.   sleep(1)
  27.  
  28.  a.setTextScale(1)
  29. print("")
  30. print("    __ __                   _  _    _  _   ")
  31. print("   |  |  | ___  ___  ___  _| || |_ |_|| |_ ")
  32. print("   |-   -|| . || .'||   || . || . || ||  _|")
  33. print("   |__|__||___||__,||_|_||___||___||_||_|  ")
  34. print("")
  35.  
  36.  rednet.close("left")
  37.  rednet.open("left")
  38.  
  39.  sleep(5)
  40.  
  41.  while true do
  42.  
  43.  term.clear()
  44.  term.setCursorPos(1,1)
  45.  print()
  46.  print("  +-+-+-+-+-+-+-+-+");
  47.  print("  |X|o|a|n|d|b|i|t|");
  48.  print("  +Automatizetajs-+")
  49.  print()
  50.  
  51. if n==0 then
  52.         term.setCursorPos(x,y+2)
  53.         write("Nav parvaldamo iekartu")
  54. else
  55.      for i=1,n do
  56.         term.setCursorPos(x,y+i)
  57.         write(nosaukumi[i])
  58.         write(" - ")
  59.         write(aktivs[i])
  60.         write(" ")
  61.         local apr=os.clock()-laiki[i]
  62.         write(math.ceil(apr))
  63.      end
  64. end
  65.  term.setCursorPos(25,10)
  66.  
  67.  
  68.  
  69. while true do
  70.  
  71.     i=1
  72.     id,sk=rednet.receive(0.5)
  73.     if id~=nil then
  74.             for l=1,n do
  75.                if id==computer_id[l] then
  76.                    sk=sk+1-1
  77.                            if sk>0 then
  78.                           laiki[l]=os.clock()
  79.                           aktivs[l]="ON"
  80.                           i=i+1
  81.                         end
  82.                       if sk==0 then
  83.                           aktivs[l]="ON-N"
  84.                           laiki[l]=os.clock()
  85.                           i=i+1                  
  86.                       end
  87.                end
  88.             end
  89.     else
  90.         break
  91.     end
  92.     if i>10 then
  93.        break
  94.     end
  95. end
  96.  
  97.  --Parbaudam
  98.  
  99.  for i=1,n do
  100.  local apr=math.ceil(os.clock()-laiki[i])-1
  101.     if apr>15 then
  102.         aktivs[i]="OFF"
  103.     end
  104.  end
  105.  
  106.  end
Advertisement
Add Comment
Please, Sign In to add comment