Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Finds devices connected to the computer, wraps them
- local function getDevices(deviceType) -- This function was taken from https://github.com/sandalle/minecraft_bigreactor_control and has been modified by https://github.com/Sanwi
- local deviceName = nil
- local deviceIndex = 1
- local deviceList, deviceNames = {}, {} -- Empty array, which grows as we need
- local peripheralList = peripheral.getNames() -- Get table of connected peripherals
- for peripheralIndex = 1, #peripheralList do -- Log every device found
- if (string.lower(peripheral.getType(peripheralList[peripheralIndex])) == deviceType) then -- Log devices found which match deviceType and which device index we give them
- deviceNames[deviceIndex] = peripheralList[peripheralIndex]
- deviceList[deviceIndex] = peripheral.wrap(peripheralList[peripheralIndex])
- deviceIndex = deviceIndex + 1
- end
- end -- for peripheralIndex = 1, #peripheralList do
- return deviceList, deviceNames
- end
- local deviceList, deviceNames = getDevices("modem")
- local modem = deviceList[1]
- rednet.open(deviceNames[1])
- while true do
- local senderId, message, protocol = rednet.receive()
- if type(message) == "string" then
- print(message)
- elseif type(message) == "table" then
- print(textutils.serialize(message))
- else
- print(message)
- end
- local event,key = os.pullEvent("key")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement