Lua:shell.run('asdf','arg1','arg2')参数?标记?

时间:2014-05-29 00:46:38

标签: lua computercraft

这些论点有什么作用?如何在某处为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()

2 个答案:

答案 0 :(得分:3)

shell.run运行命令,就好像您已将其键入命令行一样。我认为你把它与goto混淆了,这是非常不同的。

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

实施例。 shell.run("ls")将运行ls命令,shell.run("rm", "foo.txt")将运行rm foo.txt

答案 1 :(得分: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()