Data types that can be saved to ClusterScript.state or sent using ItemHandle.send.

Specifically, values below are Sendable:

Notably, Sendable does not include undefined.

Conversion from non-Sendable to Sendable

If a non-Sendable value, such as undefined, is passed to APIs that require a Sendable value, it will be handled according to the following rules.

  • If a non-Sendable value such as undefined is passed directly, it will either throw an error or be ignored depending on the API.
  • If an array containing non-Sendable values such as undefined is passed, it will be treated as Sendable by converting the non-Sendable values to null.
  • If an object containing non-Sendable values such as undefined is passed, it will be treated as Sendable by deleting the corresponding key-values.

If these behaviors occur, a warning message will be logged to the script console. These behaviours are planned to throw errors instead in future updates.

Conversion from Sendable to PlayerScriptSendable

When Sendable is sent to PlayerScript, values that cannot be treated as PlayerScriptSendable are converted to PlayerScriptSendable based on the following rules.

  • PlayerHandle becomes PlayerId that represents the same player.
  • ItemHandle becomes ItemId that represents the same item.
  • Contents of arrays and objects are converted in the same manner.

Example

$.state.exampleKey1 = 1; // Write a number
$.state.exampleKey2 = "hello"; // Write a string
$.state.exampleKey3 = true; // Write a boolean
$.state.exampleKey4 = { foo: "bar" }; // Write an object
$.state.exampleKey5 = [1, 2, 3]; // Write an array
$.state.exampleKey6 = { // Write a complex object
array: [1, 2, 3],
object: { foo: "bar" },
};

Example

itemHandle.send("message1", 10); // Send a number
itemHandle.send("message2", "hello"); // Send a string
itemHandle.send("message3", true); // Send a boolean
itemHandle.send("message4", { foo: "bar" }); // Send an object
itemHandle.send("message5", [1, 2, 3]); // Send an array
itemHandle.send("message6", { // Send a complex object
array: [1, 2, 3],
object: { foo: "bar" },
});

Generated using TypeDoc