[Help] Lube networking
Posted: Sun Dec 02, 2012 12:00 pm
I got lube networking working for me so far. i am currently having problems figuring out how to send data via TCP to player 1, 2, 3, and 4. server:send(data) doesn't even seem to send anything also.. and the data variable is not empty.
For example sending certain data only to player 1 like player 1's x/y position.
my server/main.lua:
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