Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- this program really sucks!
- -- it sucks in front, below and ontop of the turtle.
- -- Created Mar 21, 2014 by Kreezxil
- function help()
- print("\
- usage: suck [direction] [times]\
- Where [direction] is one of:\
- front, up, down or f, u, d or\
- nothing at all and it will default\
- to 'front' and where [times] is how\
- many times you want it to suck, default is 1")
- end
- function suck(dir,amt)
- for n=1,amt do
- if dir == 'f' then
- turtle.suck()
- print("I'm sucking.")
- elseif dir == 'd' then
- turtle.suckDown()
- print("I'm sucking from below me.")
- else
- -- only option left now is 'up'
- turtle.suckUp()
- print("I'm sucking from above me.")
- end
- end
- end
- -- Process Arguments
- local tArgs = { ... }
- local direction = 'f'
- local times = 1
- if #tArgs == 2 then
- times = tonumber( tArgs[2] )
- end
- if #tArgs >= 1 then
- if tonumber( tArgs[1] ) ~= nil then
- -- ie suck 20, implies suck front 20
- times = tonumber( tArgs[1] )
- else
- direction = string.lower(string.sub( tArgs[1],1,1 ))
- end
- end
- --[[ Process command directives --]]
- local paramError = 0
- if tArgs[1] == "help" then
- help()
- return
- end
- if times <= 0 then
- print("You must specify a positive number for [times] or no number at all")
- paramError = paramError + 1
- end
- if string.find("fud",direction) == nil then
- print("Direction must be one of: front, up, down, f, u, or d")
- paramError = paramError + 1
- end
- if paramError > 0 then
- print("")
- print("Number of parameter errors are " .. paramError)
- print("Try:\n\tsuck help")
- return
- end
- suck(direction,times)
Add Comment
Please, Sign In to add comment