Jump to content




need help with code....

turtle computer

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

#1 brokenmirror67

  • New Members
  • 1 posts

Posted 24 October 2012 - 04:06 PM

1- is there any way to make the turtle place blocks?
2- if there is how can i fill in a large floor with wood?

#2 billysback

  • Members
  • 569 posts

Posted 24 October 2012 - 04:18 PM

1: http://computercraft...itle=Turtle_api
2:
local left = true
for y=1,maxy do
   local x = 0
   while x <= maxx do
		while turtle.detect() do turtle.dig() sleep(0) end
		turtle.place()
		turtle.forwards()
   end
   if left then
	   left = false
	   turtle.turnLeft()
	   while turtle.detect() do turtle.dig() sleep(0) end
	   if not turtle.detect() then turtle.forwards() end
	   turtle.turnLeft()
   else
	   left = true
	   turtle.turnRight()
	   while turtle.detect() do turtle.dig() sleep(0) end
	   if not turtle.detect() then turtle.forwards() end
	   turtle.turnRight()
   end
end
^^^Untested^^^
You really should look around the forums however, this is both in the wrong place and the information you asked for is almost certainly in the forums somewhere.

#3 Ditto8353

  • New Members
  • 138 posts

Posted 24 October 2012 - 04:22 PM

Should put things like this in the "Ask a Pro" board

#4 ChunLing

  • Members
  • 2,027 posts

Posted 24 October 2012 - 07:31 PM

No, this is more "read the API description and the forum rules first." Ask a pro is for after you've done both of those.

#5 Heracles421

  • Members
  • 258 posts

Posted 24 October 2012 - 07:39 PM

Guys, calm down and don't rage.

And broken, read the rules before posting a new thread, and do some research before too

#6 ChunLing

  • Members
  • 2,027 posts

Posted 24 October 2012 - 11:24 PM

Oh, com'on, you've seen us rage and this is not it. We can be really bad when we get mad.

#7 slay_mithos

  • New Members
  • 22 posts

Posted 25 October 2012 - 08:22 PM

View Postbillysback, on 24 October 2012 - 04:18 PM, said:

1: http://computercraft...itle=Turtle_api
2:
local left = true
for y=1,maxy do
   local x = 0
   while x <= maxx do
		while turtle.detect() do turtle.dig() sleep(0) end
		turtle.place()
		turtle.forwards()
   end
   if left then
	   left = false
	   turtle.turnLeft()
	   while turtle.detect() do turtle.dig() sleep(0) end
	   if not turtle.detect() then turtle.forwards() end
	   turtle.turnLeft()
   else
	   left = true
	   turtle.turnRight()
	   while turtle.detect() do turtle.dig() sleep(0) end
	   if not turtle.detect() then turtle.forwards() end
	   turtle.turnRight()
   end
end
^^^Untested^^^
You really should look around the forums however, this is both in the wrong place and the information you asked for is almost certainly in the forums somewhere.

I might be stupid, or blind, but your while seems to be an infinite loop.
For that kind of loops, you usually go for a FOR loop, as you don't have to remember to increment the variable, even more with lua not supporting the "x+=1"

Well, at least the guy asked, even if he would have had his answers in the tutorial of the wiki.

#8 ChunLing

  • Members
  • 2,027 posts

Posted 26 October 2012 - 01:23 AM

See, much more rage-like.

#9 billysback

  • Members
  • 569 posts

Posted 27 October 2012 - 08:53 AM

woops, forgot x = x + 1
and using a while loop at that point worked just as well and made it a little bit simpler, if I was writing that in Notepad I probably would have used a for loop but I was sort of just writing it simply as an example of what could be done in the post box...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users