Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- globalPort = 5296
- modem = peripheral.find("modem")
- modem.open(globalPort)
- db = {}
- commands = {
- alert = function(input)
- assert(type(input) == "string", "helloWorld expects a string for its input")
- print("ALERT: " .. input)
- return true
- end,
- }
- function commandParser(event, side, channel, replyChannel, message, distance)
- print(textutils.serialise(message))
- if commands[message.cmd] ~= nil and message.args ~= nil then
- ran, err = pcall(commands[message.cmd], table.unpack(message.args))
- if not ran then
- print(("Error in \"%s\": %s"):format(message.cmd, err))
- end
- else
- print(("No command named \"%s\" found"):format(message.cmd))
- end
- end
- function commandRunner(command, target, arguments)
- assert(type(command) == "string", "commandRunner expects a string for its input \"command\"")
- assert(type(target) == "number", "commandRunner expects a number for its input \"target\"")
- assert(type(arguments) == "table", "commandRunner expects a table for its input \"arguments\"")
- modem.transmit(5296,5296, {cmd=command, tgt=target, args=arguments})
- end
- while true do
- commandParser(os.pullEvent("modem_message"))
- end
Advertisement
Add Comment
Please, Sign In to add comment