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

hamish1001 programs

Started by hamish1001, 23 March 2012 - 12:28 AM
hamish1001 #1
Posted 23 March 2012 - 01:28 AM
my programs :)/>/>

SpoilerProtection for your computer (login)

user = "INSERT USERNAME HERE"
pass = "INSERT PASSWORD HERE"

write "Username: "
input = read()
if user == input then
else
print "Error: User not found"
sleep(1,5)
os.reboot()
end
write "Password: "
input = read("*")
if pass == input then
print "Logging on"
sleep(1)
print "Starting CraftOS"
sleep(3,5)
print "Ready"
else
print "Wrong password"
sleep(1,5)
os.shutdown()
end



A door lock for your doors

function os.pullEvent()
local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
if event == "terminate" then
end
return event, p1, p2, p3, p4, p5
end

term.clear()
term.setCursorPos(1,1)
print "Super Lock 2000"
print " "
write ("Password: ")

correctpass = "123"
pass = read("*")

if pass == (correctpass) then
print " "
write("Correct! You may enter!")user
redstone.setOutput("left", true)
sleep(4)
redstone.setOutput("left", false)
os.reboot()

else
print " "
write("Incorrect! Rebooting!")
sleep(2)
os.reboot()
end



AN ADVANCED DOOR LOCK WHERE YOU HAVE TO LOG IN AND THEN ENTER YOUR DOORS PASSWORD


Save as "startup" to one of your computers (type id to find out the computer number) eg. save/computer/1 (sorry for the bad example)


–Define Program Information

–Text Symbols
usersymbol = "X"
passsymbol = "*"
–Passwords
pass1 = "ENTER PASSWORD HERE"

– Usernames
user1 = "ENTER USERNAME HERE"

–TERMINATE
TerminalMode = 0 – Allows you to edit what terminate does


function os.pullEvent()
local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
if event == "terminate" then
if TerminalMode == 0 then

end


if TerminalMode == 1 then
os.reboot()
end
if TerminalMode == 2 then
error( "Terminated" )
end
end
return event, p1, p2, p3, p4, p5
end

–Program
shell.run("clear")

textutils.slowPrint"Please input Username"



xuser = read(usersymbol)
if xuser == user1 then
textutils.slowPrint"Username Valid"
sleep(1)
shell.run("clear")


else


textutils.slowPrint"Access Denied"
sleep(2)
shell.run("startup")



end

textutils.slowPrint"Please enter Password"

xpassword = read(passsymbol)
if xpassword == pass1 then
textutils.slowPrint"Password Accepted"
sleep(1)
shell.run("clear")
shell.run("doorlock")

else
textutils.slowPrint"Access Denied"
sleep(2)
shell.run("startup")


end



Save as "doorlock" and put in C:Users"name"AppDataRoaming.minecraftmodsComputerCraftluaromprograms

–Define Program Information

–Redstone Output
side = "left"

–Text Symbols
passsymbol = "*"

–Passwords
doorpw = "ENTER PASSWORD HERE"

–TERMINATE
TerminalMode = 0 – Allows you to edit what terminate does


function os.pullEvent()
local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
if event == "terminate" then
if TerminalMode == 0 then

end
if TerminalMode == 1 then
os.reboot()
end
if TerminalMode == 2 then
error( "Terminated" )
end
end
return event, p1, p2, p3, p4, p5
end

textutils.slowPrint"Please Enter Door Password"

xpassword = read(passsymbol)
if xpassword == doorpw then
textutils.slowPrint"Password Accepted, Opening Door"
rs.setOutput(side, true)
sleep(5)
rs.setOutput(side, false)
sleep(1)

else

textutils.slowPrint"Access Denied"
sleep(2)
shell.run("clear")
shell.run("doorlock")


end

shell.run("startup.lua")






Enjoy ;)/>/>


im a ninja :(/>/>



edit: forgot the door lock that opens doors in heaps more directions all at once :o/>/>


function os.pullEvent()
local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
if event == "terminate" then
end
return event, p1, p2, p3, p4, p5
end

term.clear()
term.setCursorPos(1,1)
print "super lock 3000"
print " "
write ("Password: ")

correctpass = "ENTER PASSWORD HERE"
pass = read("*")

if pass == (correctpass) then
print " "
write("Correct! You may enter!")
redstone.setOutput("left", true)
rs.setOutput("right",true)
rs.setOutput("back",true)
rs.setOutput("bottom",true)
rs.setOutput("top",true)
rs.setOutput("front",true)
sleep(4)
redstone.setOutput("left", false)
rs.setOutput("back",false)
rs.setOutput("top",false)
rs.setOutput("right",false)
rs.setOutput("bottom",false)
rs.setOutput("front",false)
os.reboot()

else
print " "
write("Incorrect! Rebooting!")
sleep(2)
os.reboot()
end




Bombing Run (turtle program)
thanks to Dirkus7 for telling me the program :)/>/>

Rs.setOutput("front", true) –activates redstone
While true do – start infinite loop, you can change it to a finite loop
Turtle.place() –places a block, in your case tnt, tnt automaticly activated by redstone :D/>/>
Turtle.forward() – go forward
End – end infinite loop


hamish1001 #2
Posted 23 March 2012 - 01:35 AM
haha :(/>/> its mainly a door lock and a login :)/>/>
Luanub #3
Posted 23 March 2012 - 02:15 AM
spoiler and code tags would be nice. :(/>/>

I also suggest breaking away from using global vars in your programs. I noticed in one script you use a global var name input several times in the script for different uses. This can cause numerous issues and is a bad coding habit. Only use global vars when you have to.
hamish1001 #4
Posted 23 March 2012 - 02:35 AM
spoiler and code tags would be nice. :(/>/>

I also suggest breaking away from using global vars in your programs. I noticed in one script you use a global var name input several times in the script for different uses. This can cause numerous issues and is a bad coding habit. Only use global vars when you have to.

what can i use instead can you edit it and comment it for an example for me :)/>/> PLEASE
Luanub #5
Posted 23 March 2012 - 02:40 AM
for the tags or the vars?

for the vars try:
Spoiler

replace

input = read() <-- is set as global

with

local input = read()  <-- makes it a local


The tags are [_spoiler] [_/spoiler] [_code] [_/code] without the _'s
hamish1001 #6
Posted 23 March 2012 - 02:48 AM
so what did i put in there that i shouldt of and how can my profile say something different then clueless i h8 clueless lol :(/>/>
Luanub #7
Posted 23 March 2012 - 03:07 AM
Use the tags so the post isn't a mile long and so that it flags the code in the post appropriately. It will just make it cleaner and easier for people to look at the code you posted. Take a look at some of the other posts in this section for some examples.
hamish1001 #8
Posted 23 March 2012 - 03:10 AM
how wheres tag :(/>/>
hamish1001 #9
Posted 23 March 2012 - 03:14 AM
Use the tags so the post isn't a mile long and so that it flags the code in the post appropriately. It will just make it cleaner and easier for people to look at the code you posted. Take a look at some of the other posts in this section for some examples.
how where?
Ian-Moone #10
Posted 23 March 2012 - 07:58 AM
do this

--says hello word this is a tag
print("helloworld")
[/CODE

its in his post sory abouut this / i thought to make people read code
Wolvan #11
Posted 23 March 2012 - 03:19 PM
Nice first programs :(/>/> Event with terminating lock. Wow
Kadecamz #12
Posted 26 March 2012 - 12:50 AM
Keep getting errors
Wolvan #13
Posted 26 March 2012 - 06:10 PM
Try put your programs into code things. You can do it like this: select the text you want to put in a code box and then press the blue <> symbol on top of the editor
Kryptanyte #14
Posted 01 April 2012 - 08:23 AM
Excuse me Hamish, but i would advise against stealing programs other people wrote then claim them as your own.

My two:

SpoilerAN ADVANCED DOOR LOCK WHERE YOU HAVE TO LOG IN AND THEN ENTER YOUR DOORS PASSWORD


Save as "startup" to one of your computers (type id to find out the computer number) eg. save/computer/1 (sorry for the bad example)


–Define Program Information

–Text Symbols
usersymbol = "X"
passsymbol = "*"
–Passwords
pass1 = "ENTER PASSWORD HERE"

– Usernames
user1 = "ENTER USERNAME HERE"

–TERMINATE
TerminalMode = 0 – Allows you to edit what terminate does


function os.pullEvent()
local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
if event == "terminate" then
if TerminalMode == 0 then

end


if TerminalMode == 1 then
os.reboot()
end
if TerminalMode == 2 then
error( "Terminated" )
end
end
return event, p1, p2, p3, p4, p5
end

–Program
shell.run("clear")

textutils.slowPrint"Please input Username"



xuser = read(usersymbol)
if xuser == user1 then
textutils.slowPrint"Username Valid"
sleep(1)
shell.run("clear")


else


textutils.slowPrint"Access Denied"
sleep(2)
shell.run("startup")



end

textutils.slowPrint"Please enter Password"

xpassword = read(passsymbol)
if xpassword == pass1 then
textutils.slowPrint"Password Accepted"
sleep(1)
shell.run("clear")
shell.run("doorlock")

else
textutils.slowPrint"Access Denied"
sleep(2)
shell.run("startup")


end


Save as "doorlock" and put in C:\Users\"name"\AppData\Roaming\.minecraft\mods\ComputerCraft\lua\rom\programs

–Define Program Information

–Redstone Output
side = "left"

–Text Symbols
passsymbol = "*"

–Passwords
doorpw = "ENTER PASSWORD HERE"

–TERMINATE
TerminalMode = 0 – Allows you to edit what terminate does


function os.pullEvent()
local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
if event == "terminate" then
if TerminalMode == 0 then

end
if TerminalMode == 1 then
os.reboot()
end
if TerminalMode == 2 then
error( "Terminated" )
end
end
return event, p1, p2, p3, p4, p5
end

textutils.slowPrint"Please Enter Door Password"

xpassword = read(passsymbol)
if xpassword == doorpw then
textutils.slowPrint"Password Accepted, Opening Door"
rs.setOutput(side, true)
sleep(5)
rs.setOutput(side, false)
sleep(1)

else

textutils.slowPrint"Access Denied"
sleep(2)
shell.run("clear")
shell.run("doorlock")


end

shell.run("startup.lua")

Now go back to the other forums, find who wrote the rest of those scripts and say sorry to them. Also correct your mistakes and dont claim these as your own. If you need proof that this is mine, ill link the thread where i posted this:

http://mccraftcpl.pr...play&amp;thread=178

Thank you hamish. I'm going to keep an eye on you
Kryptanyte #15
Posted 12 April 2012 - 03:10 AM
Can someone please remove this thread?
virtualayu #16
Posted 12 April 2012 - 03:31 AM
please admins do something about hammish1001 he never coded anything… he just go on other forums and appropriate others work… seriously….

hammish1001… what did you think??? you do that to pretend having friends and pretend to know about coding???

did you really think we'll never see that you steal code from others? You may know that the community is not that big and most of users of forum are on multiples forum… so it's inevitable that someone recognize his code…