Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Portes = {795, 1639, 1638}
- local tArgs = {...}
- local x = tonumber(tArgs[1])
- local y = tonumber(tArgs[2])
- local z = tonumber(tArgs[3])
- rednet.open("back")
- -- p => player
- -- b => block1
- -- c => block2
- local function checkCoord(px, py, pz, bx, by, bz, cx, cy, cz)
- return (
- (px >= bx or px <= cx) and
- (py >= by or px <= cy) and
- (pz >= bz or px <= cz)
- )
- end
- while true do
- x = 0
- while x == 0 do
- x, y, z = gps.locate(5)
- if x == 0 then
- print("Can't connect to GPS, retrying in 5 seconds")
- sleep(5)
- end
- end
- if checkCoord(x, y, z, 685.0, 65.0, -586.0, 686.0, 66.0, -587.0) or
- checkCoord(x, y, z, 698.0, 65.0, -588.0, 699.0, 66.0, -589.0) then
- print("Opening ...")
- rednet.send(Portes, "true")
- elseif checkCoord(x, y, z, 687.0, 65.0, -586.0, 688.0, 66.0, -587.0) or
- checkCoord(x, y, z, 696.0, 65.0, -590.0, 697.0, 66.0, -591.0) then
- print("Closing ...")
- rednet.send(Portes, "false")
- end
- sleep(4)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement