55 posts
Posted 28 March 2015 - 04:47 PM
I want to create a program that will read the text after the program name, so something like this: 'Enderchest List' that will list all the ender chests i have from Ender Storage. How do i make my program find key words after the program name?
957 posts
Location
Web Development
Posted 28 March 2015 - 05:45 PM
Do you mean the program will read text from a file?
To do that, you'll need the fs APIOh, you meant capturing arguments when running the program, that explains a lot
Lyqyd covered it pretty well below
Edited on 28 March 2015 - 08:23 PM
8543 posts
Posted 28 March 2015 - 06:14 PM
I think he means that he wants to use command-line arguments to change the behavior of his program. To do so, you need to capture the arguments the shell passes in to your program:
local args = {...}
Notice that we captured the arguments into a table. The shell will split up the string you used to run the program, with space characters as the separator. So, in your example, "enderchest list", the shell would send a table containing "list" at index 1. So to compare against the first argument, you would do something like this:
local args = {...}
if args[1] == "list" then
listEnderChests()
end
55 posts
Posted 29 March 2015 - 12:12 AM
Thanks! Great help!