Whiskee icon

Touch.lua

Whiskee | PRO | 04/10/17 06:28:47 PM UTC | 0 ⭐ | 336 👁️ | Never ⏰ | []
Lua |

1.25 KB

|

None

|

0 👍

/

0 👎

local event = require("event")
local s = require("shell")
local c = require("component")
local rs = c.redstone
local side = require("sides")
local term = require("term")
local gpu = c.gpu
local RSIDE = side.top
 
 
gpu.setResolution(30,15)
 
NAME = {"TotallyIridium", "Eatersoul12357", "Dinxton"}
CLVL = {1,1,1}
reqlvl = 5
 
--s.execute("wget -f https://pastebin.com/raw/4izJWFVj Names.lua")
 
 
--term.clear()
 
--print("Touch To Open Door")
 
--local N = require("Names")
 
 
function Door(name)
 
  local loop = true
  local i = 1
 
  while loop do
    if NAME[i] == name then
      if CLVL[i] <= reqlvl then
        loop = false
        rs.setOutput(RSIDE,15)
        print("Welcome, " .. NAME[i])
        os.sleep(4)
        rs.setOutput(RSIDE,0)
        else
        print("Access Dnied: Invalid Clearance Level")
        loop = false  
      end
    end
if i == 3 then
loop = false
end
    i=i+1
  end
 
end
 
 
while true do
term.clear()
print("press to open door")
 
  local id, _, x, y, _, nickname = event.pullMultiple("touch", "interrupted")
  if id == "interrupted" then
    print("soft interrupt, closing")
    break
  elseif id == "touch" then
 
   Door(nickname)
 
--print("Name: ", nickname)
--os.sleep(1)
  end
end

Comments