Posted 21 October 2013 - 01:41 PM
Hey guys!
I've written a basic floor laying code (my friends and I are working on a skyscraper!) and I wanted it to be customizable so that the turtle would either turn left first from where you placed him or right first from where you placed him. As far as I can tell, my if statement checks are right. But the Turtle insists on making his first turn a right turn, no matter what the input is.
My code is as follows,
I've written a basic floor laying code (my friends and I are working on a skyscraper!) and I wanted it to be customizable so that the turtle would either turn left first from where you placed him or right first from where you placed him. As far as I can tell, my if statement checks are right. But the Turtle insists on making his first turn a right turn, no matter what the input is.
My code is as follows,
--!floor
--This simply lays down a floor of a specified area Nothing more
print("I start counting the blocks in front of me!")
print("How far forward boss?")
local x=tonumber(read())-1
print("How far across boss?")
local y=tonumber(read())
print("Left or Right boss? (L/R)")
local dir=read()
if dir=="L" or "l" then
dir="L"
elseif dir=="R" or "r" then
dir="R"
end
a=1
t.forward()
if not turtle.detectDown() then
turtle.select(a)
turtle.placeDown()
end
if x*y+1<=turtle.getFuelLevel() then
for j=1, y do
for i=1, x do
if turtle.getItemCount(a)==0 then
a=a+1
end
t.forward()
if not turtle.detectDown() then
turtle.select(a)
turtle.placeDown()
end
end
if turtle.getItemCount(a)==0 then
a=a+1
end
if dir=="R" then
t.right()
t.forward()
if not turtle.detectDown() then
turtle.select(a)
if j~=y then
turtle.placeDown()
end
end
t.right()
dir="L"
elseif dir=="L" then
t.left()
t.forward()
if not turtle.detectDown() then
turtle.select(a)
if j~=y then
turtle.placeDown()
end
end
t.left()
dir="R"
end
end
else
print("Not enough fuel boss! Try again later!")
end