23 posts
Posted 11 December 2012 - 10:10 PM
Hi guys, im kindof new to computer craft, but have some background in java scripting (does that help?). When using a turtle to make a 3x3 tunnel (no tutorials, by myself) i ran into the error in the title. I cannot figure out what is wrong, can some one tell me what its trying to tell me. Thanks. I'm not posting code becuase i want to figure this out on my own, i just don't know what this error means.
767 posts
Posted 11 December 2012 - 10:15 PM
Its hard to explain an error, Without any kind of code.. But
the error is attempting to compare a number to a function, thats maybe a string instead of an number
or its maybe trying to get a number, out of an table, but that table maybe only holds strings.
if you want me to actually tell you what you should edit, then post your code.
-Mikk809h
23 posts
Posted 12 December 2012 - 12:26 AM
Its hard to explain an error, Without any kind of code.. But
the error is attempting to compare a number to a function, thats maybe a string instead of an number
or its maybe trying to get a number, out of an table, but that table maybe only holds strings.
if you want me to actually tell you what you should edit, then post your code.
-Mikk809h
Okay, that helps.
Here is the code:
local switchOn = true --Will start as false, just for testing is set to true
while switchOn == true do
local i = 1
repeat
i = i + 1
if turtle.getFuelLevel() < 1
then turtle.refuel(1)
else
if turtle.detectUp()
then turtle.digUp()
end
if turtle.detectDown()
then turtle.digDown()
end
if turtle.detect()
then turtle.dig()
turtle.forward()
else turtle.forward()
end
end
until i == 3
if turtle.detectDown()
then turtle.digDown()
end
if turtle.detectUp()
then turtle.digUp()
end
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
local j = 1
repeat
j = j + 1
if turtle.getFuelLevel < 1
then turtle.refuel(1)
else
if turtle.detectUp()
then turtle.digUp()
end
if turtle.detectDown()
then turtle.digDown()
end
if turtle.detect()
then turtle.dig()
turtle.forward()
else turtle.forward()
end
end
until j == 3
turtle.turnLeft()
turtle.dig()
turtle.turnLeft()
end
This is my first time with turtles, so the code might not be very efficient or optimized, so some help on that would be appreciated.
On a side-note as I have you here, is there a way to activate this program from another computer? Is there a distance limit?
1054 posts
Posted 12 December 2012 - 01:44 AM
It's this line:
if turtle.getFuelLevel < 1
You are actually comparing the function itself against a number. What you want to do is comparing the return value (output) of that function to a number. Like so:
if turtle.getFuelLevel() < 1
You have this line twice, the first instance is correct, the other is missing the parentheses.
Yes, you can activate the program from another computer. You would do that over rednet, range distance depends on your config file. By default it is in between 64m and 352m or something, depending on the height of either the transmitting or the receiving computer/turtle.
23 posts
Posted 12 December 2012 - 11:26 AM
It's this line:
if turtle.getFuelLevel < 1
You are actually comparing the function itself against a number. What you want to do is comparing the return value (output) of that function to a number. Like so:
if turtle.getFuelLevel() < 1
You have this line twice, the first instance is correct, the other is missing the parentheses.
Yes, you can activate the program from another computer. You would do that over rednet, range distance depends on your config file. By default it is in between 64m and 352m or something, depending on the height of either the transmitting or the receiving computer/turtle.
Thanks. fixing now. I must of just missed it, and couldn't see it when editing
767 posts
Posted 12 December 2012 - 11:35 AM
W
Well i Hope your code will work now.
When i saw the code, i was thinking the same as orwell.
Orwell was just too fast for me, to post xD :D/>
but orwell is right, on his code examples.
so i really Hope that it fixed your problem :D/>
-mikk809h