it is a long time since I last messed around with Minecraft and therefore CC. Some days ago I started implementing a UI framework which is inspired by the box design (HTML, Qt, ...). Therefore I have multiple files which contain one UI element each and I want to run a init.lua file via dofile() from my normal scripts to get all elements loaded.
Maybe my english is not good enough to understand the CC APIs but I can not figure out a way to use relative paths from the init file for the load process. At the moment it looks like this:
local modules = { "border", "option", "optionmenu", "window" } local pwd = ??? <--- How do I get the current directory of the init file? -- Load a UI element from file local function loadFile( fileName ) return dofile( fs.combine( pwd, fileName ) ) end local function init() local elements = {} for _, e in ipairs( modules ) do elements.insert( loadFile( e..".lua" ) ) end return elements end init()
My "normal" approach is to use something like this, but that only works if I run the init script directly which is not what I want:
local pwd = fs.getDir( shell.getRunningProgram() )
I hope some of you guys kann help me with this, I'd really appreciate that.
Cheers Mirodin
Edited by Mirodin, 25 May 2016 - 02:37 PM.