Posted 24 September 2012 - 01:59 AM
I whipped up probably my first script, and it makes the bootup a bit more realistic and interesting. When it boots up, you are prompted with a login screen. The default username is Admin (or admin). They both work, but are case-sensitive. The password is banana…but you can change that if you like.
Now, I'm not going to take all of the credit because I did receive help from KaoS and Fatal_Exception… so thanks for the help!
Here's the code.
There may be excess code, but I'm just beginning to scratch the surface of LUA. :P/>/>
Edit: I made the bootup a bit faster, and added a welcome screen.
Now, I'm not going to take all of the credit because I did receive help from KaoS and Fatal_Exception… so thanks for the help!
Here's the code.
os.pullEvent = os.pullEventRaw
local function pause(key)
print('Press X to continue.')
while true do
local sEvent, sParam=os.pullEvent('char')
if string.lower(sParam)==key then
break
end
end
end
term.clear()
sleep(0.3)
term.setCursorPos(15,2)
print("CraftOS is starting...")
term.setCursorPos(20,4)
print("----------")
sleep(0.5)
term.setCursorPos(20,4)
print("o---------")
sleep(0.5)
term.setCursorPos(20,4)
print("oo--------")
sleep(0.5)
term.setCursorPos(20,4)
print("ooo-------")
sleep(0.5)
term.setCursorPos(20,4)
print("oooo------")
sleep(0.5)
term.setCursorPos(20,4)
print("ooooo-----")
sleep(0.5)
term.setCursorPos(20,4)
print("oooooo----")
sleep(0.5)
term.setCursorPos(20,4)
print("ooooooo---")
sleep(0.5)
term.setCursorPos(20,4)
print("oooooooo--")
sleep(0.5)
term.setCursorPos(20,4)
print("ooooooooo-")
sleep(0.5)
term.setCursorPos(20,4)
print("oooooooooo")
sleep(1.0)
term.clear()
term.setCursorPos(21,2)
print("Welcome!")
sleep(2.5)
local intcount=0
term.clear()
term.setCursorPos(1,1)
print("Login")
while true do
write("Username: ")
userNameInput = read()
if userNameInput == "admin" then
sleep(1)
break
elseif userNameInput == "Admin" then
sleep(1)
break
else
sleep(1)
print("Username not found.")
intcount=intcount+1
sleep(1)
for i=3,2,-1 do
term.setCursorPos(1,i)
term.clearLine()
end
end
if intcount==3 then
print('You have entered an invalid username too many times.')
sleep(5)
os.shutdown()
end
end
local intcount=0
while true do
write("Password: ")
passwordInput = read("*")
print("Verifying login...")
sleep(2.5)
if passwordInput == "banana" then
print("Loading your settings...")
sleep(1.5)
print("Logging in...")
sleep(3.5)
term.clear()
term.setCursorPos(1,1)
print("Welcome to CraftOS!")
pause('x')
term.setCursorPos(1,2)
term.clearLine()
break
else
print("The password you have entered is incorrect.")
intcount=intcount+1
sleep(1)
for i=6,3,-1 do
term.setCursorPos(1,i)
term.clearLine()
end
end
if intcount==3 then
print('You have entered an incorrect password too many times.')
sleep(5)
os.shutdown()
end
end
There may be excess code, but I'm just beginning to scratch the surface of LUA. :P/>/>
Edit: I made the bootup a bit faster, and added a welcome screen.