Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Memelord420

Boot Script Password Protection

Question

So, basically I want to password protect my computer, and autorun.lua doesn't work when the computer starts, so I decided to make a boot script. The script runs last during the booting process, but this extremely simple code I'm trying to run bluescreens me and forces me to reinstall. (It's not that big a deal because I'm testing it all in creative before I bring it to survival) If anybody could help me, I'd appreciate it.

Broken Code:

local computer = require("computer")
local io = require("io")

print("Access Restricted")
print("Password: ")
password = io.read()
if password == "Password" then
	print("ACCESS GRANTED!")
else
	print("ACCESS DENIED!")
	computer.shutdown(true)
end

 

Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0
4 hours ago, TYKUHN2 said:

What's the bluescreen error and how are you running the script?

The bluescreen error is

init:93: /lib/term.lua:234: attempt to index local 'w' (a nil value)

and I'm running the script just by making it in the boot directory. I didn't change anything in init.lua, I just figured that the highest number boot script gets ran last, so I made a boot script called 100_password.lua and it got ran, but it bluescreened me.

Link to post
Share on other sites
  • 0

yes - this is a bug in openos when users try to print to the screen before boot is finished

I have this fixed, you are running an older version of openos

Note that if you pull the latest code, it will fix your problem and you won't get a blue screen. However, you also won't get the text printed to the screen because the terminal isn't finished loading yet.

If you want to print to the screen in a script that runs automatically during boot, you need to add your programs to /home/.shrc

Things that run in /boot, or autoruns, or rc scripts, may be executing before the terminal has initialized

If you want to run your code before /home/.shrc is run (happens when the shell loads) then you'll have to wait for the terminal to become available, that is, you'll need to:

      if not term.isAvailable() do
        event.pull("term_available")
      end

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.