This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Bringle's profile picture

Problem with strip mining code for mining turtle

Started by Bringle, 19 February 2013 - 05:35 AM
Bringle #1
Posted 19 February 2013 - 06:35 AM
The main body of the code works fine but I have written a function named inventFull() that should stop the program with an error message when the turtle's inventory is full, but for some reason it doesn't. Instead the turtle behaves as it would normally, spitting out the items from the back when the inventory is full. I'm fairly certain that the problem lies within the inventFull() function so for the moment I will only include that code, but I will be happy to provide more of my code if it will help solve the issue.

Here is the code for the inventFull() function:


function checkInvent()
for i = 1,16 do
  if turtle.getItemCount(i) == 0 then
   inventFull = false
   break
  end
end
if not inventFull == false then
  inventFull = true
  print("Inventory Full!")
  if blocksMoved > 0 then
   print("Returning to start...")
   returnToStart()
  end
  error("Could not mine because inventory is full.")
end
end

P.S. I am using the FeedTheBeast modpack which I assume uses the latest version of ComputerCraft, if that makes any difference.
Lyqyd #2
Posted 19 February 2013 - 06:52 AM
Split into new topic.

Create a new line just inside the function, before the for loop:

local inventFull = true
Bringle #3
Posted 19 February 2013 - 08:33 AM
Thank you! It worked a charm!