Difference between revisions of "LlSay"

From Second Life Wiki
Jump to navigation Jump to search
 
m (Attempted to clarify that 254-byte limit on negative chat is a viewer limit and doesn't apply to object-to-object chat)
 
(58 intermediate revisions by 22 users not shown)
Line 1: Line 1:
{{LSLFunctionAll|func_id=23|func_sleep=0.0|func_energy=10.0|func=llSay|p1_type=integer|p1_name=channel|p2_type=string|p2_name=msg|func_footnote=says msg on channel}}[[Category:LSL_Functions]][[Category:LSL_Stub]]
{{LSL_Function
|inject-2={{LSL_Function/chat|channel|msg}}
|func_id=23
|func_sleep=0.0
|func_energy=10.0
|func=llSay
|sort=Say
|p1_type=integer|p1_name=channel
|p2_type=string|p2_name=msg
|func_desc=Says the text supplied in string {{LSLP|msg}} on channel supplied in integer {{LSLP|channel}}. The message can be heard 20m away, usually (see caveats)
|return_text
|spec
|constants
|caveats=
*{{LSLP|msg}} can only be heard within 20 meters of the speaking prim (rather than the root). This is contrary to how the event [[listen]] works, where a {{LSLP|msg}} can only be heard by any prim in the object if and only if the root prim is capable of hearing it.
*Some simulators (mostly event sims or linden-owned ones) have <code>[[llGetEnv]]("chat_range")</code> set to a value other than 20. On these sims:
** <code>llSay(0, msg)</code> can be heard in a radius of <code>[[llGetEnv]]("chat_range")</code>
** <code>llSay(any_other_channel, msg)</code> can be heard in a radius of 20m
** as of 2023-03-26, [http://maps.secondlife.com/secondlife/Hippotropolis/67/188/28 Hippotropolis] (a linden meeting sim) has a chat range of 40m
*{{LSLP|msg}} can be a maximum of 1024 bytes. This can convey 1024 ASCII characters, or 512 UTF-8 characters such as <code>á</code>.
*A prim can '''not''' hear itself, this to prevent problems with recursion. It can however hear other prims within the same object.
|examples=
<syntaxhighlight lang="lsl2">
default
{
    state_entry()
    {
        llSay(0, "Hello, Avatar!");
    }
}
</syntaxhighlight>
To avoid making your object spam its neighborhood, use [[llInstantMessage]], [[llOwnerSay]] or [[llRegionSayTo]].
|helpers
|also_events=
{{LSL DefineRow||[[listen]]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|Receives chat}}
|also_functions=
{{LSL DefineRow||[[llListen]]|Ask for listen events}}
{{LSL DefineRow||[[llInstantMessage]]|Sends chat to the owner only (or to some other user only) to avoid spamming the [[PUBLIC_CHANNEL]]}}
{{LSL DefineRow||[[llOwnerSay]]|Sends chat to the owner only to avoid spamming the [[PUBLIC_CHANNEL]]}}
{{LSL DefineRow||[[llRegionSay]]|Sends chat region wide}}
{{LSL DefineRow||[[llRegionSayTo]]|Sends chat region wide to a specific avatar, or their attachments, or to a rezzed object of known UUID}}
{{LSL DefineRow||[[llShout]]|Sends chat limited to 100 meters}}
{{LSL DefineRow||[[llWhisper]]|Sends chat limited to 10 meters}}
|also_tests
|also_articles=
{{LSL DefineRow||[[Hello Avatar]]}}
|notes=
* Channel {{HoverText|0|Zero}} is the [[PUBLIC_CHANNEL]]. Everyone can hear chat transmitted on this channel. All other channels are private channels (not sent to users, with the exception of [[DEBUG_CHANNEL]]).
* Consider using [[llInstantMessage]], [[llOwnerSay]], or the [[DEBUG_CHANNEL]] for debugging purposes. If [[DEBUG_CHANNEL]] is used as {{LSLP|channel}}, the script will say {{LSLP|msg}} to the Script Warning/Error window.
** Note, however, that when using [[DEBUG_CHANNEL]], what ''you'' consider to be 'debugging messages' will still be seen by others as ''scripting errors'' indicated by the floating 'script error' icon.
* If one object 'says' something to another object (''e.g.'', a button that, when touched, turns on a lamp), it is a good idea to use a very negative channel, ''e.g.'', <code>-5243212</code> but don't just use any number take a look at the [[User-Defined Protocols & APIs]] and choose one that won't interfere with other protocols. If you are going to sell your script widely, please add it to the appropriate [[LSL_Protocol#Known_negative_chat_channels|known chat channels list]] so others won't interfere with your product (do keep in mind you should build your product so that it handles interference appropriately).
<syntaxhighlight lang="lsl2">
    llSay(-5243212,"turn on");
</syntaxhighlight>
:From at least September 2016 (see [[Release Notes/Second Life Release/4.0.9.320038]]), viewers have been able to chat on negative channels, although chat from viewers is [https://jira.secondlife.com/browse/BUG-41541 limited to 254 characters]. (Chat from objects caps at 1024 bytes, whether the channel is negative or not). Negative channels were popular for script communications because the standard SL client was unable to chat directly on those channels (<code>/-xxxx message</code> would not chat <code>message</code> on channel <code>-xxxx</code>). The only way for a viewer to generate chat on negative channels prior to [[llTextBox]] was to use [[llDialog]] which was limited to 24 bytes.
* Be aware that if you mistakenly use an integer bigger than the maximum or smaller than the minimum, SL will treat the literal number as a {{LSLP|float}} and convert it implicitly to an out-of-range integer, resulting in <code>1</code>, ''without'' giving a script/syntax error (since this implicit conversion is legitimate). This means that all scripts listening to an out-of-range integer will be listening to channel 1 instead! (see also [[llListen]]).
|cat1
|cat2
|haiku={{Haiku|Oh say, can you see?|Can you see what I say if|You're not far away?}}
|cat3
|cat4
}}

Latest revision as of 14:41, 30 August 2023

Summary

Function: llSay( integer channel, string msg );
0.0 Forced Delay
10.0 Energy

Says the text supplied in string msg on channel supplied in integer channel. The message can be heard 20m away, usually (see caveats)

• integer channel output chat channel, any integer value
• string msg message to be transmitted
Channel Constant Description
DEBUG_CHANNEL 0x7FFFFFFF Chat channel reserved for script debugging and error messages, broadcasts to all nearby users.
PUBLIC_CHANNEL 0x0 Chat channel that broadcasts to all nearby users. This channel is sometimes referred to as: open chat, local chat and public chat.

Caveats

  • Messages sent on channel zero[1] and DEBUG_CHANNEL are throttled to a rate of <200/10sec, per region, per owner/user.
    • Once the rate is exceeded, all following messages on channel zero or DEBUG_CHANNEL will be dropped until the send rate is again below 200/10sec for the previous 10 sec. Dropped messages, despite being dropped still count against the limit.
  • msg can only be heard within 20 meters of the speaking prim (rather than the root). This is contrary to how the event listen works, where a msg can only be heard by any prim in the object if and only if the root prim is capable of hearing it.
  • Some simulators (mostly event sims or linden-owned ones) have llGetEnv("chat_range") set to a value other than 20. On these sims:
    • llSay(0, msg) can be heard in a radius of llGetEnv("chat_range")
    • llSay(any_other_channel, msg) can be heard in a radius of 20m
    • as of 2023-03-26, Hippotropolis (a linden meeting sim) has a chat range of 40m
  • msg can be a maximum of 1024 bytes. This can convey 1024 ASCII characters, or 512 UTF-8 characters such as á.
  • A prim can not hear itself, this to prevent problems with recursion. It can however hear other prims within the same object.

Examples

default
{
    state_entry()
    {
        llSay(0, "Hello, Avatar!");
    }
}
To avoid making your object spam its neighborhood, use llInstantMessage, llOwnerSay or llRegionSayTo.

Notes

  • Channel 0 is the PUBLIC_CHANNEL. Everyone can hear chat transmitted on this channel. All other channels are private channels (not sent to users, with the exception of DEBUG_CHANNEL).
  • Consider using llInstantMessage, llOwnerSay, or the DEBUG_CHANNEL for debugging purposes. If DEBUG_CHANNEL is used as channel, the script will say msg to the Script Warning/Error window.
    • Note, however, that when using DEBUG_CHANNEL, what you consider to be 'debugging messages' will still be seen by others as scripting errors indicated by the floating 'script error' icon.
  • If one object 'says' something to another object (e.g., a button that, when touched, turns on a lamp), it is a good idea to use a very negative channel, e.g., -5243212 but don't just use any number take a look at the User-Defined Protocols & APIs and choose one that won't interfere with other protocols. If you are going to sell your script widely, please add it to the appropriate known chat channels list so others won't interfere with your product (do keep in mind you should build your product so that it handles interference appropriately).
    llSay(-5243212,"turn on");
From at least September 2016 (see Release Notes/Second Life Release/4.0.9.320038), viewers have been able to chat on negative channels, although chat from viewers is limited to 254 characters. (Chat from objects caps at 1024 bytes, whether the channel is negative or not). Negative channels were popular for script communications because the standard SL client was unable to chat directly on those channels (/-xxxx message would not chat message on channel -xxxx). The only way for a viewer to generate chat on negative channels prior to llTextBox was to use llDialog which was limited to 24 bytes.
  • Be aware that if you mistakenly use an integer bigger than the maximum or smaller than the minimum, SL will treat the literal number as a float and convert it implicitly to an out-of-range integer, resulting in 1, without giving a script/syntax error (since this implicit conversion is legitimate). This means that all scripts listening to an out-of-range integer will be listening to channel 1 instead! (see also llListen).

See Also

Events

•  listen                 Receives chat

Functions

•  llListen Ask for listen events
•  llInstantMessage Sends chat to the owner only (or to some other user only) to avoid spamming the PUBLIC_CHANNEL
•  llOwnerSay Sends chat to the owner only to avoid spamming the PUBLIC_CHANNEL
•  llRegionSay Sends chat region wide
•  llRegionSayTo Sends chat region wide to a specific avatar, or their attachments, or to a rezzed object of known UUID
•  llShout Sends chat limited to 100 meters
•  llWhisper Sends chat limited to 10 meters

Articles

•  Hello Avatar

Deep Notes

Footnotes

  1. ^ Channel zero is also known as: PUBLIC_CHANNEL, open chat, local chat and public chat

Signature

function void llSay( integer channel, string msg );

Haiku

Oh say, can you see?
Can you see what I say if
You're not far away?