Page 1 of 1

I need help understanding how to make client and servers.

Posted: Mon Jun 14, 2021 6:14 pm
by InTheProcess
(Keep in mind that I am very new to love2d and Lua)

I am making a survival game that I want to be multiplayer. I want the player to be able to host and join games. I want them to be able to join with some special key or something. How would I go about doing this?

I've heard about Sockets and stuff, but I don't understand it. There are almost no tutorials on this subject.

Re: I need help understanding how to make client and servers.

Posted: Mon Jun 14, 2021 6:43 pm
by grump
InTheProcess wrote: Mon Jun 14, 2021 6:14 pm I've heard about Sockets and stuff, but I don't understand it. There are almost no tutorials on this subject.
Your question is too broad and can't be easily answered in a forum post. There are basic client/server examples on the LÖVE wiki though, they're not hard to find.

The rest of the internet has an infinite number of tutorials and basic documentation on how to use sockets. Not all of them target LÖVE, but the basics are always the same.

That being said: Making multiplayer games is hard and not a thing a beginner should attempt, especially not with a barebones framework like LÖVE. Frustration and failure are guaranteed.

Re: I need help understanding how to make client and servers.

Posted: Tue Jun 15, 2021 11:07 am
by Gunroar:Cannon()
You could try sock.lua or share.lua/sync.lua. They both come with tutorials and the libs make it very easy.

Re: I need help understanding how to make client and servers.

Posted: Tue Jun 15, 2021 11:17 am
by darkfrei
I would be nice to make an example how to send and to get any Lua table via TCP and UDP.

Re: I need help understanding how to make client and servers.

Posted: Tue Jun 15, 2021 2:07 pm
by milon
darkfrei wrote: Tue Jun 15, 2021 11:17 am I would be nice to make an example how to send and to get any Lua table via TCP and UDP.
See the wiki: https://love2d.org/wiki/lua-enet
There's some examples on that page that cover sending & receiving data. To send a table, I believe you just send the table variable (as opposed to the string used in the example). I haven't done any lua networking before, so I could be wrong.

Re: I need help understanding how to make client and servers.

Posted: Wed Jun 16, 2021 6:40 am
by Xii
You might want to use a serialization library like Blob.lua which lets you turn a Lua table into a string, which you can then send over the network. (and turn back into a table on the other side)

Re: I need help understanding how to make client and servers.

Posted: Wed Jun 16, 2021 7:48 am
by togFox
I use bitser to do the same thing.