SHOW:
|
|
- or go back to the newest paste.
| 1 | - | margherita = "right" |
| 1 | + | output = "top" |
| 2 | - | marinara = "bottom" |
| 2 | + | allowed = "bottom" |
| 3 | - | allowed = "left" |
| 3 | + | denied = "back" |
| 4 | - | denied = "top" |
| 4 | + | |
| 5 | local function searchUser(user) | |
| 6 | - | pizzaType = true |
| 6 | + | |
| 7 | checkUser = string.find(userList.readAll(), user) | |
| 8 | userList.close() | |
| 9 | return checkUser | |
| 10 | end | |
| 11 | ||
| 12 | local function addUser(user) | |
| 13 | local userList = fs.open("users", "a")
| |
| 14 | userList.writeLine(user) | |
| 15 | userList.close() | |
| 16 | end | |
| 17 | ||
| 18 | local function resetRedstone() | |
| 19 | rs.setOutput(output, false) | |
| 20 | rs.setOutput(allowed, false) | |
| 21 | rs.setOutput(denied, false) | |
| 22 | - | rs.setOutput(margherita, false) |
| 22 | + | |
| 23 | - | rs.setOutput(marinara, false) |
| 23 | + | |
| 24 | local function resetList() | |
| 25 | if fs.exists("users") then
| |
| 26 | fs.delete("users")
| |
| 27 | end | |
| 28 | local userList = fs.open("users", "w")
| |
| 29 | userList.writeLine("Kiiw")
| |
| 30 | userList.writeLine("_Roovy")
| |
| 31 | userList.writeLine("LoreSao99")
| |
| 32 | userList.close() | |
| 33 | - | userList.writeLine("MegaAlbert4000")
|
| 33 | + | |
| 34 | ||
| 35 | os.setAlarm(0) | |
| 36 | resetRedstone() | |
| 37 | resetList() | |
| 38 | ||
| 39 | while true do | |
| 40 | local event, user = os.pullEvent() | |
| 41 | if event == "player" then | |
| 42 | local checkUser = searchUser(user) | |
| 43 | if checkUser == nil or checkUser == "" then | |
| 44 | print("User " .. user .. " allowed")
| |
| 45 | addUser(user) | |
| 46 | rs.setOutput(output, true) | |
| 47 | - | if pizzaType then |
| 47 | + | |
| 48 | - | rs.setOutput(margherita, true) |
| 48 | + | sleep(10) |
| 49 | - | else |
| 49 | + | |
| 50 | - | rs.setOutput(marinara, true) |
| 50 | + | |
| 51 | - | end |
| 51 | + | |
| 52 | - | pizzaType = not pizzaType |
| 52 | + | |
| 53 | resetRedstone() | |
| 54 | end | |
| 55 | elseif event == "alarm" then | |
| 56 | resetList() | |
| 57 | end | |
| 58 | sleep(1) | |
| 59 | end |