diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/gps.lua b/src/main/resources/assets/computercraft/lua/rom/apis/gps.lua index 5b556eb09..79b192494 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/gps.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/gps.lua @@ -84,16 +84,16 @@ function locate( _nTimeout, _bDebug ) print( "Finding position..." ) end - -- Open a channel + -- Open GPS channel to listen for ping responses local modem = peripheral.wrap( sModemSide ) local bCloseChannel = false - if not modem.isOpen( os.getComputerID() ) then - modem.open( os.getComputerID() ) + if not modem.isOpen( CHANNEL_GPS ) then + modem.open( CHANNEL_GPS ) bCloseChannel = true end -- Send a ping to listening GPS hosts - modem.transmit( CHANNEL_GPS, os.getComputerID(), "PING" ) + modem.transmit( CHANNEL_GPS, CHANNEL_GPS, "PING" ) -- Wait for the responses local tFixes = {} @@ -104,7 +104,7 @@ function locate( _nTimeout, _bDebug ) if e == "modem_message" then -- We received a reply from a modem local sSide, sChannel, sReplyChannel, tMessage, nDistance = p1, p2, p3, p4, p5 - if sSide == sModemSide and sChannel == os.getComputerID() and sReplyChannel == CHANNEL_GPS and nDistance then + if sSide == sModemSide and sChannel == CHANNEL_GPS and sReplyChannel == CHANNEL_GPS and nDistance then -- Received the correct message from the correct modem: use it to determine position if type(tMessage) == "table" and #tMessage == 3 and tonumber(tMessage[1]) and tonumber(tMessage[2]) and tonumber(tMessage[3]) then local tFix = { vPosition = vector.new( tMessage[1], tMessage[2], tMessage[3] ), nDistance = nDistance } @@ -141,7 +141,7 @@ function locate( _nTimeout, _bDebug ) -- Close the channel, if we opened one if bCloseChannel then - modem.close( os.getComputerID() ) + modem.close( CHANNEL_GPS ) end -- Return the response