Guest User

door

a guest
Nov 15th, 2014
1,313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. local p = peripheral.wrap("right")
  2. --local info = p.getPlayers()
  3. --local username = info[1].name
  4. --local pos = p.getPlayerByName(username).position
  5.  
  6. redstone.setOutput("left", true)
  7. i = 1
  8.  
  9. function getInfo()
  10.   info = p.getPlayers()
  11.   return info
  12. end
  13.  
  14. function getUsername()
  15.   getInfo()
  16.   info = p.getPlayers()
  17.   username = info[1].name
  18.   return username
  19. end
  20.  
  21. function getPos()
  22.   info = p.getPlayers()
  23.   username = info[1].name
  24.   pos = p.getPlayerByName(username).position
  25.   return pos
  26. end
  27.  
  28. while true do
  29.   print("Iteration: "..i)
  30.   i = i + 1
  31.   getInfo()
  32.   getUsername()
  33.   getPos()
  34.   for key, value in pairs(info) do
  35.     for x, y in pairs(value) do
  36.       print(x..": "..y)
  37.     end
  38.   end
  39.   print(username)
  40.   for A, E in pairs(pos) do
  41.     print(A..": "..E)
  42.   end
  43.   print("Player 1: "..info[1].name)
  44.   sleep(10)
  45. --  if info ~= nil then
  46. --   print("Iteration: "..i)
  47. --    i = i +1
  48. --    print("Someone is online! Who is it?")
  49. --    sleep(1)
  50. --    getPos()
  51. --    print(getUsername().." has been detected! How close are they?")
  52. --      if getPos() ~= nil then
  53. --      pos = p.getPlayerByName(username).position
  54. --      print(getUsername().." is at coords: "..getPos().x..", "..getPos().y..", "..getPos().z)
  55. --        if getPos().x >= -2 and getPos().x <= 2
  56. --        and getPos().y >= 0 and getPos().y <= 3
  57. --        and getPos().z >= -2 and getPos().z <= 2 then
  58. --          print(getUsername().." is in the spot. Opening Door")
  59. --          redstone.setOutput("left", false)
  60. --          sleep(3)
  61. --          redstone.setOutput("left", true)
  62. --      else
  63. --        print("oooh if only Player were in the spot...")
  64. --        sleep(1)
  65. --      end
  66. --    end
  67. --  else
  68. --    print("No one is online -_-")
  69. --    sleep(1)
  70. --  end
  71. end
Advertisement
Add Comment
Please, Sign In to add comment