Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. local args = {...} --get the arguments from the command line and put them in the table named args
  2.  
  3. if #args < 1 then --if we did not get any arguments, tell the user to provide them
  4.   print("Usage: "..fs.getName(shell.getRunningProgram()).." <length>") --fancy stuff to print the name of the program.
  5.   return --quit early, since we got no arguments.
  6. elseif tonumber(args[1]) == nil then --the user gave us an argument, but it was not a number! Print usage again.
  7.   print("Usage: "..fs.getName(shell.getRunningProgram()).." <length>")
  8.   return
  9. end
  10.  
  11. --now, since the code made it here, we must have at least one argument that can be made into a number.
  12.  
  13. local length = tonumber(args[1]) --take the first argument (that is the [1] part, the first index of the table), convert it to a number, and store the result in our length variable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement