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

Help with writing a program to place a layer of blocks.

Started by Cabius, 31 December 2012 - 07:13 PM
Cabius #1
Posted 31 December 2012 - 08:13 PM
Hello, I am new here. I have been playing with Tekkit for over a year now and I just started to get into the Computer Craft stuff and I am trying to make a turtle place a single layer of blocks across a 24X40 block area. Could someone help me write the program? I tried to do something like

turtle.place()

turtle.moveBack()

turtle.place()



But it doesn't work and I cant make it do a 24X40 area. Any help would be appreciated. It wouldn't be bad to have it remove the next block behind it to so I don't have to clear the layer of blocks before putting the turtle down. Maybe at the start of the program it would dig down one block then dig behind it then place one in front then dig behind again then place and so fourth. I suppose it would have to not pick up the blocks it is digging so its inventory doesn't get full.


Thankyou. :D/>
Lyqyd #2
Posted 31 December 2012 - 08:47 PM
Moved to Ask a Pro.
ChunLing #3
Posted 31 December 2012 - 10:56 PM
First of all, you need to read up on your turtle API. Because it's not "turtle.moveBack()"

Then, you need to learn about control structures in Lua, particularly for loops and conditionals.

After that, you should be able to do this pretty easily. Or at least get close.
Cabius #4
Posted 31 December 2012 - 11:17 PM
Ok thanks, I would rather learn it my self than have someone just hand it to me anyway. :D/>
ChunLing #5
Posted 31 December 2012 - 11:51 PM
Oh, one more helpful thing. Use the modulus (the % operator or math.fmod) to figure out whether you are an odd or even iteration. That helps control turning for the next pass.

I believe that the % is easier/faster and functionally the same as long as you're dealing with positive numbers.