Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s = Socket.new("http://chuie.io:9000/", Socket.randomId())
- s:on("term", function(msg)
- local buffer = textutils.unserialize(msg:gsub("\\u003c", "<"):gsub("\\u003e", ">"):gsub("\\u0026", "&"))
- for k, v in pairs(buffer) do
- local args = v
- local func = args[1]
- table.remove(args, 1)
- term[func](unpack(args))
- end
- end)
- term.clear()
- term.setTextColor(colors.white)
- term.setCursorPos(1,1)
- print("Ready...")
- local function listener()
- while true do
- local events = {os.pullEvent()}
- if events[1] == "key" or events[1] == "char" or
- events[1] == "mouse_click" or events[1] == "mouse_scroll" then
- s:write("event", textutils.serialize(events):gsub("\n", ""))
- end
- end
- end
- parallel.waitForAny(Socket.run, listener)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement