- Home
- Script API
- Sansar.Simulation
- Classes
- SimpleScript.OnChatOptionsAttribute
Script API
SimpleScript.OnChatOptionsAttribute
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.SimpleScriptOptionsAttributeRemarks
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
| Kind | Members |
|---|---|
| Constructors | OnChatOptionsAttribute |
| Properties | Channel · Source |
Constructors
OnChatOptionsAttribute
public SimpleScript.OnChatOptionsAttribute()Set options for OnChat events
Properties
Channel
[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
[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.