This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
supersammy00's profile picture

help new to computer craft

Started by supersammy00, 11 July 2013 - 03:22 PM
supersammy00 #1
Posted 11 July 2013 - 05:22 PM
Title: help new to computer craft

im trying to make a mining program and when i run it it just executes and does nothing code below



function DigDown()
  turtle.digDown()
  turtle.dig()
  if turtle.down() then
    Go = Go - 1
  end
end

function DigUp()
  turtle.digUp()
  turtle.dig()
  if turtle.up() then
    Go = Go + 1
  end
end

function refuel()
  if turtle.getFuelLevel < 200 then
    turtle.refuel()
    if turtle.getFuelLevel < 200 then
      turtle.select(16)
      turtle.digUp()
      turtle.up()
      turtle.digUp()
      turtle.down()
      turtle.placeUp()
      turtle.suckUp()
      turtle.refuel()
    end
  end
end

function dropOff()
  turtle.select(15)
  turtle.digUp()
  turtle.up()
  turtle.digUp()
  turtle.down()
  turtle.placeUp()
  turtle.dropUp()
end



function test()
  print ("hello world loop")
  print (Go) 
  print (Going)
  if Going == false then
    if Go < 6 then
      Going = true
      turtle.dig()
      turtle.forward()
      turtle.dig()
      turtle.forward()
    else
      DigDown()
    end
  else
    if Go < 63 then
      DigUp()
    else
      if turtle.detectUp() then
        DigUp()
      else
        Going = false
        turtle.dig()
        turtle.forward()
        turtle.dig()
        turtle.forward()
      end
    end
  end
end

function 

Go = 78
Going = false

while true do
  test()
end

Updated code
Cranium #2
Posted 12 July 2013 - 11:00 AM
Split to new topic.

In your while loop, you used 'while ture do'. That will check if the variable 'ture' exists. You need to switch that out with 'while true do'.
Lyqyd #3
Posted 12 July 2013 - 12:41 PM
Even if you fix that, the logic in the rest of the loop is rather broken. All it's ever going to do is call the digDown function you've written.
supersammy00 #4
Posted 12 July 2013 - 02:53 PM
Even if you fix that, the logic in the rest of the loop is rather broken. All it's ever going to do is call the digDown function you've written.
Split to new topic.

In your while loop, you used 'while ture do'. That will check if the variable 'ture' exists. You need to switch that out with 'while true do'.
thanks i have realized that as i said im new to computer craft and it is still a alpha version of this.
CCJJSax #5
Posted 13 July 2013 - 09:22 PM
also Going == ture? I think you want "Going = true". simple mistake we all make on occasion :)/>

Most of your functions aren't being called, but I'm sure that's just 'cause you haven't included them or you haven't gotten to that yet.

Go will never be anything other than 64 because it's never changed, so it will always "digDown()" assuming I understand what you're trying to do, that variable will need to have something to modify it.

Finally, don't worry about being a noob at computercraft, we were all there once, and I've been working with it for awhile and I come to these forums and all of a sudden I feel like a complete noob being overshadowed with all these amazing programmers. :)/>