Posted 17 March 2014 - 07:48 AM
Im trying to make a code for turtles that can make a platform of "l" length and "w" width. Please keep in mind im not a coder whatsoever and my code is probably mediocre at best. I keep getting an error when running saying that its expecting a "" string:"Platform":50 expecting "=" ""but I have no clue why its wanting = or where.
l = 15
w = 15
e = l/2
i = 0
function MaterialsNeeded()
print(l*w)
end
function Seti()
print("From")
if l%2 == 1 then
i = .5
print(i)
else
i = 0
print(i)
end
function Start()
turtle.forward()
DetectMaterial()
turtle.placeDown()
turtle.turnRight()
print("To")
print(e)
print(" ")
print(" ")
repeat
turtle.forward()
DetectMaterial()
turtle.placeDown()
sleep(1)
i = i + 1
sleep(1)
print(i)
until i == e
i = 0
end
function ComeBack()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
DetectMaterial()
turtle.placeDown()
repeat
turtle.forward
DetectMaterial()
turtle.placeDown()
i = i + 1
until i == l
i = 0
end
end
function GoBack()
turtle.turnRight()
turtle.forward()
DetectMaterial()
turtle.placeDown()
turtle.turnRight()
repeat
turtle.forward()
DetectMaterial()
turtle.placeDown()
i = i + 1
until i = l
i = 0
end
function DetectMaterial()
if turtle.getItemCount(1) => 0 then
turtle.select(1)
end
elseif turtle.getItemCount(2) >= 0 then
turtle.select(2)
end
elseif turtle.getItemCount(3) >= 0 then
turtle.select(3)
end
elseif turtle.getItemCount(4) >= 0 then
turtle.select(4)
end
elseif turtle.getItemCount(5) >= 0 then
turtle.select(5)
end
elseif turtle.getItemCount(6) >= 0 then
turtle.select(6)
end
elseif turtle.getItemCount(7) >= 0 then
turtle.select(7)
end
elseif turtle.getItemCount(8) >= 0 then
turtle.select(8)
end
elseif turtle.getItemCount(9) >= 0 then
turtle.select(9)
end
elseif turtle.getItemCount(10) >= 0 then
turtle.select(10)
end
elseif turtle.getItemCount(11) >= 0 then
turtle.select(11)
end
elseif turtle.getItemCount(12) >= 0 then
turtle.select(12)
end
elseif turtle.getItemCount(13) >= 0 then
turtle.select(13)
end
elseif turtle.getItemCount(14) >= 0 then
turtle.select(14)
end
elseif turtle.getItemCount(15) >= 0 then
turtle.select(15)
end
else turtle.getItemCount(16) >= 0 then
turtle.select(16)
end
end
function Platform()
MaterialsNeeded()
Start()
f = 0
repeat
ComeBack()
GoBack()
f = f + 1
until f = w
end
l = 15
w = 15
e = l/2
i = 0
function MaterialsNeeded()
print(l*w)
end
function Seti()
print("From")
if l%2 == 1 then
i = .5
print(i)
else
i = 0
print(i)
end
function Start()
turtle.forward()
DetectMaterial()
turtle.placeDown()
turtle.turnRight()
print("To")
print(e)
print(" ")
print(" ")
repeat
turtle.forward()
DetectMaterial()
turtle.placeDown()
sleep(1)
i = i + 1
sleep(1)
print(i)
until i == e
i = 0
end
function ComeBack()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
DetectMaterial()
turtle.placeDown()
repeat
turtle.forward
DetectMaterial()
turtle.placeDown()
i = i + 1
until i == l
i = 0
end
end
function GoBack()
turtle.turnRight()
turtle.forward()
DetectMaterial()
turtle.placeDown()
turtle.turnRight()
repeat
turtle.forward()
DetectMaterial()
turtle.placeDown()
i = i + 1
until i = l
i = 0
end
function DetectMaterial()
if turtle.getItemCount(1) => 0 then
turtle.select(1)
end
elseif turtle.getItemCount(2) >= 0 then
turtle.select(2)
end
elseif turtle.getItemCount(3) >= 0 then
turtle.select(3)
end
elseif turtle.getItemCount(4) >= 0 then
turtle.select(4)
end
elseif turtle.getItemCount(5) >= 0 then
turtle.select(5)
end
elseif turtle.getItemCount(6) >= 0 then
turtle.select(6)
end
elseif turtle.getItemCount(7) >= 0 then
turtle.select(7)
end
elseif turtle.getItemCount(8) >= 0 then
turtle.select(8)
end
elseif turtle.getItemCount(9) >= 0 then
turtle.select(9)
end
elseif turtle.getItemCount(10) >= 0 then
turtle.select(10)
end
elseif turtle.getItemCount(11) >= 0 then
turtle.select(11)
end
elseif turtle.getItemCount(12) >= 0 then
turtle.select(12)
end
elseif turtle.getItemCount(13) >= 0 then
turtle.select(13)
end
elseif turtle.getItemCount(14) >= 0 then
turtle.select(14)
end
elseif turtle.getItemCount(15) >= 0 then
turtle.select(15)
end
else turtle.getItemCount(16) >= 0 then
turtle.select(16)
end
end
function Platform()
MaterialsNeeded()
Start()
f = 0
repeat
ComeBack()
GoBack()
f = f + 1
until f = w
end