Is it possible to get the directory a love game that was launched?
unknown/path/to/myGame.exe
I don't think that there is a way but I couldn't find a post about it and thought it was worth asking
Finding myGame.exe path
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Finding myGame.exe path
Thanks works great!
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
Re: Finding myGame.exe path
That would work if the game is launched using the .love file.Robin wrote:arg[1]
But for a standalone binary, arg[1] is nil unless the player sets launch parameters like "./mygame -a"
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: [Solved] Finding myGame.exe path
Is that right? I thought that would give the path to the executable in that case. (Not inclined to test it right now.)
Help us help you: attach a .love.
Re: Finding myGame.exe path
Sorry I only tested it with a .love file and figured that it would work with .exe's as well Opps!Ubermann wrote:That would work if the game is launched using the .love file.Robin wrote:arg[1]
Using the following code in a .bat file it works (it isn't a great work around but it does the job.) (I will have to make equivalents for macs and linux)Ubermann wrote: But for a standalone binary, arg[1] is nil unless the player sets launch parameters like "./mygame -a"
Code: Select all
for /F %%x in ('CHDIR') do set path=%%x
testGame.exe "%path%/testGame.exe"
Code: Select all
copy /b launch.bat+love.exe+testGame.love testGame.exe
Is it possible to add all of the files together into one .exe?
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
Re: Finding myGame.exe path
I found another solution! This one doesn't use a .bat file. I used the LoveFS lib to make executing os commands a little easier. Here's the code in main.lua
After some testing I found that it won't work if the game is launched from the terminal
or of course if the file was renamed.
Code: Select all
require 'lovefs/lovefs'
function love.load()
fs = lovefs()
if not(arg[1]) then
if love._os == 'Windows' then
a, b = fs:run('cd')
b = b..'\\'
else
a, b = fs:run('pwd')
b = b..'/'
end
else
b = arg[1]
end
end
function love.draw()
love.graphics.print( b..'test.exe', 0, 0)
end
or of course if the file was renamed.
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
Who is online
Users browsing this forum: Semrush [Bot] and 4 guests