Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- startup.lua(keypad.lua)
- Created By Cavious(Donald R. Valverde)
- Version 0.5-ALPHA
- SETUP REQUIREMENTS
- ==================
- (1)One Gold COMPUTER
- (2)One Gold Monitor
- ]]--
- --[[
- UPDATES COMING TO THIS FILE
- ===========================
- (1)RedNet Controls(SEND, RECEIVE)
- (2)Secure variables
- (3)Security log(TextFile with ComputerCraft Database Connection)
- ]]--
- --##################VARIABLES##################
- mon_side = "" --The side your monitor is on.
- door_side = ""
- definedTime = 1 --Enter delay for door open & close; DEFAULT = 1
- --YOUR PASSWORD HERE
- --Consists of three, one digit codes, all must be numerical.
- password_code1 = "" --Enter 1 digit into the "".
- password_code2 = "" --Enter 1 digit into the "".
- password_code3 = "" --Enter 1 digit into the "".
- --###############DO NOT TOUCH##################
- --DO NOT TOUCH THIS VARIABLE!
- mon = peripheral.wrap(mon_side) --SIDE SET BY YOU ABOVE
- code = {} -- USED BY THE COMPUTER ONLY!
- curNum = 1 --DEFAULT DO NOT TOUCH
- --##############################################
- --#################FUNCTIONS####################
- function run()
- initialize()
- main()
- end
- function initialize()
- mon.clear()
- mon.setTextScale(1)
- drawBackground()
- displayText()
- end
- function drawBackground()
- term.redirect(mon)
- background = paintutils.loadImage(".background")
- paintutils.drawImage(background, 1, 1)
- term.native()
- end
- function displayText()
- --Set Number on Pad
- --Send Buttons
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.yellow)
- --Left Send Button
- mon.setCursorPos(2,2)
- mon.write("S")
- mon.setCursorPos(2,3)
- mon.write("E")
- mon.setCursorPos(2,4)
- mon.write("N")
- mon.setCursorPos(2,5)
- mon.write("D")
- --Right Send Button
- mon.setCursorPos(6,2)
- mon.write("S")
- mon.setCursorPos(6,3)
- mon.write("E")
- mon.setCursorPos(6,4)
- mon.write("N")
- mon.setCursorPos(6,5)
- mon.write("D")
- --Number Buttons
- mon.setTextColor(colors.white)
- --Green Numbers
- mon.setBackgroundColor(colors.green)
- mon.setCursorPos(3,3)
- mon.write("1")
- mon.setCursorPos(5,3)
- mon.write("3")
- mon.setCursorPos(4,4)
- mon.write("5")
- mon.setCursorPos(3,5)
- mon.write("7")
- mon.setCursorPos(5,5)
- mon.write("9")
- --Lime Numbers
- mon.setBackgroundColor(colors.lime)
- mon.setCursorPos(4,3)
- mon.write("2")
- mon.setCursorPos(3,4)
- mon.write("4")
- mon.setCursorPos(5,4)
- mon.write("6")
- mon.setCursorPos(4,5)
- mon.write("8")
- end
- function buttonCheck(xPos, yPos)
- --SEND BUTTON CHECK
- if(xPos == 2 and yPos >= 2 or xPos == 6 and yPos >= 2 and yPos <= 5) then
- if (pass.num1 == password_code1 and pass.num2 == password_code2 and pass.num3 == password_code3) then
- --########FOR TESTING ONLY########
- mon.setCursorPos(1,1)
- mon.setBackgroundColor(colors.white)
- mon.write(" ")
- --################################
- --RESET ALL VARIABLES, KEYS, AND PAD
- --OPEN AND CLOSE DOOR
- curNum = 1 --Reset the entry back to the first number of the password.
- redstone.setOutput(door_side, true)
- os.sleep(definedTime)
- redstone.setOutput(door_side, false)
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(3,2)
- mon.write(" ")
- mon.setCursorPos(4,2)
- mon.write(" ")
- mon.setCursorPos(5,2)
- mon.write(" ")
- end
- end
- --1 BUTTON CHECK
- if(xPos == 3 and yPos == 3) then
- if curNum == 1 then
- --Save Number to variable
- pass.num1 = "1"
- --Display on Dial pad
- mon.setCursorPos(3,2)
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- mon.write("*")
- --Add one to the curNum
- curNum = curNum + 1
- os.sleep(0.5)
- end
- if curNum == 2 then
- --Save Number to variable
- pass.num2 = "1"
- --Display on Dial pad
- mon.setCursorPos(4,2)
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- mon.write("*")
- --Add one to the curNum
- curNum = curNum + 1
- end
- if curNum == 3 then
- --Save Number to variable
- pass.num3 = "1"
- --Display on Dial pad
- mon.setCursorPos(5,2)
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- mon.write("*")
- --Add one to the curNum
- curNum = curNum + 1
- end
- end
- --2 BUTTON CHECK
- if(xPos == 4 and yPos == 3) then
- if curNum == 1 then
- --Save Number to variable
- pass.num1 = "2"
- --Display on Dial pad
- mon.setCursorPos(3,2)
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- mon.write("*")
- --Add one to the curNum
- curNum = curNum + 1
- end
- if curNum == 2 then
- --Save Number to variable
- pass.num2 = "2"
- --Display on Dial pad
- mon.setCursorPos(4,2)
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- mon.write("*")
- --Add one to the curNum
- curNum = curNum + 1
- end
- if curNum == 3 then
- --Save Number to variable
- pass.num3 = "2"
- --Display on Dial pad
- mon.setCursorPos(5,2)
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- mon.write("*")
- --Add one to the curNum
- curNum = curNum + 1
- end
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.white)
- mon.write(curNum)
- end
- end
- function main()
- while(true) do
- event, side, xPos, yPos = os.pullEvent("monitor_touch")
- buttonCheck(xPos, yPos)
- end
- end
- --####################MAIN########################
- run()
Advertisement
Add Comment
Please, Sign In to add comment