Last active
December 12, 2015 10:09
-
-
Save SquidLord/4757117 to your computer and use it in GitHub Desktop.
t: ComputerCraft turtle command line nav tool. Takes a single string and parses it as directions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- t: ComputerCraft turtle command line nav tool. Takes a single string and parses it as directions | |
-- by Alexander "SquidLord" Williams (SaladinVrai) | |
-- Gist: https://gist.github.com/SquidLord/4757117 | |
-- Load libraries | |
os.loadAPI("squid/squidlib") | |
os.loadAPI("squid/turtlelib") | |
ARGS = {...} | |
function main() | |
if not ARGS[1] then | |
usage() | |
return nil | |
else | |
MT = turtlelib.makeMoveTable(turtle) -- Initialize the parser from the base turtle motions | |
Moves = turtlelib.stringToMoves(ARGS[1], MT) -- Build the move list | |
print("Moving turtle: "..ARGS[1]) | |
turtlelib.executeMoves(Moves) -- Make stuff happen | |
end | |
end | |
function usage() | |
UsageText = { "SquidOS Turtle Movement Program ...", | |
" Takes a string of letters as directives on how to move the drone.", | |
"", | |
" Acceptable letters are:", | |
" f - Forward", | |
" b - Back", | |
" u - Up", | |
" d - Down", | |
" l - Turn left", | |
" r - Turn right", | |
" L - Move Left 1m but keep facing", | |
" R - Move Right 1m but keep facing"} | |
squidlib.printTable(UsageText) | |
end | |
--- | |
--- Main | |
--- | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment