Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Set the vault and monitor peripherals
- function monitorSearch()
- local names = peripheral.getNames()
- local i, name
- for i, name in pairs(names) do
- if peripheral.getType(name) == "monitor" then
- return peripheral.wrap(name)
- else
- --return null
- end
- end
- end
- function modemSearch()
- local names = peripheral.getNames()
- local i, name
- for i, name in pairs(names) do
- if peripheral.getType(name) == "modem" then
- return peripheral.wrap(name)
- else
- --return null
- end
- end
- end
- monitor = monitorSearch()
- modem = modemSearch()
- modem.open(1)
- modem.open(2)
- while true do
- local event, side, channel, replyChannel, message, distance
- event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- if((channel == 1) and (message == "Hello")) then
- modem.transmit(replyChannel, 1, "Confirmed")
- elseif(channel == 2) then
- charPos = string.find(message,":")
- qty = string.sub(message,(charPos+1))
- name = string.sub(message,0,(charPos-1))
- print(name.." "..qty)
- modem.transmit(replyChannel, 2, "Okay")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement