Module 13 · In Studio · challenge 3 of 3 in this lesson

diff sends only changes, with dotted paths, remove ops without a value, copied values and sorted output

A test in Studio grades it and prints a pass code.

Open

Level 3, Professional

Challenge

Write diff, apply and newStore in challenges/work/player_state.luau. The written solution is challenges/solutions/state-and-replication.md. In Play, run game.ServerScriptService.RunGameTests:Invoke("state-and-replication", "state-diff-store") and paste the pass code here.

Start from
The game at milestone m14 (download)
Grade it
In Studio, press Play, then run game.ServerScriptService.RunGameTests:Invoke("state-and-replication", "state-diff-store") in the server command bar. Copy the pass code from Output.

Done means

  • diff sends only changes, with dotted paths, remove ops without a value, copied values and sorted output
  • apply(old, diff(old, new)) equals new, including tables replaced by numbers and the other way round
  • The store applies a newer snapshot, then only the next seq; older is stale, a skipped seq or a diff before any snapshot is a gap, and neither changes anything
  • subscribe calls a listener only when its key changed and stops after unsubscribing
  • challenges/state-and-replication.luau prints TEST PASS for every check

The Course Runner prints this code when the test passes.