PSanf2

Untitled

Jun 26th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. os.loadAPI("disk/go")
  2.  
  3. local function printUsage()
  4. print("Usage: move <direction> <distance>\n")
  5. print("Valid directions are")
  6. print("\tforward, backward, left, right")
  7. print("\tnorth, south, east, west")
  8. print("\tup, down\n")
  9. end
  10.  
  11. local tArgs = { ... }
  12. if #tArgs < 1 then
  13. printUsage()
  14. return
  15. end
  16.  
  17. local sDir = tArgs[1]
  18. local iDis = 1
  19. if #tArgs >= 2 then
  20. iDis = tArgs[2]
  21. end
  22.  
  23. if (sDir == "north") or (sDir == "forward") then
  24. go.north(iDis)
  25. elseif (sDir == "south") or (sDir == "backward") then
  26. go.south(iDis)
  27. elseif (sDir == "west") or (sDir == "left") then
  28. go.west(iDis)
  29. elseif(sDir == "east") or (sDir =="right") then
  30. go.east(iDis)
  31. elseif sDir == "up" then
  32. go.up(iDis)
  33. elseif sDir == "down" then
  34. go.down(iDis)
  35. else
  36. print("Invalid direction.\n")
  37. printUsage()
  38. end
Advertisement
Add Comment
Please, Sign In to add comment