I have a storyboard file and I want to reference the name of the file that the storyboard is implemented in so that I can load a configuration file of the same base name.
Here is an example that is in a file called scene001.lua
-- Called when the scene's view does not exist:
function scene:createScene( event )
local screenGroup = self.view
local json = require("json")
-- load the book definition file
local contents = textFromFile("scene001.json")
local page = json.decode(contents)
image = buildPage(page)
screenGroup:insert(image)
image.touch = onSceneTouch
end
As you can see I have to hard code the "scene001.json"
. I want to load a configuration file of the with the same name as the current storyboard, how can I do this dynamically?
I actually found a better more official way of doing this without all the regex sillyness needed to parse the path. Of the potential performance implications of using debug.getinfo()
.