This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
nutcase84's profile picture

BSoD Fail

Started by nutcase84, 05 January 2013 - 07:14 AM
nutcase84 #1
Posted 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?


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
PixelToast #2
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
nutcase84 #3
Posted 05 January 2013 - 08:27 AM
you sould center the text by using term.getSize
How?
And thank you. :D/>
EDIT: And it didn't have a error, it just didn't return anything. How would i detect a nil?
remiX #4
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.
print sould have parenthese

Doesn't need it.
nutcase84 #5
Posted 05 January 2013 - 08:38 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.
print sould have parenthese

Doesn't need it.
Thanks. I will try that. But if the OS fails, Will it return false?
Lyqyd #6
Posted 05 January 2013 - 08:55 AM
Yes, it should return false if the program errors.
nutcase84 #7
Posted 05 January 2013 - 09:00 AM
Yes, it should return false if the program errors.
Thank you Lyqyd.
nutcase84 #8
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?
Kingdaro #9
Posted 05 January 2013 - 10:05 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.
Lyqyd #10
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.
nutcase84 #11
Posted 05 January 2013 - 11:42 AM
Can you put it in my code? Thanks.
ChunLing #12
Posted 05 January 2013 - 06:29 PM
Hmmm…yes, but it will be untested. You're better off understanding the functions dofile() and pcall() I'm particularly concerned about whether dofile() even works with CC computer files. Does it?
Kingdaro #13
Posted 05 January 2013 - 06:41 PM
Hmmm…yes, but it will be untested. You're better off understanding the functions dofile() and pcall() I'm particularly concerned about whether dofile() even works with CC computer files. Does it?
Yep. Use it in a couple of my programs.
ChunLing #14
Posted 05 January 2013 - 07:16 PM
So, [[ local ok, err = pcall(dofile,".os/nos") ]] should work?
PixelToast #15
Posted 05 January 2013 - 08:14 PM
yeah, but it might be buggy for things that use the shell api extensively
nutcase84 #16
Posted 06 January 2013 - 03:12 AM
Thanks guys. I also have another problem.


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.)
Lyqyd #17
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.
MysticT #18
Posted 06 January 2013 - 09:28 AM
Thanks guys. I also have another problem.


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.)
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).
nutcase84 #19
Posted 06 January 2013 - 01:51 PM
[you can't use the shell api in an api
How do I run apps in the api then?
Kingdaro #20
Posted 06 January 2013 - 02:52 PM
dofile() works.