Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
LyqydNet-Programs/net
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
66 lines (64 sloc)
1.96 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local tArgs = { ... } | |
| if tArgs[1] == "route" then | |
| --routes stuff | |
| if tArgs[2] == "print" then | |
| for rId, rInfo in pairs(net.routeTable) do | |
| print(rId..": "..rInfo.name.." ("..rInfo.gateway..":"..rInfo.cost..")") | |
| end | |
| elseif tArgs[2] == "flush" then | |
| net.routeTable = {} | |
| return net.netInit() | |
| end | |
| elseif tArgs[1] == "shell" and #tArgs == 2 then | |
| local packetConversion = { | |
| TW = "textWrite", | |
| TC = "textCursorPos", | |
| TG = "textGetCursorPos", | |
| TD = "textGetSize", | |
| TI = "textInfo", | |
| TE = "textClear", | |
| TL = "textClearLine", | |
| TS = "textScroll", | |
| TB = "textBlink", | |
| TF = "textColor", | |
| TK = "textBackground", | |
| TA = "textIsColor", | |
| } | |
| local serverConnection, remoteDir = connection.open(tArgs[2], 23, 10) | |
| if not serverConnection then | |
| print("Connection Failed") | |
| return | |
| else | |
| term.clear() | |
| term.setCursorPos(1,1) | |
| end | |
| --connect to a server. | |
| while true do | |
| event = {os.pullEvent()} | |
| if event[1] == "socket_message" then | |
| --convert packet type somehow, if it's ours. | |
| local cInfo = connection.connectionTable[serverConnection] | |
| if cInfo.localport == tonumber(string.match(event[4], "^(%d+),%d+;")) and cInfo.foreignport == tonumber(string.match(event[4], "^%d+,(%d+);")) and cInfo.route == event[2] then | |
| event[4] = string.match(event[4], ";(.*)") | |
| if packetConversion[event[3]] then | |
| event[3] = packetConversion[event[3]] | |
| connection.processText(serverConnection, event[3], event[4]) | |
| elseif event[3] == "SC" then | |
| if term.isColor() then | |
| term.setBackgroundColor(colors.black) | |
| term.setTextColor(colors.white) | |
| end | |
| term.clear() | |
| term.setCursorPos(1, 1) | |
| print("Connection closed by server.") | |
| return | |
| end | |
| end | |
| elseif event[1] == "mouse_click" or event[1] == "mouse_drag" or event[1] == "mouse_scroll" or event[1] == "key" or event[1] == "char" then | |
| connection.send(serverConnection, "event", textutils.serialize(event)) | |
| end | |
| end | |
| else | |
| print("Usage: net route <print|flush>") | |
| print(" net shell <servername>") | |
| end |