LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

An "easier" way to program multiplayer games?

Root / Programming Questions / [.]

RealTiPCreated:
I'm currently working on a multiplayer game, that translates strings from mpsend to modify certain variables. Is there an "easier" way to send variables to another console?

Depending on what you need, it might be more convenient to use MPGET and MPSET. Each terminal (i.e. each 3DS) has 8 (or 9?) variables that it can set, and other terminals can read these values. So for example, each player's health will be saved to his first network variable: MPSET 0, HP then everyone can see every player's health:
P1HP = MPGET(0, 0)
P2HP = MPGET(1, 0)
P3HP = MPGET(2, 0)
P4HP = MPGET(3, 0)
This system isn't perfect for every situation, but it's very convenient for storing player-specific info that is required on every player's console. It's also important to remember that only integers are allowed, not floating-point numbers. http://smilebasic.com/en/reference/#wireless

Thx, you saved me about 16 lines of code :D

There are 9 variables. And updates to the variables are not guaranteed to be detected in order. In other words, say you have one variable which is a counter of cumulative HP regeneration, and another which is cumulative HP damage. One console may increment its 'regen' counter just in time to survive a damaging hit, but other consoles may see (for a moment) values indicating the player should die. So, as much as possible, put independent values, independent aspects of the game, into different variables (or, use a communications protocol) to avoid such glitches and inconsistent game states.