ComputerCraft Forums

ComputerCraft => Ask a Pro => Topic started by: Gerunimuz96 on Feb 21, 2019, 09:31 PM

Title: trying to find my issue in my program
Post by: Gerunimuz96 on Feb 21, 2019, 09:31 PM
I do not find the issue, pls help







write("wie weit soll gegraben werden ?")
lange = io.read()
 
shell.run("clear")
 
write("wie breit?")
breit = io.read()
 
shell.run("clear")
 
 
function tf()
 
  for forward = 0,lange do 
         
    turtle.dig()
    turtle.forward()
     
    if forward == lange then
       
        tb()
    end
  end
end
 
function tb()
 
  switch = 0
 
  for breite = 0,breit do
 
    if switch == 0 then
   
      turtle.turnLeft()
      turtle.forward()
      turtle.turnLeft()
      switch = 1
    else
      turtle.turnRight()
      turtle.forward()
      turtle.turnRight()
      switch = 0
     
    end
  end
end
 
shell.run("clear")
 
tf()
 
print("Auftrag wird nun erledigt")
Title: trying to find my issue in my program
Post by: informer on Feb 21, 2019, 11:43 PM
What is the error that is being displayed? The discord chat might be a better place to solve this.
Title: trying to find my issue in my program
Post by: Dog on Feb 22, 2019, 04:52 PM
What is the script doing now and what do you expect it to do that is different?

Does your turtle have fuel?

One thing I noticed is that you're capturing strings for your input then using them as numbers.  While CC Lua is pretty forgiving about this, that *might* be the source of whatever issue you're having.

Change lange = io.read() to lange = tonumber(io.read())
and change breit = io.read() to breit = tonumber(io.read())

That *might* be enough to get your program running the way you expect.