trying to find my issue in my program

Started by Gerunimuz96, Feb 21, 2019, 09:31 PM

Previous topic - Next topic

Gerunimuz96

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")

informer

What is the error that is being displayed? The discord chat might be a better place to solve this.

Dog

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.