Advertisement
tmtowtdi

bin/go_home

Oct 26th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. --go_home nCp8t5Q1 1478290485
  2.  
  3. local args   = {...}
  4. function die_usage()
  5.   print("---------------------------------------")
  6.   print("bin/go_home [height] [, name]")
  7.   print("")
  8.   print("Send the turtle to its home spot (set")
  9.   print("with bin/set_home).  ")
  10.   print("")
  11.   print("height - Y coord to fly to first.")
  12.   print("  Defaults to 100.")
  13.   print("name - which home to go to.  Defaults")
  14.   print("  to 'home'.")
  15.   print("---------------------------------------")
  16. end
  17. if args[1] == "-h" then die_usage() return end
  18.  
  19. if not turtle then error("This is not a turtle!") end
  20. if not os.loadAPI("lib/move") then return end
  21. local height = args[1] or 100
  22. local name   = args[2] or 'home'
  23.  
  24. if move.has_home(name) then
  25.   move.go_home(height, name)
  26. else
  27.   error("You don't have a home named "..name..".  Set one using bin/set_home.")
  28.   return
  29. end
  30.  
  31.  -- vim: syntax=lua ts=2 sw=2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement