Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- P-Remote
- -- An api to help use remote peripherals
- -- Created by GiantNuker
- -- Gets the side your wired modem is on
- function getModemSide()
- side = ""
- if peripheral.isPresent("front") then
- if peripheral.getType("front")
- side = "front"
- end
- else if peripheral.isPresent("back") then
- if peripheral.getType("back")
- side = "back"
- end
- else if peripheral.isPresent("up") then
- if peripheral.getType("up")
- side = "up"
- end
- else if peripheral.isPresent("down") then
- if peripheral.getType("down")
- side = "down"
- end
- else if peripheral.isPresent("left") then
- if peripheral.getType("left")
- side = "left"
- end
- else if peripheral.isPresent("right") then
- if peripheral.getType("right")
- side = "right"
- end
- return side
- end
- -- Returns a modem object based on the above
- function getModem()
- return peripheral.wrap(getModemSide())
- end
- -- Gets the names of the peripherals using getNamesRemote()
- function getRemotePeripherals()
- return getModem().getNamesRemote()
- end
- -- Gets the methods of the peripherals using getMethodsRemote(peripheral)
- function getPeripheralMethods(peripheral)
- return getModem().getMethodsRemote(peripheral)
- end
- -- Checks if a certain peripheral is connected
- function hasRemotePeripheral(peripheral)
- return getModem().isPresentRemote(peripheral)
- end
- -- Calls a function of a selected peripheral
- function callRemoteMethod(peripheral, method)
- return callRemote(peripheral, method)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement