Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local shell = require ( 'shell' )
- local options = shell.parse ( ... )
- local valid = {}
- valid = {
- ['forward'] = function (a) valid ['_'](a) end,
- ['back'] = function (a) valid ['_'](a) end,
- ['up'] = function (a) valid ['_'](a) end,
- ['down'] = function (a) valid ['_'](a) end,
- ['left'] = function (a) for i=1,a do require('robot').turnLeft () end end,
- ['right'] = function (a) for i=1,a do require ('robot').turnRight () end end,
- ['_'] = function (a) for i=1,a do require('robot') [options[1]] () end end,
- }
- if options[1] ~= '_' and valid [options[1]] then
- valid [options[1]](tonumber(options[2]) or 1)
- else
- io.write ( 'Usage: go direction [amount]\n' )
- io.write ( 'Direction: forward,back,up,down,left or right\n' )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement