Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,9 @@ function locate(_nTimeout, _bDebug)
end

-- Find a modem
local sModemSide = nil
for _, sSide in ipairs(rs.getSides()) do
if peripheral.getType(sSide) == "modem" and peripheral.call(sSide, "isWireless") then
sModemSide = sSide
break
end
end

if sModemSide == nil then
local modem = peripheral.find("modem", function(_, m) return m.isWireless() end)

if modem == nil then
if _bDebug then
print("No wireless modem attached")
end
Expand All @@ -127,7 +121,7 @@ function locate(_nTimeout, _bDebug)
end

-- Open GPS channel to listen for ping responses
local modem = peripheral.wrap(sModemSide)
local sModemSide = peripheral.getName(modem)
local bCloseChannel = false
if not modem.isOpen(CHANNEL_GPS) then
modem.open(CHANNEL_GPS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe("The gps library", function()
local computer = fake_computer.make_computer(1, fn)
computer.position = vector.new(x, y, z)
fake_computer.add_api(computer, "rom/apis/gps.lua")
fake_computer.add_api(computer, "rom/apis/peripheral.lua")
fake_computer.add_api(computer, "rom/apis/vector.lua")

local modem = fake_computer.add_modem(computer, "back")
Expand All @@ -39,6 +40,7 @@ describe("The gps library", function()
end)
host.position = position
fake_computer.add_api(host, "rom/apis/gps.lua")
fake_computer.add_api(computer, "rom/apis/peripheral.lua")
fake_computer.add_api(host, "rom/apis/vector.lua")

local host_modem = fake_computer.add_modem(host, "back")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ local function make_computer(id, fn)
getNames = function() return keys(peripherals) end,
isPresent = function(name) return peripherals[name] ~= nil end,
getType = function(name) return peripherals[name] and getmetatable(peripherals[name]).type end,
hasType = function(name, typ) return peripherals[name] and getmetatable(peripherals[name]).type == typ end,
getMethods = function(name) return peripherals[name] and keys(peripherals[name]) end,
call = function(name, method, ...)
local p = peripherals[name]
Expand Down