Jump to content




[Lua]Wall building problem


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

#1 DigitalQR

  • New Members
  • 2 posts

Posted 14 January 2013 - 07:43 AM

My idea was to have a turtle who will go and build me a wall (I know there's probably a bunch of people who have already done this, but I wanted to program my own version) and I've encountered a problem; the turtle will only build 2 wide.
Any help?

print("How High?")
high = tonumber(read())
print("How Long?")
long = tonumber(read())
y = high
x = long
u = 0

while y>0 do
turtle.place()
turtle.up()
y = y-1
end

if y == 0 then
if x>0 then
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
turtle.down()
x = x-1
u = high
end
end

while u>0 do
turtle.place()
turtle.down()
u = u-1
end

if u == 0 then
if x>0 then
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
turtle.up()
x = x-1
y = high
return
end
end

#2 zekesonxx

  • Signature Abuser
  • 263 posts
  • LocationWhere you aren't

Posted 14 January 2013 - 08:00 AM

You need to encase it in a while not isFinished do, and set isFinished to false when it has been finished.

#3 DigitalQR

  • New Members
  • 2 posts

Posted 21 January 2013 - 08:11 AM

I put it in and it didn't work. But, I rewrote the script with the if statement in and it worked fine. Thankyou.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users