Command line parameters not working

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
PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

Command line parameters not working

Post by PGUp » Sun Aug 04, 2019 10:27 am

Code: Select all

function love.load(arg)
    for i,v in pairs(arg) do
		print(v)
	end
end
I ran the .love file with the following command:

Code: Select all

main.love test a b c
the output of the print function is not showing the argument i passed with the command line
-

Konikoko
Prole
Posts: 3
Joined: Sat Aug 03, 2019 3:14 pm

Re: Command line parameters not working

Post by Konikoko » Sun Aug 04, 2019 3:41 pm

I tried the following command in my cmd:

Code: Select all

"C:\Program Files\LOVE\love.exe" "tester" a b
and it worked for me.

I put the main.lua in a folder called tester with the following code:

Code: Select all

function love.load(arg)
    for i,v in pairs(arg) do
		print(v)
	end
end

function love.update(dt)
end

function love.draw()
end
And I also wrote a conf.lua:

Code: Select all

function love.conf(t)
	t.console = true
end

User avatar
pgimeno
Party member
Posts: 1943
Joined: Sun Oct 18, 2015 2:58 pm
Location: Valencia, ES

Re: Command line parameters not working

Post by pgimeno » Sun Aug 04, 2019 9:59 pm

My guess: that calling the file, so that the executable to run is determined by extension, is not passing the additional parameters to said executable.

Try checking if there is any mechanism in your OS to solve that, or call the executable yourself as Konikoko suggests.

ketkipatil
Prole
Posts: 1
Joined: Tue Aug 06, 2019 7:07 am

Re: Command line parameters not working

Post by ketkipatil » Tue Aug 06, 2019 7:08 am

Good explaination..

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests