0

论据有什么作用?如何在某处为 shell.run('asdf') 编写标签并将其链接到 shell.run('asdf') 行?编码:

  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()
4

2 回答 2

3

shell.run运行一个命令,就像您在命令行中键入它一样。我认为您将其与 混淆了goto,这有很大不同。

的参数shell.run作为参数传递给命令行。

前任。shell.run("ls")将运行ls命令,shell.run("rm", "foo.txt")并将运行rm foo.txt.

于 2014-05-29T03:34:51.997 回答
0

这里使它成为一个函数:

  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()
于 2014-08-24T23:12:04.027 回答