title: Computercraft Lua Multiple processes running simultaneously
body: <p>I am trying to make a simple tunnel mining turtle. I tried to display some information on the turtle while mining. For instance, the progress and the fuel consumption. </p>
  
  <p>The process/function of mining the actual tunnel and displaying the information should run simultaneously, but at this point it doesn't really do that.</p>
  
  <p>I try to use the parallel API but it just doesn't work the way I want it to. </p>
  
  <p>Here's the code I have so far: </p>
  
  <pre><code>--Starting Conditions--
  HeightQuestion = true
  WidthQuestion = true
  LengthQuestion = true
  BlocksToMine =0
  EstBlocksDone =0
  BlocksDone =0
  BlocksToDo =0
  screen = 0
  
  
  function FuncFuel()
      if turtle.getFuelLevel() &lt; 10 then
          turtle.refuel()
          print("fuel level: " .. turtle.getFuelLevel() ..  "/".. turtle.getFuelLimit())
      else
          print("fuel level: " .. turtle.getFuelLevel().. "/".. turtle.getFuelLimit())
      end 
  end
  
  function FuncHeight()
      while (HeightQuestion == true) do -- Height Question
          print("Height of tunnel?")
          IniHeight = tonumber(read())
          if IniHeight == nil then
              print( "Please answer with a number." )
          elseif IniHeight &gt;= 2 then
              HeightQuestion = false
          elseif IniHeight == 1 then
              print( "The tunnel Height must be larger than one." )
          elseif IniHeight == 0 then
              print( "The tunnel Height can't be infinite." )
          else
              print( "The tunnel Height must be positive." )
          end
      end
      Height=IniHeight
   end
  
  function FuncWidth()
      while (WidthQuestion == true) do -- Width Question
          print("Width of tunnel?")
          IniWidth = tonumber(read())
          if IniWidth == nil then
              print( "Please answer with a number." )
          elseif IniWidth &gt; 0 then
              WidthQuestion = false
          elseif IniWidth == 0 then
              print( "The tunnel Width can't be infinite." )
          else
              print( "The tunnel Width must be positive." )
          end 
      end
      Width=IniWidth
  end
  
  function FuncLength()
      while (LengthQuestion == true) do -- Length Question
          print("Length of tunnel?")
          IniLength = tonumber(read())
          if IniLength == nil then
              print( "Please answer with a number." )
          elseif IniLength &gt; 0 then
              LengthQuestion = false
          elseif IniLength == 0 then
              LengthQuestion = false
              InfiniteLength = true
              TorchesQuestion = false
              TorchSpacingQuestion = false
          else
              print( "The tunnel Length must be positive." )
          end
      end
      Length=IniLength
  end
  
  function FuncDig()
      while turtle.detect()==true do
          turtle.dig()
          BlocksDone = BlocksDone+1
          sleep(0.5)
      end
  end
  
  function FuncDigUp()
      while turtle.detectUp()==true do
          turtle.digUp()
          BlocksDone = BlocksDone+1
          sleep(0.5)
      end
  end
  
  function FuncDigDown()
      while turtle.detectDown()==true do
          turtle.digDown()
          BlocksDone = BlocksDone+1
          sleep(0.5)
      end
  end
  
  function FuncRight()
      turtle.turnRight()
      FuncDig()
      turtle.forward()
      turtle.turnLeft()
  end
  
  function FuncLeft()
      turtle.turnLeft()
      FuncDig()
      turtle.forward()
      turtle.turnRight()
  end
  
  function FuncUp()
      FuncDigUp()
      turtle.up()
  end
  
  function FuncDown()
      FuncDigDown()
      turtle.down()
  end
  
  function FuncForward()
      FuncDig()
      turtle.forward()
  end
  
  
  
  function SetMineScreen()
      BlocksToMine = IniHeight*IniWidth*IniLength
      BlocksToDo = BlocksToMine-BlocksDone
      PercentageDone= EstBlocksDone*100/BlocksToMine
      if turtle.getFuelLevel() &lt; 10 then
          turtle.refuel(1)
      end
      term.clear()
      print("    ----------MineBot----------    \n")
      print("    ---------ACTIVATED---------    \n")
      print("    Total Amount To Do: " .. BlocksToMine .. "\n")
      print("    Total Amount Done: " .. BlocksDone ..  "\n")
      print("    Estimated Done: " .. EstBlocksDone ..  "\n")
      print("    Progress : " .. PercentageDone .. "\n")
      print("    Fuel Level: " .. turtle.getFuelLevel() .. "/" .. turtle.getFuelLimit() .. "\n")
      print("    &lt;-- previous      Next--&gt;")
  end
  
  function MineScreenProcess()
      while true do
          SetMineScreen()
          sleep(0.5)
      end
  end
  
  function FuncTunnel()
      FuncFuel()
      Width = Width - 1
      Height = Height - 1 
      for i=1, Length do
          for i=1,Height do
              FuncUp()    
          end
          for i=1, Height / 2 do
              for i=1,Width do
                  FuncDig()
                  FuncRight() 
                  EstBlocksDone = EstBlocksDone+1
              end
              FuncDig()
              EstBlocksDone = EstBlocksDone+1
              FuncDown()
              for i=1, Width do               
                  FuncDig()
                  EstBlocksDone = EstBlocksDone+1
                  FuncLeft()  
              end
              FuncDig()
              EstBlocksDone = EstBlocksDone+1
              FuncDown()
          end
          if Height % 2 == 0 then
              for i=1,Width do
                  FuncDig()
                  EstBlocksDone = EstBlocksDone+1
                  FuncRight()     
              end
              FuncDig()
              EstBlocksDone = EstBlocksDone+1
              for i=1, Width do               
                  FuncDig()
                  FuncLeft()  
              end
              FuncDig()
              EstBlocksDone = EstBlocksDone+1
          elseif Height % 2 == 1 then
              for i=1,Width do
                  FuncDig()
                  EstBlocksDone = EstBlocksDone+1
                  FuncRight()     
              end
              FuncDig()
              EstBlocksDone = EstBlocksDone+1
              FuncDown()
              for i=1, Width do               
                  FuncDig()
                  FuncLeft()  
                  EstBlocksDone = EstBlocksDone+1
              end
              FuncDig()
              EstBlocksDone = EstBlocksDone+1
          end
          FuncForward()
      end
      turtle.turnRight()  
      turtle.turnRight()  
      for i=1, Length do
          turtle.forward()
      end
      turtle.turnRight()  
      turtle.turnRight()  
  end
  
  
  FuncHeight()
  FuncWidth()
  FuncLength()
  
  parallel.waitForAll(MineScreenProcess(), FuncTunnel())
  --FuncDig()
  </code></pre>