Type alias PlayerScriptSendablePlayer

PlayerScriptSendable: ExtJSON<PlayerScriptSendablePrims>

Data types that can be sent using PlayerScript.sendTo.

Specifically, values below are PlayerScriptSendable:

Notably, PlayerScriptSendable does not include undefined.

Conversion from non-PlayerScriptSendable to PlayerScriptSendable

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

  • If a non-PlayerScriptSendable 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-PlayerScriptSendable values such as undefined is passed, it will be treated as PlayerScriptSendable by converting the non-PlayerScriptSendable values to null.
  • If an object containing non-PlayerScriptSendable values such as undefined is passed, it will be treated as PlayerScriptSendable 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 PlayerScriptSendable is sent to ItemScript, values that cannot be treated as Sendable are converted to Sendable based on the following rules.

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

Example

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

Generated using TypeDoc