-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Universal bootloader #4
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just started using this mod, but I'm very glad to see this PR, and I'd like to see it merged! Here are a improvements I could think of after using it for a while.
if code then | ||
-- We don't really expect this to return | ||
computer.log(0, "Starting " .. name) | ||
local success, error = pcall(code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using xpcall
to display proper traceback:
local success, error = pcall(code) | |
local success, error = xpcall(code) | |
if not success then | |
computer.log(3, error.message.."\n"..error.trace) |
end | ||
end | ||
|
||
function bootloader:loadModule(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think loadModule
should check if a module with this name was already loaded (or in progress of loading), and skip it. Otherwise, a module might be loaded twice if a user manually calls bootloader:loadModule("display.lua")
.
local content = self:loadCode(name) | ||
if content then | ||
computer.log(0, "Parsing loaded content") | ||
local code, error = load(content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, you can pass the module name to the load
function to enhance tracebacks even further:
local code, error = load(content) | |
local code, error = load(content, name) |
See the README for details.