Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local a = ...
- if not a then error("Must include a valid command sequence") end
- local cmds = {
- ["l"]=turtle.turnLeft,
- ["r"]=turtle.turnRight,
- ["d"]=turtle.down,
- ["u"]=turtle.up,
- ["f"]=turtle.forward,
- ["b"]=turtle.back,
- ["a"]=function() turtle.turnLeft() turtle.turnLeft() end,
- ["s"]=os.reboot
- }
- for c,rep in a:gmatch("(%a)(%d*)") do
- local cmd = cmds[c]
- if not cmd then error("Unrecognised command: "..c) end
- if tonumber(rep) then
- for i=1,tonumber(rep) do
- cmd()
- end
- else cmd() end
- end
Advertisement
Add Comment
Please, Sign In to add comment