Jump to content




Problem with strip mining code for mining turtle


  • You cannot reply to this topic
2 replies to this topic

#1 Bringle

  • New Members
  • 2 posts

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.

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

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

#3 Bringle

  • New Members
  • 2 posts

Posted 19 February 2013 - 08:33 AM

Thank you! It worked a charm!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users