0

What do the arguments do? How do I code a tag for shell.run('asdf') somewhere and link it to the shell.run('asdf') line? The Code:

  turtle.dig()
  turtle.forward()
 -what api works with shell.run() here?-  <---------- Where I want tag.
  turtle.digUp()
  turtle.dig()
  turtle.turnLeft()
  turtle.dig()
  turtle.turnRight()
  turtle.up()
if turtle.detect() then
  shell.run('asdf')        <---------- What do I put to link it to tag.
else
  turtle.forward()
  turtle.turnLeft()
end
  while not turtle.detectDown() do
    turtle.dig()
    turtle.down()
  end
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.turnLeft()
turtle.turnLeft()
Colonel Thirty Two
  • 23,953
  • 8
  • 45
  • 85

2 Answers2

3

shell.run runs a command, as if you had typed it into the command line. I think you are confusing it with goto, which is much different.

The arguments to shell.run are passed as arguments to the command line.

Ex. shell.run("ls") will run the ls command, and shell.run("rm", "foo.txt") will run rm foo.txt.

Colonel Thirty Two
  • 23,953
  • 8
  • 45
  • 85
0

Here make it a function:

  turtle.dig()
  turtle.forward()
  function tag() -- function

    turtle.digUp()
   turtle.dig()
   turtle.turnLeft()
   turtle.dig()
  turtle.turnRight()
   turtle.up()
if turtle.detect() then
 tag() -- running the function
 else
  turtle.forward()
  turtle.turnLeft()
 end
  while not turtle.detectDown() do
       turtle.dig()
    turtle.down()
  end
 turtle.turnLeft()
 turtle.forward()
 turtle.forward()
 turtle.turnLeft()
 turtle.turnLeft()
Test
  • 1