Multiplayer Help
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- CanadianGamer
- Party member
- Posts: 132
- Joined: Tue Jun 30, 2015 1:23 pm
- Location: Canada
- Contact:
Multiplayer Help
Hi I have recently been trying to make an online game so I went and read the networking tutorial on the wiki, but it didn't explain why you really have to format the string before sending from the server. Why is it necessary? Any help anyone could provide would be helpful
My serious itch.io page:
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
Re: Multiplayer Help
If you're referring to lines like this one
that's equivalent to
The point is to turn it into a single string like
I would recommend having a look at enet for networking.
Code: Select all
local dg = string.format("%s %s %d %d", entity, 'at', 320, 240)
Code: Select all
dg = entity.." at "..320.." "..240
Code: Select all
"*entity* at 320 240"
Re: Multiplayer Help
Because string is basically array of bytes which is easy to work with: to compose on sender side and to process on receiver side using standard string libraries. You can set up communication without using strings and using your own encode-decode format, but your data is going to be a pack of bytes anyway.
Re: Multiplayer Help
I have a question. If I format the string, will it be sent as a string? Can I send packages as raw bytes to increase bandwidth?
- CanadianGamer
- Party member
- Posts: 132
- Joined: Tue Jun 30, 2015 1:23 pm
- Location: Canada
- Contact:
Re: Multiplayer Help
Thank you guys so much I was getting really confused
My serious itch.io page:
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Multiplayer Help
Yes.Zvoc47 wrote:I have a question. If I format the string, will it be sent as a string?
No.Zvoc47 wrote:Can I send packages as raw bytes to increase bandwidth?
You can only send strings, because what's sent is the contents of the string, and they're sent as raw bytes.
Help us help you: attach a .love.
- GhostAction
- Prole
- Posts: 34
- Joined: Wed Apr 22, 2015 11:10 pm
- Contact:
Re: Multiplayer Help
Another easier way, in my opinion is having in loop through the data, finding every space, then separating the works/numbers/characters and then putting them into a table in order.
Then I use something like:
Just I little thing I found out. But the other way is great too, just never figured out how to use it lol.
Code: Select all
for i in string.gmatch(receivedData, "%S+") do
table.insert(command, i)
end
Code: Select all
if command[1] == "dog" then
print("cat")
end
command = {}
Owner of Isocubic. (Developer of void²)
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 8 guests