Advertisement
quenti77

fix

Apr 15th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 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 or px <= cx) and
  14.         (py >= by or px <= cy) and
  15.         (pz >= bz or px <= 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.  
  29.     if checkCoord(x, y, z, 685.0, 65.0, -586.0, 686.0, 66.0, -587.0) or
  30.             checkCoord(x, y, z, 698.0, 65.0, -588.0, 699.0, 66.0, -589.0) then
  31.         print("Opening ...")
  32.         rednet.send(Portes, "true")
  33.     elseif checkCoord(x, y, z, 687.0, 65.0, -586.0, 688.0, 66.0, -587.0) or
  34.             checkCoord(x, y, z, 696.0, 65.0, -590.0, 697.0, 66.0, -591.0) then
  35.         print("Closing ...")
  36.         rednet.send(Portes, "false")
  37.     end
  38.     sleep(4)
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement