Hey ! No problem, it's very cool that you keep answering and helping me <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">
So, concerning the synchronization of global values, this is pretty much the same idea I had (found in this thread : https://www. scirra.com/forum/how-do-i-sync-global-variables-over-multiplayer_t101878). The problem is that the peer always gets a NaN value for the timer. Apparently, there is a problem with sending a variable as a message. The guy in the thread had the same problem and found an alternative solution which is not clearly explained, so I am stuck here.
I will try the other stuff too and come back. (Just mentioning "randomly" in my edit will give you a notification ?)
Edit randomly : Concerning the use of families. I looked at your .capx and I understand quite clearly how this work, but still, I can't think of a way to spawn my creatures according to my "Spawn" variable. As you can see in my .capx, I already have a "Creatures" family with all the sprites in it, and I have several events using this like : on start of layout > delete "Creatures" (and that's convenient). I also have the "index" instance variable set accordingly for each sprite, as you explained me. But I don't know how to say to the game "you have to spawn the creature who's "Index" value is egal to the current "Spawn" value". I tried your idea of "picking "Creature" by evaluating "Index = Spawn" but that did not work. That's the only detail that I am stuck with.
- Concerning the smart random "next" expression. After some testing, it appears to be more simple than what you explained. "Start" expression always give you the lowest possible value in the range (useless in my case), but "next" actually starts from the first value of the sequence. Proof is in this .capx : https://www. dropbox.com/s/5l7ztd8kndlsov8/Next.expression-test.capx?dl=0
Notice that the two first value you get are always different, which proves they belong to the same loop, thus the first time you click on "next" you really get the first value in the sequence. If you started at the second value, skipping the first one, then you would start at the edge of a loop and have a 50% chance that the first value of the next loop is the same.
Illustration : with a sequence like 2-1 / 1-2 / 1-2 / 2-1 / ...
The two first value you get using only "next" is this : 2-1 / 1-2 / 1-2 / 2-1 / ...
And never : 2-1 / 1-2 / 1-2 / 2-1 / ...
Which is what I want anyway. So that's cool. Now I have to think of the way to always send the "next" value to every peer upon connection. Of course, I tried "upon peer connected" > send message, tag "Group", message "Groupgenerator.Next". But that wouldn't work since "Groupgenerator.Next" is a number and not a string (damn, that limitation is troublesome).
Here is another idea I just tried, but it failed (too bad! I was confident this time ah ah) : I created a "GlobalValues" dictionnary. The host task is to add a "Timer" key every second with the value "Timer" (global variable's current value), and add a key "Group" on peer connected, with the value "GroupGenerator.Next". Then, broadcast a message every second, tag "Timer", message "GlobalValues.Get(Timer)" and send a message on peer connected, ID "Multiplayer.FromID", tag "Group", message "GlobalValues.Get(Group)". For the peers : on peer message, tag "Timer"/"Group", set "Timer/Group" (Global variable) to "Multiplayer.message".
And of course, it doesn't work for both : "Timer" gets a NaN value and "Group" doesn't change at all.
- Concerning dictionnaries, I think I have a hard time understanding how the informations can be transmitted from host to peer. It seems the "AsJSON" expression is the key, but I don't really get it. For example, I suppose I could send the "GlobalVariables" Dictionnary as JSON and make the peer load it somehow and then set their global values accordingly. But I have troubles with this whole "host transforms into JSON > send to peers > Peers transform back to dictionnary objet" process. I think I would need a concrete example on that one.