Item$.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" },
};
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" },
});
Data types that can be saved to ClusterScript.state or sent using ItemHandle.send.
Specifically, values below are Sendable:
nullNotably, 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.undefinedis passed directly, it will either throw an error or be ignored depending on the API.undefinedis passed, it will be treated as Sendable by converting the non-Sendable values tonull.undefinedis 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.