Created
April 21, 2020 00:09
-
-
Save groverburger/3a4c1a1b368830b2734a800c56686672 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 socket = require "socket" | |
function love.load() | |
udp = socket.udp() | |
Setup = false | |
Thing = "n/a" | |
Input = "" | |
love.keyboard.setKeyRepeat(true) | |
end | |
function love.keypressed(k) | |
if k == "return" then | |
Setup = true | |
udp:settimeout(0) | |
udp:setpeername(Input, 45645) | |
udp:send("init") | |
end | |
if k == "backspace" then | |
Input = Input:sub(1,#Input-1) | |
end | |
end | |
function love.textinput(text) | |
Input = Input .. text | |
end | |
function love.update(dt) | |
if Setup then | |
repeat | |
local data, ip = udp:receive() | |
if data then | |
Thing = data | |
end | |
until not data | |
end | |
end | |
function love.draw() | |
love.graphics.print("client") | |
love.graphics.print("> " .. Input, 100,80) | |
love.graphics.print("output : " .. Thing, 100,100) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment