iCloud Multiplayer! Guess The Number Game

4

SP4CEBAR 2025-10-07 14:40 (Edited)

We Have Online Multiplayer!


        Open In Editor (single player)


How Is This Even Possible!?

An NX program can save data to a file named "Disk.nx". On IOS, your NX programs, including your Disk.nx, are stored on iCloud, platforms like MacOS and Windows have more freedom but could store them on iCloud as well. iCloud allows collaborating on a file online with others, so I shared a Disk.nx with all of you (two actually, see section "Servers" below). When using this shared Disk.nx instead of your current Disk.nx, your program can "talk" to others that use the same disk. This program is made to play a simple game as turn-based online multiplayer. I expect the program to be easily modify-able for other turn-based online games.


Gameplay


How To Play Multiplayer Using iCloud

Prerequisites

  1. Make sure your iCloud is synchronized with your device.
    • IOS and Mac should do this already.
    • On Windows, you should download iCloud and enable the iCloud drive folder.
    • On Linux, you will need to get a tool to sync iCloud to a folder.
  2. Make sure there is a folder in your iCloud Drive root (highest level in folder structure) named "LowRes NX".
    • If you used NX on IOS, it likely exists already, which is good.

How to set up multiplayer

  1. If there is a Disk.nx in the same folder as your program, rename it so it couldn't be overwritten in the next steps.
  2. Save a shared Disk.nx file to your iCloud
    • Like my Disk.nx
      • anyone can modify it, read more about the risks in the section "Risks Of A Public Disk.nx" below
      • Section "servers" below may list more disks I shared.
  3. Move this Disk.nx to your iCloud "LowRes NX" folder.
    • be sure to remove it after playing multiplayer so you can use a standard Disk.nx again.
  4. Proceed when you are ready to play multiplayer, and have an appointed time and order of joining (with about 30 seconds between each joining player).
    • See section "joining orderly" below for more details.
  5. On IOS, click "open in app" on the program upload below; on other platforms, Download this NX program and move it to your iCloud "LowRes NX" folder, and run it.
    • Make sure that the NX program can access the shared "Disk.nx": it should be in the same folder as the program, in this case we used the "LowRes NX" folder on iCloud for both files.

Joining Orderly

Now that you are ready to play, here are some guidelines to avoid confusing the program:

  1. If you are the first player of a session, clear the shared disk if the most-recent change was more than 15 minutes ago.
    • If changes are made very recently, there is a good chance someone is playing right now, In which case you can go to the section "Servers" below to use a different Disk.nx file I shared.
    • Clearing the disk will ensure a clean start, the previous game may not have been shut down properly and may confuse your game if not cleared.
    • If the disk has a lot of NX data inside of it, please mail it to whoever edited it last (see file metadata) because they probably saved this in the shared Disk accidentally.
    • If everyone clears it regularly, the potential impact of spam will be reduced.
  2. Wait for the moment agreed upon with your fellow players before running the program yourself
    • This is to prevent two players getting the same ID and their turns will be the same.
    • After your program shows that it is waiting for players, the next player should wait 30 seconds or less depending on the cloud synchronization speed before they should join.
  3. keep the program running, cancelling prematurely requires the disk to be wiped manually before it can be played again, as the disk won't "know" you left
    • the disk will "know" when the game ended, so you won't have to wipe it in between games
  4. When you are done, delete the shared Disk from your iCloud to avoid writing to it accidentally in the future.
    • If you do write your precious NX files to it, save them immediately, or you may lose them if someone wiped the disk before a game.
      • Check your apple email if you did lose this data, someone may have salvaged it for you.
    • It could also save you phone credit and background tasks as the file may change and synchronize a lot, a spammer may even upload 1GB of text to the file (the size of the iCloud Drive of the sharing account).

Game

Notes


I Shared Disks

I shared Disk.nx files on iCloud (see "Servers" below): Save one to your iCloud, then move it to your "Lowres NX" folder on iCloud, then NX should be able to use it. See instructions above on "how to play". Don't confuse your "recents" folder with your "Lowres NX" folder like I did.

Servers

if the shared disk were in use, you could use another one

Notes On My Shared Disks

Risks Of A Public Disk.nx

⚠️ Tread with caution: anyone on the internet could have modified one of the Disk.nx files I shared


Related topics


SP4CEBAR 2025-10-08 15:41 (Edited)

How To Share A Disk

  1. Get an empty Disk.nx file (you can rename your current Disk.nx to keep it saved)
    • make sure this empty disk file is in the same folder as your NX program you will be running
  2. Share it via iCloud Drive or equivalent or host it on your device.
    • each player needs both read and write access
    • I found that iCloud allows you to give anyone with a link both read and write access, but I'm not sure if you'd want that.
      • In that case you could better use the Disk on iCloud I shared above
      • See "Risks Of Using A Public Disk.nx" above.
    • make sure to stop sharing your Disk afterward as you may need it for other projects, though it would be funny if people left their disk files linked and did not notice it.
  3. Communicate to your players:
    • when you will be playing
    • the order of players to run the program (to join)
      • make sure to wait around 30 seconds, depending on the synchronization speed, between each joining player.
    • how to access your shared Disk.nx with FTP credentials or a URL
  4. Follow the steps from the section above named "How To Play".

Technical details


Multiplayer Example Code

Turn based

You may treat this code as an example of a turn-based multiplayer game, you could for example modify it into a card game.

Reveal

If you are more adventurous, you could mess with the code to make different multiplayer rules: game where each player can prepare their moves all at once before the result of them is revealed, like rock paper scissors.

All at once

You could even try to let each connected program modify their file (channel) continuously to sync the states of more action-packed games.


Improvement Ideas

  1. Clients get the same ID if they join at the same time and become indistinguishable
    • have each client save a timer variable, to file 4 + TIMER MOD 12
      • this allows a two clients that joined near each other to be identified
      • there is still a 1 in 12 chance that both clients still wrote to the same file, in which case one of them may not be able to see the other's message.
      • I think the timer is counted since the app opened, PC clients that run an NX programs on boot may have the same timer value when they join

SP4CEBAR          a sneaky markdown trick

Update 1: essential fixes

I tested it on Linux by running two NX instances and it actually works!


SP4CEBAR 2025-10-08 19:47 (Edited)

Update 2: reliability and clarity


jpospTynker 2025-10-09 00:02

this is SICK! it’s crazy multiplayer works in LOWRES NX now


SP4CEBAR 2025-10-09 11:51

I'm glad you like it!


SP4CEBAR 2025-10-09 13:49 (Edited)

Update 3: party player


SP4CEBAR 2025-10-09 14:37 (Edited)

I shared a Disk with all of you!

Now you can play multiplayer on IOS! See program desciption above for more details.

Please let me know if you managed to open and modify the Disk, with an NX program on platforms other than IOS. I also just updated the description to provide more instructions and details.


SP4CEBAR 2025-10-09 16:24 (Edited)

Update 4: single player


jpospTynker 2025-10-09 21:42

this is awesome, definitely doing something with this! imagine 12-player Co-op with fellow NXers!


SP4CEBAR 2025-10-10 13:06 (Edited)

I love the enthausiasm! I updated the instructions to make it clear for most platforms how to play.

All we need now is to arrange a time when anyone that wants to play will be online to play!
...as well as a joining order (with around 30 seconds between each joining player)


SP4CEBAR 2025-10-10 13:22 (Edited)

Also, if anyone wants to modify this turn-based online multiplayer example into a more complex game such as a card game, feel free to do so:


SP4CEBAR 2025-10-10 18:45 (Edited)

Update 5


SP4CEBAR 2025-10-11 06:35

Update 6


SP4CEBAR 2025-10-11 08:51

Here's an invitation to play multiplayer: Do You Want To Play The First Online Multiplayer Game?


M&J Coding and Technologies 2025-10-11 14:38

Ummm I’m kinda confused could you simplify it. Btw I’m on iOS


SP4CEBAR 2025-10-11 20:00 (Edited)

Thanks for the feedback!
TL;DR An NX program can save data to a file named "Disk.nx". On IOS, your NX programs, including your Disk.nx, are stored on iCloud. iCloud allows collaborating on a file online with others, so I shared a Disk.nx with all of you (two actually, see section "Servers" above). When using this shared Disk.nx instead of your current Disk.nx, your program can "talk" to others that use the same disk. This program is made to play a simple game as turn-based online multiplayer. I expect the program to be easily modify-able for other turn-based online games.


jpospTynker 2025-10-11 20:20

woah now i wanna make a 4 player platformer


jpospTynker 2025-10-11 20:21

imagine r/place or something with this


SP4CEBAR 2025-10-12 06:16 (Edited)

Good luck, feel free to use code from here such as the connection phase. You can test multiplayer by opening an NX program twice on PC to launch two instances, you won't need any cloud for this. The possibilities are endless,


SP4CEBAR 2025-10-12 14:46 (Edited)

Update 7

code comparison

before

Even though it's short, it is hard to read what it does

MULTIPLAYER_TURNS:
  IF TARGET_CLIENT_COUNT > 1 THEN GOSUB RIVAL_TURN
  IF CLIENT_ID = TURN_ID OR TURN_ID = -1 THEN GOSUB YOUR_TURN
RETURN

after

This is much more straightforward

MULTIPLAYER_TURN:
  IS_YOUR_TURN= TURN_ID = CLIENT_ID
  IF IS_YOUR_TURN THEN
    GOSUB YOUR_TURN
  ELSE 
    GOSUB RIVAL_TURN
  END IF
RETURN

We also don't need the IS_YOUR_TURN variable anymore


jpospTynker 2025-10-12 15:07

i will try to make a platformer from this, with the acceleration the only thing online and the positions being stored in the game itself, but i still feel it will be nonstop conflict issues i have to fix :/


SP4CEBAR 2025-10-12 18:30

Good luck, have fun!


cmos 2025-10-14 02:30

too bad i don't have icloud D; (or anything apple for that matter)
i might try to get a google drive disk.nx up,
but no promises!


SP4CEBAR 2025-10-14 11:19 (Edited)

Good luck! note that the "Disk.nx" file has a capital "D", otherwise NX may not be able to find it.

You could also create a new apple account here, it does not require any apple device, but will give you 1GB instead of 5GB of iCloud drive. It also won't give you an "@icloud.com" email account


Log in to reply.