A couple months ago i made a fairly simple code for a friend of mine, that basicly was a lock system that if the player was authorized the door would open if he wasnt, he would get a portal's pellet energy and would go from earth to heaven(aka he would die) Carrying on 13 m4st3r c0d3 Le Master Code Spoiler Code: local event local name local found function door() redstone.setOutput("back",true) sleep(2) redstone.setOutput("back",false) end function floor() redstone.setOutput("front",true) sleep(1) redstone.setOutput("front",false) end function reset() name = "" found = false end function waitClick() event, name = os.pullEvent("player") print(name) end function checkName() file = io.open("perms", "r") for line in file:lines() do if name == line then found = true end end end function run() if found == true then print("Player Authorized, Opening Door.") door() else print("PLAYER NOT AUTHORIZED INITIATING FLOOR/KILLING PROCESS") floor() end end os.pullEvent = os.pullEventRaw while true do reset() waitClick() checkName() run() end Pastebin link: http://pastebin.com/ceNTDJdj Or through computer ftp or the skcraft IDE! For Maximum Protection its better that it is on startup It Outputs a redstone signal on the front, if the player isnt authorized And Outputs a redstone signal on the back if the player is authorized Those can be changeable on the code Also, Player Detector is on the top(Can also be changed)
I recommend doing nested if/else, that way it doesn't evaluate each function every time it loops, but only the first if statement, then if true continues through the rest of the program.