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

Need a little help with this

Started by Gryffin2009, 29 March 2014 - 09:10 PM
Gryffin2009 #1
Posted 29 March 2014 - 10:10 PM
Howdy! So, I've been fiddling with a startup program to lock the computer to users unless they have a password, right? Well…it's created an issue. Whenever I reboot a computer, I get the following error:

"bios:377: Too long without yielding"

When I place a computer, it works fine. But if I reboot that same, brand new computer…I get that error. I'm not too sure how to fix this. If someone could help, that'd be fantastic.

If for some reason you're interested in the startup program I created in case it broke something, here it is:

shell.run("monitor","left","title")
os.pullEvent = os.pullEventRaw
local w,h = term.getSize()
local function printCentered(str, ypos)
   term.setCursorPos(w/2-#str/2,ypos)
   term.write(str)
end
local function clsTerm()
   term.clear()
   term.setCursorPos(1,1)
end
local function drawHeader()
   printCentered(string.rep("-",w), 2)
   printCentered("GateLock", 4)
   printCentered("What is the Password?", 6)
   printCentered(string.rep("-",w), 8)
end
clsTerm()
drawHeader()
term.setCursorPos(1,10)
write("PASSWORD: ")
pass = read("*")
cpass = "xxxxxx"
if pass == (cpass) then
   clsTerm()
   printCentered("Welcome Admin", 4)
   sleep(1.5)
   clsTerm()
else
   clsTerm()
   printCentered("Incorrect Password!", 4)
   sleep(1.5)
   os.reboot()
end

Thanks in advance!
nateracecar5 #2
Posted 29 March 2014 - 10:27 PM
Can you give us your title program for the monitor? I think it might be in there, not sure….
Gryffin2009 #3
Posted 29 March 2014 - 10:35 PM
I just had it display a simple message. I since deleted the program. The program should run whether or not there is a title program, though.
nateracecar5 #4
Posted 30 March 2014 - 12:12 AM
I can't see anything wrong, why don't you remove the parenthesis around cpass? There is no need. Is there ANYTHING else that is running along side with that program? Maybe you didn't put it all there? This may be me, but I personally can't find anything.

EDIT: I'm gonna go out on a limb and say that it is the mod, not your startup program. The only thing I don't like about your program is that it does the os.pullEvent == os.pullEventRaw.

What I would do is pcall and test when the program exists, if the err is terminate, rerun the program. Look up pcall if you don't know what I'm talking about ;)/>
Edited on 29 March 2014 - 11:16 PM
Gryffin2009 #5
Posted 30 March 2014 - 05:10 AM
The program runs fine on its own. The issue seems to be when the computer shuts down. When I start up my server and open up the computer, the program is up and running. I input the password and it opens up just like it should. I can run the startup program again and it works perfectly. When I reboot it, I get that bios error. I'm not sure if it's something I've done. Perhaps it's an issue with the actual computers startup? As in the one all computers have on their rom?
Bomb Bloke #6
Posted 30 March 2014 - 08:21 AM
I would agree that it's something happening to os.pullEvent. I can't recall anything that would cause problems with what you're doing to it here, but if any of the other scripts you run before rebooting play with it, I'd be taking a strong look at them.

Does the issue occur if you type the wrong password (causing a reboot before this script completes)? Does it matter if you use os.reboot() or Ctrl+R?

A better practise would be to do something like this at the start of the program:

local oldEventPuller = os.pullEvent
os.pullEvent = os.pullEventRaw

Then at the end of the program you can undo your change:

os.pullEvent = oldEventPuller

Which version of ComputerCraft are we playing with?
Edited on 30 March 2014 - 06:24 AM
Gryffin2009 #7
Posted 30 March 2014 - 05:39 PM
Does the issue occur if you type the wrong password (causing a reboot before this script completes)? Does it matter if you use os.reboot() or Ctrl+R?

Both, actually. And I can take that line of code out and it still occurs. And I'm on Tekkit Classic, so 1.31 I believe.
Bomb Bloke #8
Posted 30 March 2014 - 10:20 PM
Ok. What happens if you empty out the whole script? Same thing?
Gryffin2009 #9
Posted 31 March 2014 - 12:15 AM
Well, it happens if I place a brand new computer. I can spawn one in, drop it, reboot it, and I still get this bios error.
Bomb Bloke #10
Posted 31 March 2014 - 08:11 AM
Then the issue's not in your code - unfortunately there's likely not much you can do about this while using that old pack.