Skip to content

Instantly share code, notes, and snippets.

@groverburger
Created April 21, 2020 00:09
Show Gist options
  • Save groverburger/3a4c1a1b368830b2734a800c56686672 to your computer and use it in GitHub Desktop.
Save groverburger/3a4c1a1b368830b2734a800c56686672 to your computer and use it in GitHub Desktop.
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