30 posts
Location
Earth
Posted 07 April 2013 - 07:12 AM
Have you ever needed an effective startup, but don't know how to program one? Probably not, but look at this post anyway. The simple program I just made is a small startup, effective for making a personal computer for your home.
FETURES:- No CTRL+T
- Program can easily turn on wireless and wired modems
- Not a long program, so you don't spend hours programming (doesn't matter if http is enabled)
CODE:
os.pullEvent = os.pullEventRaw
term.setCursorPos(8,1)
print ("ComputerCraft 1.5.2")
term.setCursorPos(1,2)
term.setTextColor(colors.blue)
print ("Please enter your password to enter this computer.")
pass = ("password") -- Change password to whatever you want it to be,
write ("Password = ")
term.setTextColor(colors.cyan)
input = read("*")
if not (input == pass) then
term.setTextColor(colors.red)
print ("Incorrect password. Shutting down...")
sleep(1)
os.shutdown()
end
if (input == pass) then
term.setTextColor(colors.green)
print ("Welcome,")
sleep(1)
term.setTextColor(colors.cyan)
print ("Please input side of wireless/wired modem, or 'none' if you have no modem attached.")
none = ("none")
input = read()
if not (input == none) then
rednet.open( input )
print ("Modem turned on.")
term.setTextColor(colors.white)
sleep(0.5)
end
if (input == none) then
print ("No modems turned on.")
term.setTextColor(colors.white)
sleep(0.5)
end
end
PASTEBIN:http://www.pastebin.com/uRaYM9VY
59 posts
Posted 07 April 2013 - 07:19 AM
Thank you for not calling this an OS
30 posts
Location
Earth
Posted 07 April 2013 - 07:26 AM
Found an error in code, fixed it. :)/>
220 posts
Location
Germany
Posted 07 April 2013 - 08:46 AM
Haha, your first line is epic :D/>
30 posts
Location
Earth
Posted 07 April 2013 - 09:27 AM
Haha, your first line is epic :D/>
Thanks for the compliment :3
645 posts
Location
'Merica
Posted 07 April 2013 - 11:59 PM
Err… correct me if I'm wrong but
os.pullEvent = os.pullEventRaw
term.setCursorPos(8,1)
print ("ComputerCraft 1.5.2")
term.setCursorPos(1,2)
term.setTextColor(colors.blue)
print ("Please enter your password to enter this computer.")
pass = ("password") -- Change password to whatever you want it to be,
write ("Password = ")
term.setTextColor(colors.cyan)
input = read("*")
if not (input == pass) then -- You shouldn't have the () around the variables.
term.setTextColor(colors.red)
print ("Incorrect password. Shutting down...")
sleep(1)
os.shutdown()
end
if (input == pass) then -- You really do not need the ()
term.setTextColor(colors.green)
print ("Welcome,")
sleep(1)
term.setTextColor(colors.cyan)
print ("Please input side of wireless/wired modem, or 'none' if you have no modem attached.")
none = ("none")
input = read()
if not (input == none) then -- again you don't need the ()
rednet.open( input )
print ("Modem turned on.")
term.setTextColor(colors.white)
sleep(0.5)
end
if (input == none) then -- Same here
print ("No modems turned on.")
term.setTextColor(colors.white)
sleep(0.5)
end
end
Also I spaced your program, it makes it easier to read. Also you don't need to do
if not var == var then
all you need if the main if
if input == password then
-- code
else -- This removes the need for the extra if
-- code that would be in the "if not"
EDIT: I hate how when you copy something in it copies the code box, not just the code.
30 posts
Location
Earth
Posted 08 April 2013 - 12:19 AM
Thank you for spacing my code. Also, I have some feedback for your feedback…
—————————————————————————————————–
if (input == pass) then
print ("Code goes here")
else
print ("More code goes here")
I knew that, and I usually do that, but when I programmed and tested this, there was originally an override password, but it didn't work right and I removed it. After that, I didn't feel like re-scripting anything else, so I just left it how it was.
—————————————————————————————————–
if not (input == pass) then – You shouldn't have the () around the variables.
If I have the (), it changes nothing and it helps me be more organized.
645 posts
Location
'Merica
Posted 08 April 2013 - 12:28 AM
Thank you for spacing my code. Also, I have some feedback for your feedback…
—————————————————————————————————–
if (input == pass) then
print ("Code goes here")
else
print ("More code goes here")
I knew that, and I usually do that, but when I programmed and tested this, there was originally an override password, but it didn't work right and I removed it. After that, I didn't feel like re-scripting anything else, so I just left it how it was.
—————————————————————————————————–
ifnot(input ==pass)then–You shouldn't have the () around the variables.
If I have the (), it changes nothing and it helps me be more organized.
Actually the syntax reads better without the ().
30 posts
Location
Earth
Posted 08 April 2013 - 12:37 AM
Whatever, I'll try to stop programming with the ()s now.
645 posts
Location
'Merica
Posted 08 April 2013 - 12:40 AM
Whatever, I'll try to stop programming with the ()s now.
I'm just trying to be helpful, but also try spacing for often as well, it will make your code easier to read, and you can organize better that way too.
30 posts
Location
Earth
Posted 08 April 2013 - 12:55 AM
I know you were trying to be helpful, (and believe me, you were,) but I just wanted to tell you why I did what you didn't. Also, the
Whatever, I'll try to stop programming with the ()s now.
wasn't anything against you, I just didn't really feel like writing.
30 posts
Location
Earth
Posted 08 April 2013 - 05:46 AM
Forgot to say, the other fixes were helpful. Also, forgot to change program until now.
2088 posts
Location
South Africa
Posted 08 April 2013 - 05:55 AM
EDIT: I hate how when you copy something in it copies the code box, not just the code.
Right click -> paste as plain text
30 posts
Location
Earth
Posted 10 April 2013 - 12:01 AM
Thanks, that'll be helpful later.