Difference between revisions of "love.filesystem.getSourceBaseDirectory"

m
(Add love.filesystem.getSource to See Also section)
 
Line 36: Line 36:
 
* [[love.filesystem.mount]]
 
* [[love.filesystem.mount]]
 
* [[love.filesystem.isFused]]
 
* [[love.filesystem.isFused]]
 +
* [[love.filesystem.getSource]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{#set:Description=Returns the full path to the directory containing the .love file.}}
 
{{#set:Description=Returns the full path to the directory containing the .love file.}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.filesystem.getSourceBaseDirectory}}
 
{{i18n|love.filesystem.getSourceBaseDirectory}}

Latest revision as of 18:14, 16 September 2016

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

Other Languages