Skip to content

Get Sansar

Script API

SimpleScript.OnChatOptionsAttribute

Where: Client
More page actions

For the complete documentation index, see llms.txt. This page is also available as Markdown.

Set options for OnChat() overrides, or use to create more simple chat handlers.

[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=true)]
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
protected class SimpleScript.OnChatOptionsAttribute : SimpleScript.SimpleScriptOptionsAttribute

Remarks

This attribute is optional when overriding OnChat which by default will respond to all chat on the default channel (Chat.DefaultChannel) and all sources.

Add this attribute to any method that matches Action<ChatData> to create extra chat event subscriptions.

[OnChatOptions(Channel=5)]
void ChatFrom5(ChatData data)
{
// chat from channel 5.
}
void OnChat(ChatData data)
{
// chat from the default channel (0)
}

Example

// Only listen for chat on Channel 10 from scripts.
[OnChatOptions(Channel=10, Source="script")]
protected override OnChat(ChatData data)

Members at a glance

KindMembers
ConstructorsOnChatOptionsAttribute
PropertiesChannel · Source

Constructors

OnChatOptionsAttribute

public SimpleScript.OnChatOptionsAttribute()

Set options for OnChat events

Properties

Channel

Deprecated
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)] public int Channel { get; set; }

Specify a specific channel to listen for messages on.

Value: int — The channel to listen for chat on.

Remarks

By default listens for chat on Chat.DefaultChannel (0).

Example
// Only listen for chat on Channel 10.
[OnChatOptions(Channel=10)]
protected override OnChat(ChatData data)

Source

Deprecated
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)] public string Source { get; set; }

string source of the chat: system, user or script.

Value: string — The source chat to listen for: “script”, “user” or “system”

Remarks

Restricts which chat messages will trigger OnChat. [OnChatOptions(Source=“user”)] will only run OnChat for chat from users, while “script” will respond to other script messages, and “system” will only respond to system messages.

Generated from the Sansar 47.10.0 client ScriptApi snapshot.