Jump to content




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



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

#1 Cabius

  • New Members
  • 2 posts

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

Quote

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


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 31 December 2012 - 08:47 PM

Moved to Ask a Pro.

#3 ChunLing

  • Members
  • 2,027 posts

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.

#4 Cabius

  • New Members
  • 2 posts

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

#5 ChunLing

  • Members
  • 2,027 posts

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users