fix: override dofile to preserve Opus env (require was nil in sub-modules)

CC:Tweaked dofile loads files with _G as environment, but Opus
injects require into the program's sandbox _ENV. All dofile'd
modules (especially display.lua) could not see require.

Also add dropperController to apps.db.
This commit is contained in:
MayaTheShy
2026-03-22 18:40:03 -04:00
parent 40e6eab42d
commit bb139b4afd
3 changed files with 23 additions and 0 deletions

View File

@@ -20,4 +20,9 @@
category = "Inventory", category = "Inventory",
run = "inventoryWebBridge.lua", run = "inventoryWebBridge.lua",
}, },
[ "im_dropper" ] = {
title = "Dropper Ctrl",
category = "Inventory",
run = "dropperController.lua",
},
} }

View File

@@ -27,6 +27,15 @@ local DROPPER_ANNOUNCE_INTERVAL = 30 -- seconds between dropper announcements
local _baseDir = fs.getDir(shell.getRunningProgram()) local _baseDir = fs.getDir(shell.getRunningProgram())
local function _path(rel) return fs.combine(_baseDir, rel) end local function _path(rel) return fs.combine(_baseDir, rel) end
-- Override dofile to load modules into our _ENV so they inherit
-- Opus's require/package (CC:Tweaked dofile uses _G instead).
local _ccDofile = dofile
local function dofile(path) -- luacheck: ignore
local fn, err = loadfile(path, nil, _ENV)
if fn then return fn()
else error(err, 2) end
end
local CLIENT_CONFIG_FILE = _path(".client_config") local CLIENT_CONFIG_FILE = _path(".client_config")
------------------------------------------------- -------------------------------------------------

View File

@@ -15,6 +15,15 @@
local _baseDir = fs.getDir(shell.getRunningProgram()) local _baseDir = fs.getDir(shell.getRunningProgram())
local function _path(rel) return fs.combine(_baseDir, rel) end local function _path(rel) return fs.combine(_baseDir, rel) end
-- Override dofile to load modules into our _ENV so they inherit
-- Opus's require/package (CC:Tweaked dofile uses _G instead).
local _ccDofile = dofile
local function dofile(path) -- luacheck: ignore
local fn, err = loadfile(path, nil, _ENV)
if fn then return fn()
else error(err, 2) end
end
------------------------------------------------- -------------------------------------------------
-- Structured logging & shared UI helpers -- Structured logging & shared UI helpers
------------------------------------------------- -------------------------------------------------