summaryrefslogtreecommitdiff
path: root/src/preload.lua
diff options
context:
space:
mode:
authorAlexander M Pickering <alex@cogarr.net>2025-01-25 20:40:09 -0600
committerAlexander M Pickering <alex@cogarr.net>2025-01-25 20:40:09 -0600
commitb174b8c00026253fd40ec262e430b0bb764e31ea (patch)
tree173d294b98fe14727aef9cd42542f41a940f5ffa /src/preload.lua
parent89a8f94ac0206412c1a2d7b8766d97dbdbd36253 (diff)
downloadggj25-b174b8c00026253fd40ec262e430b0bb764e31ea.tar.gz
ggj25-b174b8c00026253fd40ec262e430b0bb764e31ea.tar.bz2
ggj25-b174b8c00026253fd40ec262e430b0bb764e31ea.zip
work
Diffstat (limited to 'src/preload.lua')
-rw-r--r--src/preload.lua24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/preload.lua b/src/preload.lua
index ca2dc9a..5b4034d 100644
--- a/src/preload.lua
+++ b/src/preload.lua
@@ -3,6 +3,7 @@
--[[
rewrite traceback function to map file names and line numbers to moonscript
]]
+local require_order = {}
local old_traceback = debug.traceback
debug.traceback = function(...)
local orig_traceback = old_traceback(...)
@@ -23,9 +24,30 @@ debug.traceback = function(...)
end
end
return string.format("%s:%d:", filename, linenum)
- end)
+ end) .. "\nRequire order: [" .. table.concat(require_order, ",\n") .. "]"
end
+local old_require = require
+local required = {}
+require = function(...)
+ args = {...}
+ if not required[args[1]] then
+ required[args[1]] = true
+ table.insert(require_order, args[1])
+ end
+ return old_require(...)
+end
+
+--[[
+Display where print statements are comming from
+
+local oldprint = print
+print = function(...)
+ oldprint(...)
+ oldprint(debug.traceback())
+end
+]]
+
-- Override tostring to display more info about the table
local old_tostring = tostring
local numtabs = 0