[CC] Simple Password Lock Tutorial *

View/post tutorials for use on our Tekkit server

[CC] Simple Password Lock Tutorial *

Postby sleawnis » 29 Mar 2013, 18:58

Image


This Tutorial Is For People With Little/None Understanding Of ComputerCraft, Or Coding In LUA. Sorry If Its Too Simple, I Could Make It Better, But Want To Keep It As Simple As Possible (:



1) Making Your Program:

Image
Code: Select all
edit startup

This Creates Your File, And As It Is Named Startup, The Computer Will Run The Program Each Time It Restarts.


2) Making Your GUI:

Image
Print: This Makes The Computer Display The String, Sets Cursor To The Line Below
Write: This Makes The Computer Display The String, Sets Cursor To The End Of The String

3) Input:

Image
Code: Select all
input = read("*")

This Makes The Computer Request A Input Of The User, In This Case A Password. The String Is Then Stored For Later.

3) If Statment:
Image

Code: Select all
if input == "password" then

This Checks If The Input (defined earlier) Matches The Password

Code: Select all
rs.setOutput("left", true)

This Sets A Positive Redstone Output From The Left Side Of The Computer

Code: Select all
sleep(3)

This Keeps The Computer At The Current State (emitting redstone) For 3 Seconds

Code: Select all
rs.setOutput("left", false)

This Changes The Redstone Output On The Left To False

4) Else:
Image

Code: Select all
else

Does The Following If The Input Does Not Equal The Password

Code: Select all
os.reboot()

Restarts The Computer

Code: Select all
end

Ends The Code

Fixes:

You'll Probably Notice, That When You Restart Your Computer It Sais This Above The Program:
Image

You Can Fix It By Changing Your Code Accordingly:
Image

Code: Select all
term.clear()

This Clears The Screen

Code: Select all
term.setCursorPos(1,1)

This Makes The Cursor Go Back To The Start Of The Screen


The Next Bit Allows Your Computer To Be Un-Hackable (well as much as possible)(sorry for no scrennies)

Add This At The Top Of Your Code:
Code: Select all
os.pullEvent =os.pullEventRaw



Ok Thats How To Make A Password Protected Door. Click Here For The Raw Paste Data
Golden J Brown wrote:In no impression assistance contrasted. Manners man I wishing justice hastily new anxious. At discovery discourse departure objection weImage

Goodbye Citycraft
User avatar
sleawnis
Bedrock Miner
  
Build:BANNED
Survival:BANNED
FTB:BANNED
SkyBlock:BANNED
 
Posts:538
Joined:07 Nov 2011, 18:07
Location:FTB or Survival

Return to Tekkit Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests
cron