Page 1 of 1

UDP and Modules

Posted: Mon May 16, 2016 10:10 pm
by GhostAction
So I'm making a multiplayer games and I just started switching everything to modules, but I ran into one problem: How do I get UDP to work within modules? I tried looping it through all the functions, but it barely worked. Any ideas?

Re: UDP and Modules

Posted: Mon May 16, 2016 10:18 pm
by s-ol
What? modules don't really change anything. You have some logical error somewhere in your architecture and we can't tell you what it is without you showing us your code.

Re: UDP and Modules

Posted: Mon May 16, 2016 10:20 pm
by GhostAction
Yeah I'll upload it one minute.

Re: UDP and Modules

Posted: Mon May 16, 2016 10:23 pm
by GhostAction
Alright uploaded them. The code is a tad bit different from a couple days ago, but the multiplayer part should be the same.

Re: UDP and Modules

Posted: Tue May 17, 2016 1:19 am
by pgimeno
Not related to your problem, but...

Code: Select all

local playerColors = {blue = 91, 192, 235; yellow = 253, 231, 76; green = 155, 197, 61; red = 195, 66, 63}
I don't think this does what you think it does. It is equivalent to this:

Code: Select all

local playerColors = {blue=91, [1]=192, [2]=235, yellow=253, [3]=231, [4]=76, green=155, [5]=197, [6]=61; red=195, [7]=66, [8]=63}
i.e. 'blue' gets the number 91, 'yellow' the number 253, 'green' the number 155, 'red' the number 195, and the elements with numeric indices 1, 2, 3, 4, 5, 6, 7 and 8 get the values 192, 235, 231, 76, 197, 61, 66, and 63 respectively.

You probably meant something like this:

Code: Select all

local playerColors = {blue = {91, 192, 235}; yellow = {253, 231, 76}; green = {155, 197, 61}; red = {195, 66, 63}}
because then you can do this:

Code: Select all

love.graphics.setColor(playerColors.blue)

Re: UDP and Modules

Posted: Tue May 17, 2016 6:30 pm
by GhostAction
Yeah I know, I probably copied from some code that was from a month ago.