function search(perToFind)
local printMode = false
if perToFind == "print" or perToFind==nil then
printMode=true
end
if printMode == true then
term.clear()
term.setCursorPos(1,1)
end
local perip = peripheral.getNames()
for i=1, #perip do
if printMode == true then
if peripheral.getType(perip[i])=="modem" then
if peripheral.call(perip[i],"isWireless") then
print(perip[i] .. " -- modem.wireless")
else
print(perip[i] .. " -- " ..peripheral.getType(perip[i]))
end
else
print(perip[i] .. " -- " ..peripheral.getType(perip[i]))
end
else
if perToFind=="modem" or perToFind=="modem.wireless" then
if peripheral.getType(perip[i])=="modem" then
if peripheral.call(perip[i],"isWireless") and perToFind=="modem.wireless" then
return perip[i]
elseif not peripheral.call(perip[i],"isWireless") and perToFind=="modem" then
return perip[i]
end
end
else
if perToFind==peripheral.getType(perip[i]) or perToFind==perip[i] then
return perip[i]
end
end
end
end
if printMode == false then
throw("No such peripheral: " ..perToFind)
end
end
function wsearch (perToFind)
return peripheral.wrap(search(perToFind))
end
Comments
0 B
|👍
/👎