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

Mining Turtle Help

Started by xxbryanjxx, 10 September 2013 - 05:14 PM
xxbryanjxx #1
Posted 10 September 2013 - 07:14 PM
Title: Mining Turtle help

I am trying to make a "Simple" turtle code but i can't seem to make it place a torch every 6 - 7 blocks. This is the entire code
http://pastebin.com/Ffsz4HCh
I
f there is any other helpful I am listening.
Also the function "Torch()" is what the placing thing is under.
if you notice it has
  • while y < 7 do
  • y = y + 1
  • end
  • while y = 1 do
  • turtle.place()

I put the ones there on purpose, originally the "while y = 1 do" line was "while y > 7" i only changed it to see if that would make it work (it did.. sorta)
Edited on 10 September 2013 - 05:22 PM
Lyqyd #2
Posted 10 September 2013 - 09:31 PM
Remove the declarations for X and Y.

At the top of the file, add: local x = 1

Replace the torch function with:


function Torch()
  if x % 7 == 0 then
    turtle.place()
  end
end

The basic idea is that you are already increasing the value of X, so we simply use that and check if it's a multiple of seven. The x % 7 part divides x by seven and uses the remainder to compare against 0. If x is a multiple of seven, the remainder will be zero, and it will place an item from the currently selected slot. You'll probably need to make other minor adjustments, but this should get you on the right track.
xxbryanjxx #3
Posted 11 September 2013 - 03:49 PM
Thank you for the quick reply! yeah that fixed it! i didn't know you could set it up to check if the x was a multiple of 7.
Anyway, it worked, and thank you.