-
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
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) |
found containing the file specified then it will load the file from that drive. | ||
|
||
If no drive is found containing the requested file then the file will be requested | ||
from the network using the net-boot protocol on port 8. |
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.
you can also add a link to the net-boot package [net-boot protocol](/package/NetBoot)
See the README for details.