Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("disk/go")
- local function printUsage()
- print("Usage: move <direction> <distance>\n")
- print("Valid directions are")
- print("\tforward, backward, left, right")
- print("\tnorth, south, east, west")
- print("\tup, down\n")
- end
- local tArgs = { ... }
- if #tArgs < 1 then
- printUsage()
- return
- end
- local sDir = tArgs[1]
- local iDis = 1
- if #tArgs >= 2 then
- iDis = tArgs[2]
- end
- if (sDir == "north") or (sDir == "forward") then
- go.north(iDis)
- elseif (sDir == "south") or (sDir == "backward") then
- go.south(iDis)
- elseif (sDir == "west") or (sDir == "left") then
- go.west(iDis)
- elseif(sDir == "east") or (sDir =="right") then
- go.east(iDis)
- elseif sDir == "up" then
- go.up(iDis)
- elseif sDir == "down" then
- go.down(iDis)
- else
- print("Invalid direction.\n")
- printUsage()
- end
Advertisement
Add Comment
Please, Sign In to add comment