Is there any way to load an image at a path relative to the
.lua file that's executing? I know standard convention is to place all images in the
/images directory, but I'd like to colocate some level images with their corresponding files.
As far as I can tell,
image.new always expects an absolute path, so I suppose this amounts to asking whether there's any way for a Lua script to introspect its own import path relative to the root of the project in order to construct the full path to the colocated image.
Unfortunately, even if that were possible I'm not sure it would suffice. I tried manually constructing a path in similar fashion:
local lanePath = "alleys/groovy-gutters/lanes/" local bgImagePath = "../images/CurveLeft" local bgImage = gfx.image.new(lanePath .. bgImagePath)
The above "works" (in the simulator), but yields the following warning:
warning: access to /Data/com.ebenliason.driftpin/alleys/groovy-gutters/lanes/../images/CurveLeft.pdi is not allowed on the device
I suspect that
image.new is just treating any path with a relative component within it as illegal, even though it remains within the sandboxed directory.