Advertisement
quenti77

door

Apr 16th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. local Portes = {795, 1639, 1638}
  2. local tArgs = {...}
  3. local x = tonumber(tArgs[1])
  4. local y = tonumber(tArgs[2])
  5. local z = tonumber(tArgs[3])
  6. rednet.open("back")
  7.  
  8. -- p => player
  9. -- b => block1
  10. -- c => block2
  11. local function checkCoord(px, py, pz, bx, by, bz, cx, cy, cz)
  12.     return (
  13.         (px >= bx and px <= cx) and
  14.         (py >= by and py <= cy) and
  15.         (pz >= bz and pz <= cz)
  16.     )
  17. end
  18.  
  19. while true do
  20.     x = 0
  21.     while x == 0 do
  22.         x, y, z = gps.locate(5)
  23.         if x == 0 then
  24.             print("Can't connect to GPS, retrying in 5 seconds")
  25.             sleep(5)
  26.         end
  27.     end
  28.     if checkCoord(x, y, z, 685, 65, -587, 686, 66, -586) or
  29.             checkCoord(x, y, z, 698, 65, -589, 699, 66, -588) then
  30.         print("Opening ...")
  31.         for t = 1,3 do
  32.             rednet.send(Portes[t], "true")
  33.         end
  34.     elseif checkCoord(x, y, z, 687, 65, -587, 688, 66, -586) or
  35.             checkCoord(x, y, z, 696, 65, -591, 697, 66, -590) then
  36.         print("Closing ...")
  37.         for t = 1,3 do
  38.             rednet.send(Portes[t], "false")
  39.         end
  40.     end
  41.     sleep(4)
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement