love.filesystem.getSourceBaseDirectory

love.filesystem.getSourceBaseDirectory

Available since LÖVE 0.9.0
This function is not supported in earlier versions.

Returns the full path to the directory containing the .love file. If the game is fused to the LÖVE executable, then the directory containing the executable is returned.

If love.filesystem.isFused is true, the path returned by this function can be passed to love.filesystem.mount, which will make the directory containing the main game (e.g. C:\Program Files\coolgame\) readable by love.filesystem.

Function

Synopsis

path = love.filesystem.getSourceBaseDirectory( )

Arguments

None.

Returns

string path
The full platform-dependent path of the directory containing the .love file.

Examples

read files in the same folder as the game's .exe file

if love.filesystem.isFused() then
    local dir = love.filesystem.getSourceBaseDirectory()
    local success = love.filesystem.mount(dir, "coolgame")
 
    if success then
        -- If the game is fused and it's located in C:\Program Files\mycoolgame\,
        -- then we can now load files from that path.
        coolimage = love.graphics.newImage("coolgame/coolimage.png")
    end
end
 
function love.draw()
    if coolimage then
        love.graphics.draw(coolimage, 0, 0)
    end
end

See Also

doc_love
2017-03-21 15:46:14
Comments
Leave a Comment

Please login to continue.