Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tomkcook
Copy link

See the README for details.

Copy link

@taminomara taminomara left a 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)
Copy link

@taminomara taminomara Jan 24, 2025

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:

Suggested change
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)

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)

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:

Suggested change
local code, error = load(content)
local code, error = load(content, name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants