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
|
-- manager/display.lua — dashboard rendering & touch handlers
|
||||||
-- inventoryManager.lua — this file: orchestrator, main(), network handler
|
-- 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
|
-- Structured logging & shared UI helpers
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
local log = dofile("lib/log.lua")
|
local log = dofile(_path("lib/log.lua"))
|
||||||
local ui = dofile("lib/ui.lua")
|
local ui = dofile(_path("lib/ui.lua"))
|
||||||
|
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
-- Load modules (factory pattern → shared context)
|
-- Load modules (factory pattern → shared context)
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
local cfg = dofile("manager/config.lua")(log)
|
local cfg = dofile(_path("manager/config.lua"))(log, _path)
|
||||||
local state = dofile("manager/state.lua")()
|
local state = dofile(_path("manager/state.lua"))()
|
||||||
|
|
||||||
-- Shared context table (Lua tables are by-reference, so all
|
-- Shared context table (Lua tables are by-reference, so all
|
||||||
-- modules see the same mutable cache/activity/etc)
|
-- modules see the same mutable cache/activity/etc)
|
||||||
@@ -35,10 +42,10 @@ local ctx = {
|
|||||||
craftTurtleName = nil,
|
craftTurtleName = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
local ops = dofile("manager/operations.lua")(ctx)
|
local ops = dofile(_path("manager/operations.lua"))(ctx)
|
||||||
ctx.ops = ops
|
ctx.ops = ops
|
||||||
|
|
||||||
local display = dofile("manager/display.lua")(ctx)
|
local display = dofile(_path("manager/display.lua"))(ctx)
|
||||||
ctx.display = display
|
ctx.display = display
|
||||||
|
|
||||||
-- Convenience aliases
|
-- Convenience aliases
|
||||||
|
|||||||
Reference in New Issue
Block a user