Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- BetterNet API for better wireless networking
- -- Free to use by everybody
- ---- Variables
- local modem = "top"
- local listeners = {}
- ---- Functions
- -- openConnection() opens a connection.
- function openConnection(modem)
- modem = modem
- rednet.open(modem)
- end
- -- listen() listens for any messages coming in, this blocks code from running.
- function listen(protocol)
- senderID, message = rednet.receive(protocol)
- if (type(message[1]) == table) then
- if (listeners[message[1]]) then
- listeners[message[1]]()
- end
- end
- end
- -- get() specifies a function that needs to be ran if a certain message was sent.
- function get(message, functionToRun)
- listeners[message] = functionToRun
- end
Add Comment
Please, Sign In to add comment