LÖVE CÖNNECTION 1.4

Showcase your libraries, tools and other projects that help your fellow love users.
.InsertNameHere
Prole
Posts: 9
Joined: Mon May 18, 2015 6:53 am

Re: LÖVE CÖNNECTION 1.4

Post by .InsertNameHere »

It sure looks like good stuff, but could we get a bit better of a tutorial, especially explaining all of the other commands?
For example, what if I only want to do something simple, like send a table?

The whole encode and decode thing seems interesting to me, but how to I send a table using that?

Thanks!
.InsertNameHere
Prole
Posts: 9
Joined: Mon May 18, 2015 6:53 am

Re: LÖVE CÖNNECTION 1.4

Post by .InsertNameHere »

Also, I can't even seem to get the server to connect to the client :(.

Client:

Code: Select all

Net = require 'net'

function love.load()
	Net:init("Client")
	Net:connect(localhost, 20024)
end

function love.draw()
	if Net.connected then
		love.graphics.print("Connected")
	end
end
Server:

Code: Select all

Net = require 'net'

function love.load()
	Net:init("Server")
	Net:connect(nil, 20024)

end
Nicholas Scott
Prole
Posts: 49
Joined: Sun Jun 07, 2015 9:12 am

Re: LÖVE CÖNNECTION 1.4

Post by Nicholas Scott »

.InsertNameHere wrote:Also, I can't even seem to get the server to connect to the client :(.
*If you need ANYMORE help feel free to pm me and I'll respond asap, sorry I didn't respond quicker I was playing some CS:GO xD

This could be of several things I see, first off you are calling "Net:connect( localhost, 20024 )" and my question is do you have the variable localhost set, and if not I HIGHLY suggest changing that to a string value of 127.0.0.1 as such: "Net:connect( "127.0.0.1", 20024 )"
Another possible reason could be that you aren't calling the Net:update(dt) in an active love.update(dt) function
It should change to look like this.
Client:

Code: Select all

Net = require 'net'

function love.load()
	Net:init("Client")
	Net:connect("127.0.0.1", 20024)
end

function love.draw()
	if Net.connected then
		love.graphics.print("Connected")
	end
end

function love.update( deltatime )
        Net:update( deltatime )
end

Server:

Code: Select all

Net = require 'net'

function love.load()
	Net:init("Server")
	Net:connect(nil, 20024)

end

function love.update( deltatime )
       Net:update( deltatime )
end
As for the tutorial, I will update it and make it MUCH more in depth, I just need a little bit of time, and as for sending nothing but a table to the server I would suggest using the command system implimented so you have the server actually do something when it receives it as such, however you can always just send it to the server as a raw table without the command system and on server use the net.event.server.receive( data, cmd, param, id ) if you so desire, for this example I will send to the server the name I have input on my client and my color I have chosen and then set those into the user database.

CLIENT:

Code: Select all

Net = require( "modules.Net" )

function love.load()
	Net:init( "Client" )
	Net:connect( "127.0.0.1", 20024 )
	timer = 0

	client_data = {}
	client_data.name = "Nick"
	client_data.colorR = 255
	client_data.colorG = 100
	client_data.colorB = 0

end

function love.update( dt )
	Net:update( dt ) --WE MUST CALL THIS IN THE love.update and pass a deltatime for the network to update properly
	timer = timer + dt
	if timer > 10 then
		timer = -1654163 --Sets the timer so it won't trigger for a LONG time, just an example of course :P
		Net:send( client_data, "updateClientInfo", nil ) --client_data is our table we created in love.load, remember ANYTHING can be in this table and it will be sent to server, second is the command for the server to issue, and the last "" is a parameter of the command, since the command we are issuing doesn't need parameters we will just set it to nil
	end
end
SERVER:

Code: Select all

Net = require( "modules.Net" )

function love.load()
	Net:init( "server" )
	Net:connect( nil, 20024 )
	Net:registerCMD( "updateClientInfo", function( client_data, param, id, deltatime ) --client_data is whatever you want to call it, it's the table we sent from the client with our data in it ;)
		if not client_data.name then return end --Just some safety features
		if not client_data.colorR then return end
		if not client_data.colorG then return end
		if not client_data.colorB then return end

		Net.users[id].name = client_data.name --Adds the name sent by the client to the clients table in our database of users
		Net.users[id].colorR = client_data.colorR --Adds the red color value sent by the client to the clients table in our database of users
		Net.users[id].colorG = client_data.colorG --Adds the green color value sent by the client to the clients table in our database of users
		Net.users[id].colorB = client_data.colorB --Adds the blue color value sent by the client to the clients table in our database of users
	end )
end

function love.update( dt )
	Net:update( dt )
end
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: LÖVE CÖNNECTION 1.4

Post by Jeeper »

Awesome work, keep it up. I am actually in need of something like this, so thank you! :)
Nicholas Scott
Prole
Posts: 49
Joined: Sun Jun 07, 2015 9:12 am

Re: LÖVE CÖNNECTION 1.4

Post by Nicholas Scott »

Jeeper wrote:I am actually in need of something like this, so thank you! :)
Great man! If you make anything using the library let me know! I'd love to see it :D
User avatar
SiENcE
Party member
Posts: 805
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: LÖVE CÖNNECTION 1.4

Post by SiENcE »

Can you create a github repo for this?
Nicholas Scott
Prole
Posts: 49
Joined: Sun Jun 07, 2015 9:12 am

Re: LÖVE CÖNNECTION 1.4

Post by Nicholas Scott »

SiENcE wrote:Can you create a github repo for this?
Sure -_- Gotta make things difficult huh? Nuh, jk, I'll do this now. I was putting it off cause I didn't think it would be of any assistance, but sure... Since I'm here I might as well make some documentation on using it xD All things I didn't wanna do xD
RovieD
Prole
Posts: 5
Joined: Mon Jul 20, 2015 7:55 pm
Contact:

Re: LÖVE CÖNNECTION 1.4

Post by RovieD »

Could you throw a more detailed example. For example, you can send one message from the server to the client and from the client to the server. Display this messages. It needs an example. Thanks!
Nicholas Scott
Prole
Posts: 49
Joined: Sun Jun 07, 2015 9:12 am

Re: LÖVE CÖNNECTION 1.4

Post by Nicholas Scott »

RovieD wrote:Could you throw a more detailed example.
Yeah absolutely, give me a bit. I ment to do this alot sooner but I have been super busy lately, lots of stuff going on, But I will definitely do that when I get home from work in about 7 hours :D
calusari
Prole
Posts: 1
Joined: Tue Jul 28, 2015 7:35 pm

Re: LÖVE CÖNNECTION 1.4

Post by calusari »

Great library! Been messing around with it and it seems very promising! I love the run remote command feature.

Would like to see a feature to drop packets that are out of order

Ex.

Server sends packets 1, 2, 3

Client receives packets in order 3, 2, 1 (and should drop packets 2 and 1 because 3 is the latest most up to date info)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest