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

Help ASAP [Turtle Program]

Started by predatorxil, 15 October 2012 - 08:45 PM
predatorxil #1
Posted 15 October 2012 - 10:45 PM
hello, i need a house building program, it needs to build a max of two floors or one, and a simple roof. and any blocks even if i needs modified, i need something to work off of
Lettuce #2
Posted 16 October 2012 - 12:50 AM
Probably no one here will do an entire code on request, unless they made one prior. We're here to learn, and teach others what we know. Like if you made one, and had trouble with your variables, we'd help you. We enjoy it, that's why we are here. Don't… get your hopes up, I suppose, someone may have such a code lying around, and give it to you, but you should give it a try.

For some tips though, here you go. It will be more efficient if it were layer-based. Which means some loops, repeated, oh, 9 or 11 times per wall? Then turn, repeat, turn, repeat again, go up a level. Then destroy the blocks under it, twice, to start your door, and repeat the code you made prior to climbing. I advise making it a function actually, cause you may well repeat it 5+ times.

I'll probably make a house building program someday, but I'm already working on some other programs.
predatorxil #3
Posted 16 October 2012 - 04:44 AM
Thanks, but im not asking someone to make one for me, to better word my post, i need help understanding programing turtles, ive made a simple one, but it wont run….

term.clear()
term.setCursorPos(1,1)
print("RSTown House Builder")
term.setCursorPos(1,2)
build = yes
shutdown = no
write("Ready to Build? ")
input = read()
if input == build then
print("Working…")
sleep(2)
turtle.select(2)
turtle.up()
turtle.placeDown()
turtle.forward()
turtle.placeDown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.turnLeft()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
turtle.placedown()
turtle.forward()
elseif input == shutdown then
os.reboot()
sleep(2)
end
Kingdaro #4
Posted 16 October 2012 - 05:07 AM
First off, when you say "it doesn't run", it's really helpful to post the error that comes up, though it wasn't necessary for this case because the errors are clear.

Secondly, it's also helpful when you put your code around
tags so it's easier to read. Either that, or use pastebin.

Now onto the actual script:

-- wrong
build = yes
shutdown = no

-- right
build = "yes"
shutdown = "no"
The "yes" and "no" should be around quotes. In this case, I'm assuming you're going to be asking for "yes" or "no" from the player, yes meaning to build and no for shutting down.

Secondly, Lua is case sensitive. Meaning

turtle.placedown()
is not the same as

turtle.placeDown()

"turtle.placeDown" is the correct way of typing it.

Also, this will more than likely help you a ton to know that there's a way to shorten that.

for i=1, 20 do
  turtle.placeDown()
  turtle.forward()
end
In this bit of code, it will repeat placing down and going forward 20 times. You can replace 20 with however many times you need to do this action.

One final tip, if you're going to be using CC versions above 1.33, you'll probably need to check if your turtle has enough fuel before starting the building process. You can read more about fuel on the wiki.
ChunLing #5
Posted 17 October 2012 - 01:47 AM
Check the Turtle Programs forum, there are plenty of existing programs that can do stuff like this (tele_iz_dva4a's replacement for go utility–which I refer to as gox and included in my own program–is my personal favorite, but there are others).