shell.run("clear")
print "Loading Kernel..."
local kernel = os.loadAPI(".os/kernel")
print "Loading OS..."
local os = shell.run(".os/nos")
if kernel == nil or os == nil then
term.setBackgroundColor(colors.blue)
shell.run("clear")
term.setCursorPos(11,11)
print "Epic Fail!"
end
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
BSoD Fail
Started by nutcase84, 05 January 2013 - 07:14 AMPosted 05 January 2013 - 08:14 AM
So, I was making the BSoD(Blue Screen of Death) for my OS(Nut OS) and it doesn't work. What am I doing wrong?
Posted 05 January 2013 - 08:19 AM
well um, first of all
you didnt give us an error
print sould have parenthese
os.loadAPI dosent return anything
shell.run dosent return anything
term.setBackgroundColor dosent set the whole background
you sould center the text by using term.getSize
you didnt give us an error
print sould have parenthese
os.loadAPI dosent return anything
shell.run dosent return anything
term.setBackgroundColor dosent set the whole background
you sould center the text by using term.getSize
Posted 05 January 2013 - 08:27 AM
How?you sould center the text by using term.getSize
And thank you. :D/>
EDIT: And it didn't have a error, it just didn't return anything. How would i detect a nil?
Posted 05 January 2013 - 08:35 AM
I don't think loading an api or running a program returns true or false, or am I wrong?
Else you could set a global value within the api and check the value within your program, if it's false then bsod.
Doesn't need it.
Else you could set a global value within the api and check the value within your program, if it's false then bsod.
print sould have parenthese
Doesn't need it.
Posted 05 January 2013 - 08:38 AM
Thanks. I will try that. But if the OS fails, Will it return false?I don't think loading an api or running a program returns true or false, or am I wrong?
Else you could set a global value within the api and check the value within your program, if it's false then bsod.print sould have parenthese
Doesn't need it.
Posted 05 January 2013 - 08:55 AM
Yes, it should return false if the program errors.
Posted 05 January 2013 - 09:00 AM
Thank you Lyqyd.Yes, it should return false if the program errors.
Posted 05 January 2013 - 09:17 AM
remiX, it did not work. It just exits everything when there is a error, and doesn't display the BSoD. Is there any other solutions?
Posted 05 January 2013 - 10:05 AM
Catch the error with pcall?
Makes it so that the program can't exit from an error no matter what. If that's not the problem, try putting a sleep at the end of the program so you can see what happens before anything exits.
local ok, err = pcall(shell.run, ".os/nos")
Makes it so that the program can't exit from an error no matter what. If that's not the problem, try putting a sleep at the end of the program so you can see what happens before anything exits.
Posted 05 January 2013 - 11:04 AM
Catch the error with pcall?local ok, err = pcall(shell.run, ".os/nos")
Makes it so that the program can't exit from an error no matter what. If that's not the problem, try putting a sleep at the end of the program so you can see what happens before anything exits.
This won't catch the error. shell.run always exits without errors because os.run catches and handles the errors. You'd need to override printError (called by os.run) to error, or use a custom run function. pcall()ing dofile() may meet your needs.
Posted 05 January 2013 - 11:42 AM
Can you put it in my code? Thanks.
Posted 05 January 2013 - 06:41 PM
Yep. Use it in a couple of my programs.
Posted 05 January 2013 - 07:16 PM
So, [[ local ok, err = pcall(dofile,".os/nos") ]] should work?
Posted 05 January 2013 - 08:14 PM
yeah, but it might be buggy for things that use the shell api extensively
Posted 06 January 2013 - 03:12 AM
Thanks guys. I also have another problem.
(I have the getMouseClick function and the item1cmd var.)
x, y, button = getMouseClick()
if x >= xlocation and x <= x1 and y == ylocation then --item1
shell.run(item1cmd)
end
This does not work. It gives me a nil at shell.run. why?(I have the getMouseClick function and the item1cmd var.)
Posted 06 January 2013 - 09:02 AM
You're asking us this because we are psychic and therefore know what getMouseClick does despite you not showing us the function? Post the whole code, please.
Posted 06 January 2013 - 09:28 AM
Is the code in an api? If it is then that's the problem, you can't use the shell api in an api (there's some posts with an explanation about why this happens).Thanks guys. I also have another problem.This does not work. It gives me a nil at shell.run. why?x, y, button = getMouseClick() if x >= xlocation and x <= x1 and y == ylocation then --item1 shell.run(item1cmd) end
(I have the getMouseClick function and the item1cmd var.)
Posted 06 January 2013 - 01:51 PM
How do I run apps in the api then?[you can't use the shell api in an api
Posted 06 January 2013 - 02:52 PM
dofile() works.