I need help understanding how to make client and servers.

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
InTheProcess
Prole
Posts: 11
Joined: Thu May 27, 2021 4:19 pm

I need help understanding how to make client and servers.

Post 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.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

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

Post 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.
User avatar
Gunroar:Cannon()
Party member
Posts: 1143
Joined: Thu Dec 10, 2020 1:57 am

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

Post 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.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

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

Post by darkfrei »

I would be nice to make an example how to send and to get any Lua table via TCP and UDP.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

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

Post 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.
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
User avatar
Xii
Party member
Posts: 137
Joined: Thu Aug 13, 2020 9:09 pm
Contact:

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

Post 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)
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

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

Post by togFox »

I use bitser to do the same thing.
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
Post Reply

Who is online

Users browsing this forum: kov_serg and 2 guests