From 57fd3e88bcba5cd05cac74e85e209beb4df38c3a Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sun, 22 Mar 2026 16:07:43 -0400 Subject: [PATCH] fix: resolve all paths relative to script directory for Opus package compatibility - Add _baseDir/_path() resolution using shell.getRunningProgram() in all entry-point scripts (inventoryManager, inventoryClient, craftingTurtle, inventoryWebBridge) - Pass _path function through to manager/config.lua for data/ and config files - Config files (.manager_config, .inventory_cache, etc.) now resolve relative to the package directory rather than CWD - Exclude startup/ auto-updater scripts from Opus .package manifest - All dofile() calls now use _path() for portable path resolution --- manager/config.lua | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/manager/config.lua b/manager/config.lua index 25ec063..f6bed40 100644 --- a/manager/config.lua +++ b/manager/config.lua @@ -1,7 +1,10 @@ -- manager/config.lua — Configuration constants, data tables, and lookup structures --- Usage: local cfg = dofile("manager/config.lua")(log) +-- Usage: local cfg = dofile(_path("manager/config.lua"))(log, _path) -return function(log) +return function(log, _path) + +-- Fall back to CWD-relative if _path not provided (standalone use) +if not _path then _path = function(p) return p end end local C = {} @@ -19,9 +22,9 @@ C.SMELT_RESERVE = 128 C.DEFRAG_INTERVAL = 600 C.COMPOST_INTERVAL = 3 C.ALERT_INTERVAL = 15 -C.CACHE_FILE = ".inventory_cache" +C.CACHE_FILE = _path(".inventory_cache") C.SMELTER_MONITOR_SIDE = "top" -C.DISABLED_RECIPES_FILE = ".disabled_recipes" +C.DISABLED_RECIPES_FILE = _path(".disabled_recipes") -- Network C.BROADCAST_CHANNEL = 4200 @@ -57,7 +60,7 @@ C.SLOT_OUTPUT = 3 -- Config file loader ------------------------------------------------- -local CONFIG_FILE = ".manager_config" +local CONFIG_FILE = _path(".manager_config") function C.loadConfig() if not fs.exists(CONFIG_FILE) then return end @@ -97,13 +100,13 @@ end -- Data tables ------------------------------------------------- -C.SMELTABLE = dofile("data/smeltable.lua") -C.FUEL_LIST = dofile("data/fuel.lua") -local _compostData = dofile("data/compostable.lua") +C.SMELTABLE = dofile(_path("data/smeltable.lua")) +C.FUEL_LIST = dofile(_path("data/fuel.lua")) +local _compostData = dofile(_path("data/compostable.lua")) C.COMPOSTABLE = _compostData.items C.COMPOST_TRASH = _compostData.trash -C.CRAFTABLE = dofile("data/craftable.lua") -C.LOW_STOCK_ALERTS = dofile("data/alerts.lua") +C.CRAFTABLE = dofile(_path("data/craftable.lua")) +C.LOW_STOCK_ALERTS = dofile(_path("data/alerts.lua")) -- Pre-build furnace compatibility sets for O(1) lookup for _, recipe in pairs(C.SMELTABLE) do