Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- --1 = /c or /h, 2 = Channel
- if tArgs[1] == nil or tArgs[2] == nil then
- print("Usage: Remoteterm /c or /h, Channel")
- return
- end
- local modem = nil
- for _, name in pairs(peripheral.getNames()) do
- if peripheral.getType(name) == "modem" then
- modem = peripheral.wrap(name)
- end
- end
- if modem == nil then
- print("Could not find modem")
- end
- local command = ""
- if tArgs[1] == "/h" then
- modem.open(tonumber(tArgs[2]))
- while true do
- local evt, p1, p2, p3, p4, p5 = os.pullEvent()
- if evt == "key" then
- if p1 == 28 then
- shell.run(command)
- command = ""
- end
- end
- if evt == "char" then
- command = command ..p1
- end
- if evt == "modem_message" then
- if p2 == tArgs[2] then
- command = p4
- shell.run(command)
- command = ""
- end
- end
- end
- elseif tArgs[1] == "/c" then
- while true do
- print("Send command: ")
- command = read()
- modem.transmit(tonumber(tArgs[2]),tonumber(tArgs[2]+1),command)
- command = ""
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement