SHARE
TWEET

startup

a guest Feb 4th, 2015 163 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function open_door()
  2.   rs.setOutput('left', true)
  3. end
  4. local function close_door()
  5.   rs.setOutput('left', false)
  6. end
  7.  
  8.   local function sensor_door()
  9.  
  10.     local white_list = {'Seryoga', 'NEO', 'Ruslan1911', 'Desectus', 'MorfSD', 'AlexVBG', 'Nedfreetoplay'}
  11.     local sensor = peripheral.wrap('top')
  12.     local opening = true
  13.  
  14.     close_door()
  15.  
  16.     while true do
  17.       people_table = sensor.getPlayers()
  18.       q_people = #people_table
  19.       opening = false
  20.    
  21.       term.clear()
  22.       term.setCursorPos(1, 1)
  23.       print("Quantity players: ", q_people)
  24.       for k, v in pairs(people_table) do
  25.         people = people_table[k]
  26.         write(people['name']..' ')
  27.       end
  28.          
  29.                        
  30.                    
  31.       for k, v in pairs(people_table) do  
  32.         people = v
  33.         people_info = sensor.getPlayerByUUID(people["uuid"])
  34.      
  35.         for k, v in pairs(white_list) do
  36.           if people_info["name"] == white_list[k] then
  37.             distance = 0
  38.             for k, v in pairs(people_info["position"]) do
  39.               distance = v * v + distance
  40.             end
  41.             distance = math.sqrt(distance)
  42.             if distance < 3 then
  43.               print()
  44.               print("Open")
  45.          
  46.               open_door()
  47.          
  48.               opening = ture
  49.               break
  50.             end
  51.           end
  52.         end
  53.      
  54.         if opening == ture then
  55.           break
  56.         end  
  57.       end
  58.    
  59.       if opening == false then
  60.         print()
  61.         print("Close")
  62.        
  63.         close_door()
  64.       end
  65.      
  66.       sleep(0.1)
  67.     end  
  68.   end
  69.  
  70. while true do  
  71.   pcall(sensor_door)
  72.  
  73.   close_door()
  74.  
  75.   sleep(5)
  76. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top