19 posts
Posted 19 December 2012 - 01:34 PM
So I'm making a program to cut down a tree and i am having this error.
Error bios:338: [string "TreeCutter"}]:10: 'do' expected
Although the error says 'do' i already have do there
Any help would be much appreciated!
Here's My Code:
H = 7
local function checkFuel()
if turtle.getFuelLevel() < 20 then
turtle.select(1)
turtle.refuel(1)
end
end
while H = 7 do
checkFuel()
turtle.dig()
turtle.forward()
H = H-1
end
while H < 7 do
checkFuel()
turtle.digUp()
H = H-1
end
while H = 0 do
checkFuel()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
checkFuel()
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.select(4)
turtle.drop()
checkFuel()
turtle.turnRight()
turtle.turnRight()
turtle.select(2)
turtle.place()
turtle.select(3)
turtle.place()
H = H+7
end
2088 posts
Location
South Africa
Posted 19 December 2012 - 01:43 PM
while H = 0 do
change to
while H == 0 do and with the other while
Using a single = is for setting variables, to compare two variables, you use double ==
19 posts
Posted 19 December 2012 - 02:08 PM
Thanks so much that has fixed that error.
I just have one more error.
The turtle just keeps going up and doesn't stop.
Any reason?
i know it has something to do with the counting of the H
2088 posts
Location
South Africa
Posted 19 December 2012 - 02:10 PM
How does it keep going up? There isn't a single turtle.up() in your code? Did you add anything other than changing the ==
8543 posts
Posted 19 December 2012 - 02:10 PM
What? There is literally no turtle.up() anywhere in the code you posted. How do you expect us to troubleshoot code that we don't have? Post the updated code.
19 posts
Posted 19 December 2012 - 02:14 PM
Hi, I'm having a problem with a lumberjack program I'm making.
The problem is that it keeps going upwards
Not sure exactly whats wrong but i know it has to be something to do with the counting of H
Please post a fix
All help would be much appreciated
Here's my code!
H = 7
local function checkFuel()
if turtle.getFuelLevel() < 20 then
turtle.select(1)
turtle.refuel(1)
end
end
while H == 7 do
checkFuel()
turtle.dig()
turtle.forward()
H = H-1
end
while H < 7 do
checkFuel()
turtle.digUp()
turtle.up()
H = H - 1
end
while H == 0 do
checkFuel()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
checkFuel()
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.select(4)
turtle.drop()
checkFuel()
turtle.turnRight()
turtle.turnRight()
turtle.select(2)
turtle.place()
turtle.select(3)
turtle.place()
H = H + 7
end
8543 posts
Posted 19 December 2012 - 02:18 PM
Please don't post another topic for a question about the same piece of code. The problem is that you enter the going-up loop with H at 6, then continue to go upward as long as H is less than 7, but you subtract one from H each time you loop. H will continue being smaller than 7 forever, so you'll keep looping forever.
2088 posts
Location
South Africa
Posted 19 December 2012 - 02:18 PM
while H == 7 do
checkFuel()
turtle.dig()
turtle.forward()
H = H-1
end
while H < 7 do
checkFuel()
turtle.digUp()
turtle.up()
H = H - 1
end
… Must we point it out?
First while triggers then reduces H by 1. Then the next while loop triggers and never stops because H is ALWAYS below 7. That's why it's ALWAYS going up
19 posts
Posted 19 December 2012 - 02:25 PM
Oh yea…
could you post a fix please
Also doesn't saying
while H == 7 do
checkFuel()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
...
Override it?
8543 posts
Posted 19 December 2012 - 02:29 PM
We don't know what you want the program to do, precisely, so it would be hard to "post a fix" for the broken logic you've utilized. You'll have to figure out what you want the program to do first.
19 posts
Posted 19 December 2012 - 02:33 PM
to go move up 6 spaces
with this action
checkFuel()
turtle.digUp()
turtle.up()
then down with this
checkFuel()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
checkFuel()
turtle.turnRight()
turtle.turnRight()
turtle.forward()
turtle.select(4)
turtle.drop()
checkFuel()
turtle.turnRight()
turtle.turnRight()
turtle.select(2)
turtle.place()
turtle.select(3)
turtle.place()
And then restart
8543 posts
Posted 19 December 2012 - 02:40 PM
So do:
for i=1, 6 do
checkFuel()
turtle.digUp()
turtle.up()
end
2005 posts
Posted 19 December 2012 - 04:18 PM
I love you guys…these kinds of topics are the best.
12 posts
Posted 19 December 2012 - 08:07 PM
hello i am a noob at computercraft i made refuel program but it wont work
here the code
function fuel()
if turtle.getFuelLevel() <= 5 then
turtle.select(12) –this is the slot where i put my fuel
turtle.refuel(1)
turtle.select(1)
end
end
2088 posts
Location
South Africa
Posted 20 December 2012 - 12:54 AM
I love you guys…these kinds of topics are the best.
:lol:/> :lol:/>
hello i am a noob at computercraft i made refuel program but it wont work
here the code
function fuel()
if turtle.getFuelLevel() <= 5 then
turtle.select(12) –this is the slot where i put my fuel
turtle.refuel(1)
turtle.select(1)
end
end
Please rather post your own thread, but did you actually even call the function? Add fuel() to the bottom of the code