Refactor module loading to use dynamic base directory path
This commit is contained in:
@@ -8,19 +8,26 @@
|
||||
-- manager/display.lua — dashboard rendering & touch handlers
|
||||
-- inventoryManager.lua — this file: orchestrator, main(), network handler
|
||||
|
||||
-------------------------------------------------
|
||||
-- Resolve base directory for portable path resolution
|
||||
-------------------------------------------------
|
||||
|
||||
local _baseDir = fs.getDir(shell.getRunningProgram())
|
||||
local function _path(rel) return fs.combine(_baseDir, rel) end
|
||||
|
||||
-------------------------------------------------
|
||||
-- Structured logging & shared UI helpers
|
||||
-------------------------------------------------
|
||||
|
||||
local log = dofile("lib/log.lua")
|
||||
local ui = dofile("lib/ui.lua")
|
||||
local log = dofile(_path("lib/log.lua"))
|
||||
local ui = dofile(_path("lib/ui.lua"))
|
||||
|
||||
-------------------------------------------------
|
||||
-- Load modules (factory pattern → shared context)
|
||||
-------------------------------------------------
|
||||
|
||||
local cfg = dofile("manager/config.lua")(log)
|
||||
local state = dofile("manager/state.lua")()
|
||||
local cfg = dofile(_path("manager/config.lua"))(log, _path)
|
||||
local state = dofile(_path("manager/state.lua"))()
|
||||
|
||||
-- Shared context table (Lua tables are by-reference, so all
|
||||
-- modules see the same mutable cache/activity/etc)
|
||||
@@ -35,10 +42,10 @@ local ctx = {
|
||||
craftTurtleName = nil,
|
||||
}
|
||||
|
||||
local ops = dofile("manager/operations.lua")(ctx)
|
||||
local ops = dofile(_path("manager/operations.lua"))(ctx)
|
||||
ctx.ops = ops
|
||||
|
||||
local display = dofile("manager/display.lua")(ctx)
|
||||
local display = dofile(_path("manager/display.lua"))(ctx)
|
||||
ctx.display = display
|
||||
|
||||
-- Convenience aliases
|
||||
|
||||
Reference in New Issue
Block a user