Command line switches

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
CorruptionEX
Prole
Posts: 8
Joined: Mon Oct 21, 2013 7:55 pm

Command line switches

Post by CorruptionEX »

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:

Code: Select all

 bin\CLF.exe -nonetwork -debug -width 1280 -height 720
I get a table like this:

Code: Select all

arg = {
  [-2] = "bin\CLF.exe"
  [-1] = "embedded boot.lua"
  [1] = "-nonetwork"
  [2] = "-debug"
  [3] = "-width"
  [4] = "1280"
  [5] = "-height"
  [6] = "720"
}
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.
═══ஜ۩CorruptionEX۩ஜ═══
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Command line switches

Post by bartbes »

The arg table represents all visible and hidden arguments, which might also contain the love binary and the .love file. That said, it's always described in such a way that arg[1] is the first passed-in argument. They are also in order, simply because that's the only thing that makes sense.
CorruptionEX
Prole
Posts: 8
Joined: Mon Oct 21, 2013 7:55 pm

Re: Command line switches

Post by CorruptionEX »

Thank you, however, I am still curious about the 'embedded boot.lua' switch. What is that there for?
═══ஜ۩CorruptionEX۩ஜ═══
User avatar
tio
Citizen
Posts: 61
Joined: Thu Dec 12, 2013 1:04 pm
Location: BR BR?
Contact:

Re: Command line switches

Post by tio »

CorruptionEX wrote:Thank you, however, I am still curious about the 'embedded boot.lua' switch. What is that there for?
It's used for some initializations. You can see the code here.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 7 guests