For example sending certain data only to player 1 like player 1's x/y position.
my server/main.lua:
Code: Select all
love.filesystem.load("lib/LUBE.lua")()
local Server = NetTest:addState('Server')
function Server:enterState()
clearLoveCallbacks()
x = 0
print("initializing server")
function onConnect(ip, port)
print("Connection from " .. ip)
end
function onReceive(data, ip, port)
x = tonumber(data)
end
function onDisconnect(ip, port)
end
server = lube.server(18025)
server:setCallback(onReceive, onConnect, onDisconnect)
server:setHandshake("Hi!")
print("initialized server")
function love.update(dt)
server:update(dt)
end
function love.draw()
love.graphics.print(x, 100, 85)
end
function love.keypressed(k)
if k=='escape' then
netTest:gotoState('Menu')
end
end
end
function Server:exitState()
--TODO: Server EXIT CODE
print("Exiting server")
end