LÖVE CÖNNECTION 1.4
-
- Prole
- Posts: 9
- Joined: Mon May 18, 2015 6:53 am
Re: LÖVE CÖNNECTION 1.4
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!
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!
-
- Prole
- Posts: 9
- Joined: Mon May 18, 2015 6:53 am
Re: LÖVE CÖNNECTION 1.4
Also, I can't even seem to get the server to connect to the client .
Client:
Server:
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
Code: Select all
Net = require 'net'
function love.load()
Net:init("Server")
Net:connect(nil, 20024)
end
-
- Prole
- Posts: 49
- Joined: Sun Jun 07, 2015 9:12 am
Re: LÖVE CÖNNECTION 1.4
*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.InsertNameHere wrote:Also, I can't even seem to get the server to connect to the client .
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
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
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
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
Re: LÖVE CÖNNECTION 1.4
Awesome work, keep it up. I am actually in need of something like this, so thank you!
-
- Prole
- Posts: 49
- Joined: Sun Jun 07, 2015 9:12 am
Re: LÖVE CÖNNECTION 1.4
Great man! If you make anything using the library let me know! I'd love to see itJeeper wrote:I am actually in need of something like this, so thank you!
Re: LÖVE CÖNNECTION 1.4
Can you create a github repo for this?
-
- Prole
- Posts: 49
- Joined: Sun Jun 07, 2015 9:12 am
Re: LÖVE CÖNNECTION 1.4
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 xDSiENcE wrote:Can you create a github repo for this?
Re: LÖVE CÖNNECTION 1.4
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!
-
- Prole
- Posts: 49
- Joined: Sun Jun 07, 2015 9:12 am
Re: LÖVE CÖNNECTION 1.4
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 hoursRovieD wrote:Could you throw a more detailed example.
Re: LÖVE CÖNNECTION 1.4
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)
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)
Who is online
Users browsing this forum: No registered users and 3 guests