call MPSTART in the very beginning of the game
This will give variable MPLOCAL a number (starting at 0 and counting up, each connected device has a unique number)
This also sets MPHOST
Examples in code:
IF MPLOCAL!=-1 THEN 'if server is open
IF MPLOCAL==MPHOST THEN 'if you are the creator of the server
Now: you use MPGET and MPSET to set a multiplayer value, you can have 8 variables shared ...
... this is one way to communicate
The other way is using MPSEND
This will send a string to every device connected, it just pushes it onto a queue, then the player uses MPRECV to check whatever's on the queue and get the string
MPSEND and MPRECV are like a mailbox
MPSET does not send any data out, just sets it's own 8 3DS variables
MPGET goes out and looks for someone else's 8 variables
MPNAME$ simply gets the name of whatever device you want
In the SmileBASIC tutorials, these assigned MPLOCAL values are called Terminal IDs
More code examples:
PRINT "Server created by "+MPNAME$(MPHOST)
PRINT "Your name is "+MPNAME$(MPLOCAL)
MPSEND "HI EVERYBODY!"
MPRECV OUT tid,message$
PRINT MPNAME$(tid)+" said "+message$
'which will print out "Squidy said HI EVERYBODY!" to every device
Simple mulyiplayer chat:
(Not tested but I'm 99% sure it works)
ACLS
MPSTART
?"PRESS A TO CHAT"
@LOOP 'make an infinite loop
VSYNC 'make loop run at 60fps
MPRECV TID,MSG$ 'loop for a message
IF TID>=0 THEN ?MPNAME$(TID)+": "+MSG$
IF BUTTON() AND #A THEN
INPUT "TYPE A MESSAGE";MSG$
MPSEND MSG$
ENDIF
GOTO @LOOP
Wait first tell me what you are trying to do, are you making a multiplayer chat? Or a multiplayer drawing application? Or a multiplayer platformer? A multiplayer firework simulator? Multiplayer pong game? Multiplayer tic tac toe? Chess? Do you have a game you want to add multiplayer to? What's your goal here? ...just wondering :)