Advertisement
blawhar

zaloha

May 25th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.82 KB | None | 0 0
  1. function variables()
  2.   rednet.open("top")
  3.   out1=peripheral.wrap("flux_gate_79")
  4.   in1=peripheral.wrap("flux_gate_78")
  5.   cap1=peripheral.wrap("draconic_rf_storage_16")
  6.   isCap1={empty=false,full=false,outp=false,inp=false,c=false}
  7.   maxIn=60000000
  8.   maxOut=5000000
  9.  
  10.  lot=1640000000
  11.  
  12.   koupeno=0
  13.   preneseno=0
  14. --  prenesenoStr  
  15.   pass=0
  16.   pass1=0
  17.   ipass=0
  18.  
  19.   start=false
  20.   cBuy=0
  21.   cCount=0
  22.   gate=true
  23.   isOpened=false
  24.   btnGate=0
  25.   mainScreenGate=false
  26.   passGate=false
  27.  
  28.   count=0
  29.   ID=2284
  30.   price=10
  31.  
  32.  
  33.   redstone.setOutput("left",true)
  34.   sleep(1)
  35.   redstone.setOutput("left",false)
  36.  
  37.  
  38.         out1.setSignalLowFlow(0)
  39.         in1.setSignalLowFlow(maxIn)
  40.         isCap1.outp=false
  41.         isCap1.inp=true
  42.        
  43.         while not (cap1.getEnergyStored()==cap1.getMaxEnergyStored()) do               
  44.         sleep(0.1)
  45.         end    
  46.         in1.setSignalLowFlow(0)
  47.         isCap1.inp=false
  48.        
  49.        
  50.  
  51. end
  52.  
  53. function formatInt(number)
  54.   if number == nil then number = 0 end
  55.   local i,j,minus,int,fraction=tostring(number):find('([-]?)(%d+)([.]?%d*)')
  56.   int=int:reverse():gsub("(%d%d%d)","%1,")
  57.   return minus .. int:reverse():gsub("^,","") .. fraction
  58. end
  59.  
  60.    
  61. function getAllVariables()
  62.  local data=fs.open("cap1.txt","r")
  63.  isCap1.empty=data.readLine()
  64.  isCap1.full=data.readLine()
  65.  isCap1.outp=data.readLine()
  66.  isCap1.inp=data.readLine()
  67.  isCap1.c=data.readLine()
  68.  data.close()
  69.  
  70.  local data=fs.open("cap2.txt","r")
  71.  isCap2.empty=data.readLine()
  72.  isCap2.full=data.readLine()
  73.  isCap2.outp=data.readLine()
  74.  isCap2.inp=data.readLine()
  75.  isCap2.c=data.readLine()
  76.  data.close()
  77.  
  78.  local data=fs.open("gates.txt","r")
  79.  gate=data.readLine()
  80.  isOpened=data.readLine()
  81.  mainScreenGate=data.readLine()
  82.  data.close()
  83.  
  84.  local data=fs.open("pass.txt","r")
  85.  pass=data.readLine()
  86.  data.close()
  87.  
  88.  local data=fs.open("another.txt","r")
  89.  start=data.readLine()
  90.  cBuy=data.readLine()
  91.  count=data.readLine()
  92.  data.close()
  93.  
  94.  local data=fs.open("btnGate.txt","r")
  95.  btnGate=data.readLine()
  96.  data.close()  
  97.  
  98. end
  99.  
  100. function updateCap1()
  101.   local data=fs.open("cap1.txt","w")
  102.   data.writeLine(isCap1.empty)
  103.   data.writeLine(isCap1.full)
  104.   data.writeLine(isCap1.outp)
  105.   data.writeLine(isCap1.inp)
  106.   data.writeLine(isCap1.c)
  107.   data.close()
  108. end
  109.  
  110.  
  111.  
  112. function gatesUpdate()
  113.   local data=fs.open("gates.txt","w")
  114.   data.writeLine(gate)
  115.   data.writeLine(isOpened)
  116.   data.writeLine(mainScreenGate)
  117.   data.close()
  118. end
  119.  
  120. function passUpdate()
  121.   local data=fs.open("pass.txt","w")
  122.   data.writeLine(pass)
  123.   data.close()
  124. end
  125.  
  126. function anotherUpdate()
  127.   local data=fs.open("another.txt","w")
  128.   data.writeLine(start)
  129.   data.writeLine(cBuy)
  130.   data.writeLine(count)
  131.   data.close()
  132. end
  133.  
  134. function btnGateUpdate()
  135.   local data=fs.open("btnGate.txt","w")
  136.   data.writeLine(btnGate)
  137.   data.close()
  138.  
  139. end
  140.  
  141. function monClear()
  142.   mon.setBackgroundColor(colors.black)
  143.   mon.clear()
  144.   mon.setCursorPos(1,1)
  145.   mon.setTextColour(colors.white)
  146. end  
  147.  
  148. function monSetup()
  149.   mon=peripheral.wrap("monitor_141")
  150.   mon.setBackgroundColor(colors.black)
  151.   mon.clear()
  152. end
  153.  
  154. function monWrite(ax,ay,tColor,BgColor,atext)
  155.   mon.setBackgroundColor(BgColor)
  156.   mon.setTextColour(tColor)
  157.   mon.setCursorPos(ax,ay)
  158.   mon.write(atext)
  159. end
  160.  
  161. function firstScreen()
  162.   btnGate=1
  163.   monSetup()
  164.   monWrite(10,1,colors.red,colors.black,"TERMINAL #1")
  165.   monWrite(7,3,colors.blue,colors.black,"Max out:")
  166.   monWrite(16,3,colors.white,colors.black,"5")
  167.   monWrite(18,3,colors.purple,colors.black,"MRF/t")
  168.   monWrite(7,5,colors.orange,colors.black,"1 lot:")
  169.   monWrite(14,5,colors.white,colors.black,"1,64")
  170.   monWrite(19,5,colors.purple,colors.black,"BRF")
  171.   monWrite(4,7,colors.red,colors.black,"Price:")
  172.   monWrite(11,7,colors.white,colors.black,"10")
  173.   monWrite(14,7,colors.purple,colors.black,"Dia block/lot")
  174.   monWrite(7,11,colors.white,colors.red,"OTEVRIT PRIPOJKU")
  175.  while true do
  176.   os.pullEvent()
  177.   if btnGate==0 then
  178.     return
  179.   end
  180.  end
  181.  
  182. end
  183.  
  184. function firstInfo()
  185.   btnGate=2
  186.   monClear()
  187.   monWrite(1,1,colors.white,colors.black,"Testovaci provoz. Majtel si")
  188.   monWrite(1,2,colors.white,colors.black,"vyhrazje pravo rusit/upravit")
  189.   monWrite(1,3,colors.white,colors.black,"bez vaseho vedomi. jakykoliv")
  190.   monWrite(1,4,colors.white,colors.black,"pokus o obchazeni systemu se")
  191.   monWrite(1,5,colors.white,colors.black,"tresta. pokud nebude 30 dnu")
  192.   monWrite(1,6,colors.white,colors.black,"aktivni output, pripojka se")
  193.   monWrite(1,7,colors.white,colors.black,"automaticky maze.")
  194.   monWrite(1,11,colors.white,colors.black,"Pokud souhlasis, klikni na:")
  195.   monWrite(18,12,colors.white,colors.green,"SOUHLASIM")
  196.  while true do
  197.   os.pullEvent()
  198.   if btnGate==0 then
  199.     return
  200.   end    
  201.  end
  202. end
  203.  
  204. function passInfo()
  205.   btnGate=3
  206.   monClear()
  207.   monWrite(1,3,colors.white,colors.black,"Kvuli zabezpeceni bude v")
  208.   monWrite(1,4,colors.white,colors.black,"nasledujicim kroku zadano")
  209.   monWrite(1,5,colors.white,colors.black,"4 mistne heslo. Toto heslo")
  210.   monWrite(1,6,colors.white,colors.black,"bude pozdeji pozadovano pri")
  211.   monWrite(1,7,colors.white,colors.black,"zmenach parametru pripojky")
  212.  
  213.   monWrite(1,12,colors.white,colors.black,"pro zadani hesla stiskni")
  214.   monWrite(26,12,colors.white,colors.green,"OK")
  215.  while true do
  216.   os.pullEvent()
  217.   if btnGate == 0 then
  218.     return
  219.   end  
  220.  end
  221. end
  222.  
  223. function firstPass()
  224.   btnGate=4
  225.  
  226.   while true do
  227.     monClear()
  228.     keyboardPrint()
  229.     passGate=true
  230.     zadejPass(1)
  231.     while passGate do
  232.       os.pullEvent()
  233.     end
  234.     pass=pass1
  235.     pass1=0
  236.    
  237.     passGate=true  
  238.     monClear()
  239.     keyboardPrint()
  240.     ipass=0
  241.     zadejPass(3)
  242.     while passGate do
  243.       os.pullEvent()
  244.     end
  245.     if pass==pass1 then
  246.       --printClearWindow()
  247.       --printToWindow(....)
  248.       --mainScreenGate=true
  249.       pass1=0
  250.       btnGate=0
  251.       isOpened=true
  252.       ipass=0
  253.       return
  254.     else
  255.       --printClearWindow()
  256.       printToWindow()
  257.       pass=0
  258.       ipass=0
  259.       pass1=0      
  260.     end
  261.   end
  262. end
  263.  
  264. function getPass()
  265.   btnGate=4
  266.  
  267.   while true do
  268.  
  269.    
  270.     passGate=true  
  271.     monClear()
  272.     keyboardPrint()
  273.     ipass=0
  274.     zadejPass(2)
  275.     while passGate do
  276.       os.pullEvent()
  277.     end
  278.     if pass==pass1 then
  279.       --printClearWindow()
  280.       --printToWindow(....)
  281.       mainScreenGate=true
  282.       pass1=0
  283.       btnGate=0
  284.       ipass=0
  285.       return
  286.     else
  287.       --printClearWindow()
  288.       printToWindow()
  289.       ipass=0
  290.       pass1=0      
  291.     end
  292.   end
  293. end
  294.  
  295.  
  296. --function printClearWindow()
  297.  
  298. --end
  299.  
  300. function printToWindow() --predelat
  301. monClear()
  302. monWrite(1,1,colors.white,colors.black,"CHYBA!")
  303. monWrite(1,2,colors.white,colors.black,"Hesla se neshoduji")
  304. monWrite(1,3,colors.white,colors.black,"opakuj proces")
  305. sleep(4)
  306. end
  307.  
  308.  
  309. function Loader(x)--dodelat
  310.  
  311. if x==1 then
  312. getPass()
  313.  
  314. end
  315.  
  316. btnGate=5
  317.  
  318. monClear()
  319. if x==0 then
  320. monWrite(1,1,colors.white,colors.black,"na cerveny blok poloz ")
  321. monWrite(1,2,colors.white,colors.black,"tesseract, na cerny naplneny")
  322. monWrite(1,3,colors.white,colors.black,"chunkoader* a potvrd")
  323.  
  324. monWrite(1,6,colors.white,colors.black,"* Chunkloader neni nutny,")
  325. monWrite(1,7,colors.white,colors.black,"ale...")
  326.  
  327. monWrite(5,11,colors.white,colors.green,"OK")
  328. monWrite(10,11,colors.white,colors.green,"CANCEL")
  329. else
  330. monWrite(1,1,colors.white,colors.black,"vysunul jsi loader")
  331. monWrite(1,2,colors.white,colors.black,"pro zasunuti stiskni ok")
  332.  
  333. monWrite(5,11,colors.white,colors.green,"OK")
  334.  
  335.  
  336. end
  337.  
  338. redstone.setOutput("bottom",true)
  339. sleep(1)
  340. redstone.setOutput("bottom",false)
  341.  
  342.  
  343.  
  344.  
  345. while true do
  346.  os.pullEvent()
  347.  if btnGate==0 then
  348.    return
  349.  end
  350. end
  351.  
  352. end
  353.  
  354. function buy(x)
  355. if x==1 then
  356. getPass()
  357. end
  358.  
  359.  
  360. btnGate=10
  361. mainScreenGate=false
  362. monClear()
  363. monWrite(1,1,colors.white,colors.black,"vhod dia do crate a potvrd")
  364. monWrite(1,2,colors.white,colors.black,"prepocet chvilku trva,")
  365. monWrite(1,3,colors.white,colors.black,"prosim o strpeni")
  366. monWrite(13,11,colors.white,colors.green,"OK")
  367.  
  368. while true do
  369.   eID,msg,dist=rednet.receive()
  370.   if eID==ID then
  371.   count=tonumber(msg)
  372.   print(count)
  373.   print(msg)
  374.   btnGate=11
  375.   break
  376.   end
  377. end
  378. vratit=(count-math.floor(count/price)*price)
  379. zaplaceno=(math.floor(count/price))*price
  380. koupeno=koupeno+lot*(zaplaceno/price)
  381. cBuy=cBuy+(zaplaceno/price)
  382.  
  383. print(vratit)
  384. print(zaplaceno)
  385.  
  386. monClear()
  387. monWrite(1,1,colors.white,colors.black,"zaplaceno:")
  388. monWrite(1,2,colors.white,colors.black,tostring(zaplaceno))
  389. monWrite(1,3,colors.white,colors.black,"vraceno:")
  390. monWrite(1,4,colors.white,colors.black,tostring(vratit))
  391. monWrite(1,5,colors.white,colors.black,"koupeno nergie:")
  392. monWrite(1,6,colors.lightGray,colors.black,formatInt(lot*(zaplaceno/price)))
  393. monWrite(5,11,colors.white,colors.green,"OK")
  394. monWrite(10,11,colors.white,colors.red,"CANCEL")
  395.  
  396. while true do
  397.  os.pullEvent()
  398.  if btnGate==0 then
  399.    return
  400.  end
  401. end
  402.  
  403.  
  404. end
  405.  
  406.  
  407.  
  408. function mainScreen()
  409.  -- monClear()
  410.  
  411. --  prenesenoProc=(preneseno/koupeno)*100
  412.  
  413. --  preneseno=cCount*1640000000
  414.  
  415.   if isCap1.outp  then
  416.        preneseno=(cCount)*1640000000+(1640000000-cap1.getEnergyStored())
  417.  -- sleep(1)
  418.   else
  419.     preneseno=cCount*1640000000
  420.  -- sleep(1)
  421.   end  
  422.  
  423.  monClear()
  424.   monWrite(5,3,colors.white,colors.black,"koupeno")
  425.   monWrite(1,4,colors.lightGray,colors.black,formatInt(koupeno))
  426.   monWrite(3,6,colors.white,colors.black,"preneseno")
  427.   monWrite(1,7,colors.lightGray,colors.black,formatInt(preneseno))
  428.  
  429.   monWrite(19,2,colors.white,colors.green," dokoupit ")
  430.   monWrite(19,3,colors.white,colors.green," energii  ")
  431.  
  432.   monWrite(19,5,colors.white,colors.green," vysunout ")
  433.   monWrite(19,6,colors.white,colors.green," ch.loader")
  434.  
  435.   monWrite(19,8,colors.white,colors.green,"   help   ")
  436.  
  437.   monWrite(19,10,colors.white,colors.red,"  zrusit  ")
  438.   monWrite(19,11,colors.white,colors.red," pripojku ")
  439.  
  440. end
  441.  
  442. function zadejPass(x)
  443.   mon.setTextColor(colors.white)
  444.   mon.setBackgroundColor(colors.black)
  445.   if x==1 then  
  446.       mon.setCursorPos(11,2)
  447.       mon.write("zadej 4 mistne")
  448.       mon.setCursorPos(11,3)  
  449.       mon.write("heslo a potvrd OK")
  450.   elseif x==2 then
  451.       mon.setCursorPos(11,2)
  452.       mon.write("              ")
  453.       mon.setCursorPos(11,2)
  454.       mon.write("zadej heslo")
  455.       mon.setCursorPos(11,3)
  456.       mon.write("a potvrd OK")
  457.   elseif x==3 then
  458.       mon.setCursorPos(11,2)
  459.       mon.write("              ")
  460.       mon.setCursorPos(11,2)
  461.       mon.write("potvrd heslo")
  462.       mon.setCursorPos(11,3)
  463.       mon.write("a potvrd OK")
  464.   end
  465. end
  466.  
  467. function keyboardPrint()
  468.   monClear()
  469.   mon.setBackgroundColour(colors.blue)
  470.   mon.setCursorPos(2,1)
  471.   mon.write("  ")
  472.   mon.setCursorPos(5,1)
  473.   mon.write("  ")
  474.   mon.setCursorPos(8,1)
  475.   mon.write("  ")
  476.   mon.setCursorPos(2,2)
  477.   mon.write("7 ")
  478.   mon.setCursorPos(5,2)
  479.   mon.write("8 ")
  480.   mon.setCursorPos(8,2)
  481.   mon.write("9 ")
  482.  
  483.   mon.setCursorPos(2,4)
  484.   mon.write("  ")
  485.   mon.setCursorPos(5,4)
  486.   mon.write("  ")
  487.   mon.setCursorPos(8,4)
  488.   mon.write("  ")  
  489.   mon.setCursorPos(2,5)
  490.   mon.write("4 ")
  491.   mon.setCursorPos(5,5)
  492.   mon.write("5 ")
  493.   mon.setCursorPos(8,5)
  494.   mon.write("6 ")
  495.  
  496.   mon.setCursorPos(2,7)
  497.   mon.write("  ")
  498.   mon.setCursorPos(5,7)
  499.   mon.write("  ")
  500.   mon.setCursorPos(8,7)
  501.   mon.write("  ")
  502.   mon.setCursorPos(2,8)
  503.   mon.write("1 ")
  504.   mon.setCursorPos(5,8)
  505.   mon.write("2 ")
  506.   mon.setCursorPos(8,8)
  507.   mon.write("3 ")
  508.  
  509.   mon.setCursorPos(2,10)
  510.   mon.write("  ")
  511.   mon.setCursorPos(2,11)
  512.   mon.write("0 ")
  513.   mon.setCursorPos(5,10)
  514.   mon.setBackgroundColor(colors.lime)
  515.   mon.write("  ")
  516.   mon.setCursorPos(5,11)
  517.   mon.write("OK")
  518.   mon.setCursorPos(8,10)
  519.   mon.setBackgroundColor(colors.red)
  520.   mon.write("  ")
  521.   mon.setCursorPos(8,11)
  522.   mon.write("DL")
  523.  
  524.   mon.setCursorPos(28,11)
  525.   mon.write("  ")
  526.   mon.setCursorPos(28,12)
  527.   mon.write("X ")
  528.  
  529.   mon.setBackgroundColor(colors.black)
  530.   mon.setCursorPos(11,5)
  531.   mon.write("PASS:")
  532. end
  533.  
  534.  
  535. function buttons()
  536.   while true do
  537.     event, side, x, y=os.pullEvent("monitor_touch")
  538.     if btnGate==1 then
  539.       if x>6 and x<19 and y==11 then    
  540.         btnGate=0
  541.       end
  542.     elseif btnGate==2 then
  543.       if x>17 and x<27 and y==12 then    
  544.         btnGate=0
  545.       end
  546.     elseif btnGate==3 then
  547.       if x>25 and x<28 and y==12 then
  548.         btnGate=0
  549.      
  550.       end
  551.     elseif btnGate==4 then
  552.       if x>1 and x<4 and y<3 and ipass<4 then
  553.         pass1=pass1*10+7
  554.         mon.setCursorPos(16+ipass,5)
  555.         mon.write("*")
  556.         ipass=ipass+1
  557.       elseif x>4 and x<7 and y<3 and ipass<4 then
  558.         pass1=pass1*10+8
  559.         mon.setCursorPos(16+ipass,5)
  560.         mon.write("*")
  561.         ipass=ipass+1
  562.       elseif x>7 and x<10 and y<3 and ipass<4 then
  563.         pass1=pass1*10+9
  564.         mon.setCursorPos(16+ipass,5)
  565.         mon.write("*")
  566.         ipass=ipass+1
  567.       elseif x>1 and x<4 and y>3 and y<6 and ipass<4 then
  568.         pass1=pass1*10+4
  569.         mon.setCursorPos(16+ipass,5)
  570.         mon.write("*")
  571.         ipass=ipass+1
  572.       elseif x>4 and x<7 and y>3 and y<6 and ipass<4 then
  573.         pass1=pass1*10+5
  574.         mon.setCursorPos(16+ipass,5)
  575.         mon.write("*")
  576.         ipass=ipass+1
  577.       elseif x>7 and x<10 and y>3 and y<6 and ipass<4 then
  578.         pass1=pass1*10+6
  579.         mon.setCursorPos(16+ipass,5)
  580.         mon.write("*")
  581.         ipass=ipass+1
  582.       elseif x>1 and x<3 and y>6 and y<9 and ipass<4 then
  583.         pass1=pass1*10+1
  584.         mon.setCursorPos(16+ipass,5)
  585.         mon.write("*")
  586.         ipass=ipass+1
  587.       elseif x>3 and x<7 and y>6 and y<9 and ipass<4 then
  588.         pass1=pass1*10+2
  589.         mon.setCursorPos(16+ipass,5)
  590.         mon.write("*")
  591.         ipass=ipass+1
  592.       elseif x>7 and x<10 and y>6 and y<9 and ipass<4 then
  593.         pass1=pass1*10+3
  594.         mon.setCursorPos(16+ipass,5)
  595.         mon.write("*")
  596.         ipass=ipass+1
  597.       elseif x>1 and x<4 and y>9 and y<12 and ipass<4 then
  598.         pass1=pass1*10+0
  599.         mon.setCursorPos(16+ipass,5)
  600.         mon.write("*")
  601.         ipass=ipass+1
  602.       elseif x>7 and x<10 and y>9 and y<12 then
  603.         if ipass>0 then
  604.           pass1=math.floor(pass1/10)
  605.           ipass=ipass-1
  606.           mon.setCursorPos(16+ipass,5)
  607.           mon.write(" ")
  608.         end
  609.       elseif x>4 and x<7 and y>9 and y<12 and ipass==4 then
  610.  
  611.         passGate=false
  612.  
  613.      
  614.       end
  615.     elseif btnGate==5 then
  616.       if x>4 and x<8 and y==11 then
  617.         btnGate=0
  618.      redstone.setOutput("left",true)
  619.         sleep(1)
  620.            redstone.setOutput("left",false)
  621.       end
  622.     elseif btnGate==10 then
  623.       if x>10 and x<14 and y==11 then
  624.         rednet.send(ID,1)
  625.      mainScreenGate=true
  626.      --if start==false and cBuy>0 then
  627.          -- start=true
  628.          -- gate=true
  629.     -- end
  630.    end
  631.     elseif btnGate==11 then
  632.       if x>4 and x<8 and y==11 then
  633.         rednet.send(ID,3)
  634.            btnGate=0
  635.      mainScreenGate=true
  636.      if start==false and cBuy>0 then
  637.      start=true
  638.      end
  639.         --start=true
  640.       elseif x>9 and x<17 and y==11 then
  641.         rednet.send(ID,2)
  642.            btnGate=0
  643.      mainScreenGate=true
  644.       end
  645.     elseif btnGate==0 then
  646.       if x>18 and x<29 and y>1 and y<4 then
  647.       btnGate=10
  648.       elseif x>18 and x<29 and y>4 and y<7 then
  649.    btnGate=5
  650.    end
  651.      
  652.      
  653.  end  
  654.     sleep(0.1)
  655.   end
  656. end
  657.  
  658. function disp()
  659. while true do
  660.  
  661.     term.clear()
  662.     term.setCursorPos(1,1)
  663.     print("pass: "..pass)
  664.     print("start: "..(start and 'true' or 'false'))
  665.     print("gate: "..(gate and 'true' or 'false'))
  666.     print("cap1:empty:"..(isCap1.empty and 'true' or 'false').." ,full:"..(isCap1.full and 'true' or 'false').." ,outp:"..(isCap1.outp and 'true' or 'false').." ,inp:"..(isCap1.inp and 'true' or 'false'))
  667.     print("cBuy: "..cBuy.." ,cCount: "..cCount)
  668.  
  669.  
  670.  
  671.     if not isOpened then
  672.       firstScreen()
  673.       firstInfo()
  674.       passInfo()
  675.       firstPass()
  676.       buy(0)
  677.       Loader(0)
  678.    
  679.    else
  680.      if mainScreenGate then
  681.        mainScreen()
  682.      end
  683.    if btnGate==10 then
  684.      buy(1)
  685.    elseif btnGate==5 then
  686.      Loader(1)
  687.    end
  688.    
  689.    end
  690.  
  691.     sleep(0.1)
  692.   end
  693. end
  694.  
  695.  
  696. function capReg()
  697.   while true do
  698.  
  699.     if cCount ==cBuy then
  700.       start=false
  701.       gate=true
  702.    end  
  703.    
  704.    if start then
  705.      if gate then      
  706.         isCap1.outp=true
  707.         out1.setSignalLowFlow(maxOut)
  708.         gate=false
  709.      end
  710.    end
  711.  
  712.    
  713.     if cap1.getEnergyStored()==0 then
  714.        
  715.         out1.setSignalLowFlow(0)
  716.         in1.setSignalLowFlow(maxIn)
  717.         isCap1.outp=false
  718.         isCap1.inp=true
  719.        
  720.         while not (cap1.getEnergyStored()==cap1.getMaxEnergyStored()) do               
  721.         sleep(0.1)
  722.         end
  723.        
  724.         cCount=cCount+1
  725.        
  726.         if cCount ==cBuy then
  727.             out1.setSignalLowFlow(0)
  728.             isCap1.outp=false
  729.         else
  730.             out1.setSignalLowFlow(maxOut)
  731.             in1.setSignalLowFlow(0)
  732.             isCap1.outp=true
  733.             isCap1.inp=false
  734.         end
  735.        
  736.     end
  737.    
  738.     sleep(0.1)
  739.  
  740.   end  
  741. end
  742.  
  743.  
  744. variables()
  745.  
  746. --updateCap1()
  747. --updateCap2()
  748. --gatesUpdate()
  749. --passUpdate()
  750. --anotherUpdate()
  751. --btnGateUpdate()
  752.  
  753. --getAllVariables()
  754.  
  755. parallel.waitForAny(buttons,disp,capReg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement