LUBE Server 'nil' value

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
10$man
Citizen
Posts: 77
Joined: Sun Apr 22, 2012 10:40 pm

LUBE Server 'nil' value

Post by 10$man »

Hello everyone. I've been trying to implement LUBE into my game and I can't seem to figure this out. I've never really used libraries in Love2d so please bear with me :P

Alright, so here's my code as broken down as it gets.
There error I'm receiving is "Attempt to call 'server', A nil value" and this happens right when I try to create a server object.

Oh, and the OOP library I am using is the one from HUMP (But I've also tried out many of the other ones on the compatible list just in case)

Code: Select all

local class = require("LIBS/class")
require("LIBS/lube")


function onConnect(ip, port)
	print("Connection from " .. ip)
end

function onReceive(data, ip, port)

end

function onDisconnect(ip, port)

end

function love.load()
	server = lube.server(18025, "tcp")
	server:setCallback(onReceive, onConnect, onDisconnect)
	server:setHandshake("A23JS76SH")
end
What's really annoying me, is that I don't know where the problem comes from because I can't run anybody else's example LUBE programs.

Did I do something obviously wrong?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: LUBE Server 'nil' value

Post by bartbes »

It should be more along the lines of:

Code: Select all

function love.load()
	server = lube.tcpServer()
	server.callbacks.recv = onReceive
	server.callbacks.connect = onConnect
	server.callbacks.disconnect = onDisconnect
	server.handshake = "A23JS76SH"
	server:listen(18025)
end
10$man
Citizen
Posts: 77
Joined: Sun Apr 22, 2012 10:40 pm

Re: LUBE Server 'nil' value

Post by 10$man »

Yep, that fixed it :P
I guess what I was looking at was a bit dated.
Thanks for the help! I'll assume that the rest will work the same and I'll come back here if I was wrong.
Thanks again :)
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 223 guests