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 and px <= cx) and
- (py >= by and py <= cy) and
- (pz >= bz and pz <= 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, 65, -587, 686, 66, -586) or
- checkCoord(x, y, z, 698, 65, -589, 699, 66, -588) then
- print("Opening ...")
- for t = 1,3 do
- rednet.send(Portes[t], "true")
- end
- elseif checkCoord(x, y, z, 687, 65, -587, 688, 66, -586) or
- checkCoord(x, y, z, 696, 65, -591, 697, 66, -590) then
- print("Closing ...")
- for t = 1,3 do
- rednet.send(Portes[t], "false")
- end
- end
- sleep(4)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement