Jump to content




Loop error?


29 replies to this topic

#21 Expenox

  • Members
  • 137 posts
  • LocationIn the depths of my computer.

Posted 16 December 2012 - 08:25 AM

View PostUlthean, on 16 December 2012 - 07:48 AM, said:

Try this

if not turtle.detectUp() then
  turtle.up()
end
It just stays there, I gave it coal too.

#22 Ulthean

  • Members
  • 171 posts

Posted 16 December 2012 - 08:39 AM

What code did you put it in?

#23 Expenox

  • Members
  • 137 posts
  • LocationIn the depths of my computer.

Posted 16 December 2012 - 08:54 AM

View PostUlthean, on 16 December 2012 - 08:39 AM, said:

What code did you put it in?
The one you told me to try.

Now to think of it, I should add a fuel function...
+ Added Fuel Function(Pastebin)
(Still not done)

#24 Expenox

  • Members
  • 137 posts
  • LocationIn the depths of my computer.

Posted 16 December 2012 - 09:32 AM

Okay it works, but now I need help on how to get it to move more then one time up.
When I run this it only goes up once, when it should loop itself.

#25 Ulthean

  • Members
  • 171 posts

Posted 16 December 2012 - 09:39 AM

This code loops it endlessly

local function checkFuel()
  if turtle.getFuelLevel() <1 then
	turtle.select(1)
	turtle.refuel(1)
  end
end

while true do
  checkFuel()
  if not turtle.detectUp() then
	turtle.up()
  end
end

This code loops it until there is a block above

local function checkFuel()
  if turtle.getFuelLevel() <1 then
	turtle.select(1)
	turtle.refuel(1)
  end
end

while not turtle.detectUp() do
  checkFuel()
  turtle.up()
end

This code goes up 10 times

local function checkFuel()
  if turtle.getFuelLevel() <1 then
	turtle.select(1)
	turtle.refuel(1)
  end
end

for i=1,10 do
  checkFuel()
  if not turtle.detectUp() then
	turtle.up()
  end
end


#26 Expenox

  • Members
  • 137 posts
  • LocationIn the depths of my computer.

Posted 16 December 2012 - 09:45 AM

View PostUlthean, on 16 December 2012 - 09:39 AM, said:

This code loops it endlessly

local function checkFuel()
  if turtle.getFuelLevel() <1 then
	turtle.select(1)
	turtle.refuel(1)
  end
end

while true do
  checkFuel()
  if not turtle.detectUp() then
	turtle.up()
  end
end

This code loops it until there is a block above

local function checkFuel()
  if turtle.getFuelLevel() <1 then
	turtle.select(1)
	turtle.refuel(1)
  end
end

while not turtle.detectUp() do
  checkFuel()
  turtle.up()
end

This code goes up 10 times

local function checkFuel()
  if turtle.getFuelLevel() <1 then
	turtle.select(1)
	turtle.refuel(1)
  end
end

for i=1,10 do
  checkFuel()
  if not turtle.detectUp() then
	turtle.up()
  end
end
Yeah just added the while do loop, thanks for the help!
Pastebin
Go here to see the program there and download it, once it's finished.

#27 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 16 December 2012 - 01:29 PM

can i suggest that you do this

input = read(*)
if input:lower() == password then

Did you want it to dig? If so try this.
turtle.detectUp() and turtle.digUp() or turtle.up()

And if you want it to dig, you should probably allow for sand and gravel falling before trying to move again, can cause problems if code isn't done right sometimes :)

#28 Expenox

  • Members
  • 137 posts
  • LocationIn the depths of my computer.

Posted 16 December 2012 - 01:39 PM

View PostTheOriginalBIT, on 16 December 2012 - 01:29 PM, said:

can i suggest that you do this

input = read(*)
if input:lower() == password then

Did you want it to dig? If so try this.
turtle.detectUp() and turtle.digUp() or turtle.up()

And if you want it to dig, you should probably allow for sand and gravel falling before trying to move again, can cause problems if code isn't done right sometimes :)
It is a lumberjack, and no I meant it not to dig.

#29 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 16 December 2012 - 01:43 PM

View PostExpenox, on 16 December 2012 - 01:39 PM, said:

View PostTheOriginalBIT, on 16 December 2012 - 01:29 PM, said:

can i suggest that you do this

input = read(*)
if input:lower() == password then

Did you want it to dig? If so try this.
turtle.detectUp() and turtle.digUp() or turtle.up()

And if you want it to dig, you should probably allow for sand and gravel falling before trying to move again, can cause problems if code isn't done right sometimes :)
It is a lumberjack, and no I meant it not to dig.

ok just checking :) in your original code you had it digging.

FYI making the string lowercase means that no matter how they enter the string it will work.

#30 Expenox

  • Members
  • 137 posts
  • LocationIn the depths of my computer.

Posted 17 December 2012 - 04:44 AM

View PostTheOriginalBIT, on 16 December 2012 - 01:43 PM, said:

View PostExpenox, on 16 December 2012 - 01:39 PM, said:

View PostTheOriginalBIT, on 16 December 2012 - 01:29 PM, said:

can i suggest that you do this

input = read(*)
if input:lower() == password then

Did you want it to dig? If so try this.
turtle.detectUp() and turtle.digUp() or turtle.up()

And if you want it to dig, you should probably allow for sand and gravel falling before trying to move again, can cause problems if code isn't done right sometimes :)
It is a lumberjack, and no I meant it not to dig.

ok just checking :) in your original code you had it digging.

FYI making the string lowercase means that no matter how they enter the string it will work.
For my password I already did that..
Check here for it...
and for my lock I did that on purpose, experimenting each way.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users