33 posts
Posted 26 October 2015 - 01:03 AM
This is simple. I want a turtle to keep checking for a block on top of it, then run the rest of the code.
What I have already tried:
repeat turtle.detectUp() until turtle.detectUp()
then it runs the code, I also tried
repeat turtle.detectUp() until turtle.detectUp() = true
Edited on 26 October 2015 - 12:04 AM
756 posts
Posted 26 October 2015 - 01:49 AM
Replace the first turtle.detectUp() with sleep(1).
Running you code will most likely lead to your turtle crashing, a sleep will prevent it.
33 posts
Posted 26 October 2015 - 03:30 AM
Replace the first turtle.detectUp() with sleep(1).
Running you code will most likely lead to your turtle crashing, a sleep will prevent it.
Thanks, worked, but if I you could answer another question please, i'm trying to for example ask a user to input a number, with the ( read() ) thing, and the subtract 64 from that number, and even tho the user inputs a number, it gives me this error:
""program name":3 attempt to compare string with
number expected, got string"
Actual testing code:
print("test")
local t1 = ( read() )
if t1 > 64 then
t1 = t1-64
else
print(t1)
end
print(t1)
7083 posts
Location
Tasmania (AU)
Posted 26 October 2015 - 03:38 AM
You can convert string-types to number-types:
local t1 = tonumber(read())
Though if the string doesn't represent a valid number, tostring() will return nil. So to deal with that, you might do:
local t1
repeat t1 = tonumber(read()) until t1 -- Keep bugging the user to type stuff until t1 is not nil.