Online games in love2d

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
A-lox
Prole
Posts: 43
Joined: Sun Apr 10, 2022 1:58 am

Online games in love2d

Post by A-lox »

I am a complete beginner in this topic. :awesome:
I don't know where to start. :( I don't want to make anything complicated I want to send numbers from one PC to another. :ultrahappy:
test project: a clicker and I want to know all the clicks that have been clicked so far. :o:
or a game like cursor hangout (on replit link:https://replit.com/@TechPandaPro/Cursor-Hangout?v=1) :nyu:
something simple but I want to learn love2d networking with luasocket or something else. :D ^^ :awesome:
I need help with this topic a tutorial or documentation or a link to a wiki would be nice :ultrahappy: :| :oops:
Andlac028
Party member
Posts: 174
Joined: Fri Dec 14, 2018 2:27 pm
Location: Slovakia

Re: Online games in love2d

Post by Andlac028 »

You can follow this tutorial with explained networking with UDP.

There is also TCP and lua-enet. The difference is, that in UDP, you do nit have guaranteed, that client or server received message, but it is faster (used for example in streaming or online games, when you send a lot of data about position - if client wouldn’t receive first oacket, the it would receive another packets in some time).

In TCP, you have guaranteed that the client received it (or you get error when it is not received), but is is little slower, as it sends more oackets in background to verify, the client received it. It is used in applications, when you need to be sure client received content (for example www, mail, file transfer, …).

UDP and TCP are raw internet protocols used everywhere. Then you have enet, which is protocol on top of UDP with some enhancements (for example chcecking, if client really received the message), and if I remember correctly, it also packs tables automatically, so no need to worry about how to send tables. Documentation: lua-enet
User avatar
Bigfoot71
Party member
Posts: 287
Joined: Fri Mar 11, 2022 11:07 am

Re: Online games in love2d

Post by Bigfoot71 »

There was already a similar topic some time ago (see until the last post, there are examples and an interesting suggestion by togFox)

However, before going there, I strongly advise you to do and understand the UDP tutorial offered by Andlac, it will help you get started and understand the main principles, after all that is done and with the information given in this other topic. you should be ready to make great multi games ^^

https://love2d.org/forums/viewtopic.php?f=4&t=94276
My avatar code for the curious :D V1, V2, V3.
RNavega
Party member
Posts: 353
Joined: Sun Aug 16, 2020 1:28 pm

Re: Online games in love2d

Post by RNavega »

A-lox wrote: Fri Mar 10, 2023 4:01 am I don't want to make anything complicated I want to send numbers from one PC to another.
Besides that wiki tutorial that Andlac028 pointed to and Bigfoot71's thread, if you're not brand new to coding and you explicitly ask it not to show any code so it focuses on the theory alone, then in my experience ChatGPT can be a useful tool if you use it like a smart web search.

If you ask it to write code then it might generate something unusable, so rather ask it something like "using LuaSocket, without showing any code, what are the steps to making two PCs communicate with UDP". Then ask follow-up questions or to expand on certain things -- in my case, I had to ask "what if both PCs can send and receive?" to get it to talk about bidirectional communication.

I used it in the past to learn how to write a raw HTTP socket server in Python, it's very useful if you know how to wield it.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot], Bondrusiek and 3 guests