Command line switches
Posted: Mon Mar 24, 2014 1:22 am
Hello again, I have a question regarding love.load and its only argument.
I found in the default love.run function, love.load is called with 'arg', which seems to be a table containing all the switches passed in when a game is started. I was able to find out that much on my own, but I was wondering a few other details so that i can use them in a completed game.
For instance: The switches are divided into positive and negative indexes. Negative indexes are switches I did not pass in, but rather the ones love is passing into itself. The two that keep appearing are '-1 embedded boot.lua' and '-2 bin\CLF.exe' which is the directory of my fused game. I was wondering what might be the purpose of these two, and will any more negative indexes appear under special circumstances.
Another questions is the consistency of the order of switches. If I start my games as such: I get a table like this:
My question is, will all the switches I pass in always be in the correct order? In my example, switch #4 is an argument for the function specified by the 3rd switch (-width), and the same with switch 5 and 6. However, I could not find any documentation on this topic, and so theoretically, could the wrong switch could get the wrong data in front of it?
Both questions aren't of the highest importance, because i can do with out this functionality, but I am rather curious because I cant find a page on the love wiki or anywhere else describing the behavior of the 'arg' table that is passed in, and it would be nice if i could use them. If anyone can tell me how it all works, or point me to the right location, i would really appreciate it. I don't want to use it in my games if im not sure how they work entirely.
I found in the default love.run function, love.load is called with 'arg', which seems to be a table containing all the switches passed in when a game is started. I was able to find out that much on my own, but I was wondering a few other details so that i can use them in a completed game.
For instance: The switches are divided into positive and negative indexes. Negative indexes are switches I did not pass in, but rather the ones love is passing into itself. The two that keep appearing are '-1 embedded boot.lua' and '-2 bin\CLF.exe' which is the directory of my fused game. I was wondering what might be the purpose of these two, and will any more negative indexes appear under special circumstances.
Another questions is the consistency of the order of switches. If I start my games as such:
Code: Select all
bin\CLF.exe -nonetwork -debug -width 1280 -height 720
Code: Select all
arg = {
[-2] = "bin\CLF.exe"
[-1] = "embedded boot.lua"
[1] = "-nonetwork"
[2] = "-debug"
[3] = "-width"
[4] = "1280"
[5] = "-height"
[6] = "720"
}
Both questions aren't of the highest importance, because i can do with out this functionality, but I am rather curious because I cant find a page on the love wiki or anywhere else describing the behavior of the 'arg' table that is passed in, and it would be nice if i could use them. If anyone can tell me how it all works, or point me to the right location, i would really appreciate it. I don't want to use it in my games if im not sure how they work entirely.