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

Login To Use Computer Startup

Started by odd_kid, 04 August 2012 - 12:43 PM
odd_kid #1
Posted 04 August 2012 - 02:43 PM
Hello! Im fairly new to the forums, and pretty new to coding (2 days) but i have made from scratch a simple "Login to use computer" Startup program. I will be posting version 1.0 - 1.4.5 . I am working on 1.5 but i am having a few problems and will be done soon.

As the program goes on, it will get more complex as i learn.

If you have ANY suggestions, or want certain features added, just ask! I REALLY want to learn more coding.

Features:
Disabled "CTRL + T"
Password Protected
Realistic Startup
Emergency (Bypass) Mode

Scroll to bottom for planned features and help.

Version 1.4.5
Spoiler- Improved realistic logging in and computer startup
- Added no "ctrl + T" option

os.pullEvent = os.pullEventRaw
term.clear()
p = "password"
print("   odd Security v1.4.5   ")
print("=========================")
print("|| UserName: yourname  ||")
write("|| Password: ********  ||")
print("=========================")
write("Password: ")
pt = read("*")
if pt == (p) then
print("Logging In..")
sleep(2)
print("Login succesful!")
sleep(1)
print("Welcome user!")
sleep(2)
term.clear()
print("Starting odd OS...")
sleep(3)
print("Reading Files...")
sleep(2)
print("Clearing Cache...")
sleep(2)
print("Startup Succesful!")
sleep(1)
term.clear()
print("odd OS v1.4.5")
write("")
elseif pt == "admin" then
write("Admin Mode")
else
print("Logging in...")
sleep(3)
print("Incorrect Password! Shutting Down...")
sleep(3)
os.shutdown()
end

Version 1.4

Spoiler- Added "Admin Bypass Mode" Meaning, typing "admin" will bypass the password.
- Added realistic startup
- Changed the look

term.clear()
p = "password"
print("   odd Security v1.4	 ")
print("=========================")
print("|| UserName: yourname  ||")
write("|| Password: ********  ||")
print("=========================")
write("Password: ")
pt = read("*")
if pt == (p) then
sleep(1)
print("Welcome user!")
sleep(2)
term.clear()
print("Starting odd OS...")
sleep(3)
print("odd OS v1.4")
write("")
elseif pt == "admin" then
write("Admin Mode")
else
print("Incorrect Password! Shutting Down...")
sleep(3)
os.shutdown()
end

1.3 (Huge Update For Me)

Spoiler- Added " * " instead of the letters themselves

term.clear()
p = "password"
print("======================")
print("|| Odd Security 1.3 ||")
print("|| UserName: odd_kid||")
print("|| Password:  ******||")
print("======================")
write("Password:   ")
tp = read("*")
if tp == (p) then
print("Access Granted! Welcome odd_kid!")
sleep(2)
term.clear()
else
print("Wrong Password! Shutting Down Computer...")
sleep(3)
os.shutdown()
end

Version 1.2 (Lost on Server)

Version 1.1

Spoiler- Changed Look

term.clear()
p = "password"
print("======================")
print("|| Odd Security 1.1 ||")
print("|| UserName: odd_kid||")
print("|| Password:  ******||")
print("======================")
write("Password:   ")
tp = read()
if tp == (p) then
print("Access Granted! Welcome odd_kid!")
sleep(1)
term.clear()
else
print("Wrong Password! Shutting Down Computer...")
sleep(3)
os.shutdown()
end

Version 1.0

Spoiler-First Version

term.clear()
p = "password"
print(" Odd Sercurities v1.0")
print("Username: odd_kid")
write("Password: ")
pt = read()
if pt == (p) then
print("Welcome!")
sleep(2)
term.clear()
else
print("Wrong Password! Shutting Down...")
sleep(3)
os.shutdown()
end

Remove "Bypass Mode" and Change Password and Username

SpoilerChange Password and Username:
To edit the file, open the console and type "edit startup"
To change the username, retype it on the line that say "print"
To change the Password it will be located near the top and should say "password"

Future Plans:
Options Mode (in progress)
Database to hold passwords and username
Must verify Username AND password
Installer
Xhisor #2
Posted 04 August 2012 - 04:10 PM
If you want it to be more realistic try the term.clear(), term.setCursorPos() and textutils.slowWrite()!
EDIT:
Here's how i would have done the layout!
Spoiler
os.pullEvent = os.pullEventRaw
term.clear()
term.setCursorPos(1,1)
p = "password"
print("   odd Security v1.4.5   ")
print("+----------------------+")
print("|  Username:		   |")
print("|  Password:		   |")
print("+----------------------+")
term.setCursorPos(14,3)
print("Admin")
term.setCursorPos(14,4)
pt = read("*")
if pt == (p) then
term.setCursorPos(1,6)
print("Logging in"); term.setCursorPos(11,6); textutils.slowPrint("...",1)
term.setCursorPos(1,7)
sleep(2)
print("Login succesful!")
sleep(1)
print("Welcome user!")
sleep(2)
term.clear()
term.setCursorPos(1,1)
print("Starting odd OS"); term.setCursorPos(16,1); textutils.slowPrint("...",1)
term.setCursorPos(1,2)
print("Reading Files"); term.setCursorPos(14,2); textutils.slowPrint("...",1)
term.setCursorPos(1,3)
print("Clearing Cache"); term.setCursorPos(15,3); textutils.slowPrint("...",1)
term.setCursorPos(1,4)
print("Startup Succesful!")
sleep(1)
term.clear()
term.setCursorPos(1,1)
print("odd OS v1.4.5")
term.setCursorPos(1,2)
elseif pt == "admin" then
write("Admin Mode")
else
term.setCursorPos(1,6)
print("Logging in"); term.setCursorPos(11,6); textutils.slowPrint("...",1)
term.setCursorPos(1,7)
print("Incorrect Password! Shutting Down"); term.setCursorPos(34,7); textutils.slowPrint("...",1)
os.reboot()
end
odd_kid #3
Posted 05 August 2012 - 12:59 AM
Thankyou! Ive been wondering how to do this!
Xhisor #4
Posted 05 August 2012 - 11:08 AM
Do you want to know how to automaticly run this program on every computer you place?
Leonardoas111 #5
Posted 05 August 2012 - 03:20 PM
Do you want to know how to automaticly run this program on every computer you place?
You would have to modify the rom.

Just make a floppy disk with a installer
tbyoran #6
Posted 05 August 2012 - 04:00 PM
Hey, I've just received a free Minecraft Giftcode!
You can get one too!

>> Removed, banned for 3 days, enjoy <<
Xhisor #7
Posted 05 August 2012 - 04:39 PM
Just make a floppy disk with a installer
But what if he wants to use it as an autostarting program on every computer?
Every time I script something I use Notepad++ and just save the file in
SpoilerC:Users*USERNAME*AppDataRoaming.techniclaunchertekkitmodsComputerCraftluaromprogramscomputer
, in that way it gets harder to bypass and you wont have to run aroud with disk drives and floppys.
odd_kid #8
Posted 05 August 2012 - 04:54 PM
Well I do most of my programming on a friends tekkit server so i just install it with floppys when someone wants it. But if you know how to mak a installer file, please do share. i would love to know.
Sammich Lord #9
Posted 05 August 2012 - 05:02 PM

os.pullEvent = os.pullEventRaw
local w, h = term.getSize()
--Variables
local user = "Human"
local pass = "password"
local uAllow = false
local pAllow = false
version = "1.0.0"
--Functions
function clear()
  term.clear()
  term.setCursorPos(1,1)
end
function printCentered(msg, h)
  term.setCursorPos(w/2 - #msg/2, h)
  write(msg)
end
local function printHeader()
  printCentered("Login System V"..version, 1)
  printCentered("Coded by: Human", 2)
end
local function uCheck()
  write("Username: ")
  uInput = read()
  if uInput == user then
    uAllow = true
  else
    print("Incorrect Username!")
    sleep(2)
    os.reboot()
  end
end
local function pCheck()
  write("Password: ")
  pInput = read("*")
  if pInput == pass then
    pAllow = true
  else
    print("Incorrect Password!")
    sleep(2)
    os.reboot()
  end
end
--Main Program
clear()
printHeader()
term.setCursorPos(1,4)
uCheck()
if uAllow == true then
  term.setCursorPos(1,5)
  pCheck()
end
if uAllow == true and pAllow == true then
  textutils.slowPrint("Loging in...")
  sleep(2)
  clear()
  print("Logged in")
end

That's just something that I wrote in 5 minutes I thought it was I bit more advanced.
Xhisor #10
Posted 05 August 2012 - 05:03 PM
Well I do most of my programming on a friends tekkit server so i just install it with floppys when someone wants it. But if you know how to mak a installer file, please do share. i would love to know.
You'll need a disk drive, a computer and a floppy disk.
Place the computer you have the program on and the disk drive beside each other and place the floppy disk in the disk drive. Write
cp startup disk/startup
and there you go! Now use the disk drive and the floppy to copy the program to any computer you want using
cp disk/startup startup
.
odd_kid #11
Posted 05 August 2012 - 05:07 PM
Thankyou Xhisor! Ill get on that, and Human0303, thankyou for the code but no need to brag/rub it in my face that you can code better. Like i said im new and im just looking for improvement