Difference between revisions of "LlMessageLinked/it"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "{{LSL_Function |inject-2={{LSL Function/link|linknum|, controls which prim(s) receive the link_message.}} |func_id=164|func_sleep=0.0|func_energy=10.0 |func=llMessageLinked|sort=…")
 
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function/it
|inject-2={{LSL Function/link|linknum|, controls which prim(s) receive the link_message.}}
|inject-2={{LSL Function/link|linknum|, controlla quale/i prim riceve/ono il link_message.}}
|func_id=164|func_sleep=0.0|func_energy=10.0
|func_id=164|func_sleep=0.0|func_energy=10.0
|func=llMessageLinked|sort=MessageLinked
|func=llMessageLinked|sort=MessageLinked
|p1_type=integer|p1_name=linknum|p1_desc
|p1_type=integer|p1_name=linknum|p1_desc
|p2_type=integer|p2_name=num|p2_desc=Value of the second parameter of the resulting link_message event.
|p2_type=integer|p2_name=num|p2_desc=Valore del secondo parametro dell'evento link_message risultante.
|p3_type=string|p3_name=str|p3_desc=Value of the third parameter of the resulting link_message event.
|p3_type=string|p3_name=str|p3_desc=Valore del terzo parametro dell'evento link_message risultante.
|p4_type=key|p4_name=id|p4_desc=Value of the fourth parameter of the resulting link_message event.
|p4_type=key|p4_name=id|p4_desc=Valore del quarto parametro dell'evento link_message risultante.
|func_desc=The purpose of this function is to allow scripts in the same object to communicate. It triggers a [[link_message]] event with the same parameters '''num''', '''str''', and '''id''' in all scripts in the prim(s) described by '''linknum'''.  
|func_desc=Lo scopo di questa funzione è di permettere la comunicazione tra gli script in uno stesso oggetto. Fà scattare un evento [[link_message]] con i medesimi parametri '''num''', '''str''', e '''id''' in tutti gli script nel/i prim definito/i da '''linknum'''.
|func_footer=You can use '''id''' as a second string field{{Footnote|In LSL the [[key]] type is implemented as a [[string]] (but with different operators and restrictions). [[typecast|Typecasting]] between string and key types has no effect on the data contained.}}. The sizes of '''str''' and '''id''' are only limited by available script memory.
|func_footer=Potete utilizzare '''id''' come campo stringa secondario{{Footnote|In LSL il tipo [[key]] è implementato come una [[string]] (ma con operatori e restrizioni differenti). [[typecast|La conversione]] tra tipi stringa e chiave non ha effetto sui dati contenuti.}}. Le dimensioni di '''str''' e '''id''' sono limitate solamente dalla memoria script disponibile.
|constants
|constants
|func_footnote
|func_footnote
|return_text
|return_text
|spec
|spec
|caveats=*A script can hear its own linked messages if '''linknum''' targets the prim it is in{{Footnote|There are four ways for a script to target itself: by [[llGetLinkNumber|precise link number]], [[LINK_THIS]], [[LINK_SET]] and [[LINK_ALL_CHILDREN]] (if the prim is a child prim).}}. This creates the possibility of an infinite loop (a bad thing); be very careful about how messages are handled and passed along.
|caveats=*Uno script può ascoltare i suoi stessi link_messages se '''linknum''' ha come obiettivo il prim in cui è lo script{{Footnote|Uno script ha quattro modi per avere sé stesso come obiettivo: [[llGetLinkNumber|precise link number]], [[LINK_THIS]], [[LINK_SET]] e [[LINK_ALL_CHILDREN]] (se il prim è un prim collegato).}}. Ciò crea la possibilità di un circolo vizioso infinito (cosa cattiva); state molto attenti a come i messaggi vengono gestiti e passati.
* Messages sent via llMessageLinked to a script that is [[llSleep|sleeping]], [[LSL Delay|delayed]], or [[lag|lagged]], are queued until the end of the delay. The event queue can hold 64 events.
* I messaggi inviati tramite llMessageLinked a uno script che è in [[llSleep|sonno]], [[LSL Delay|è rinviato]], o [[lag|laggato]], sono messi in coda fino al termine del rinvio. La coda eventi può contenere 64 eventi.
** If an event is received and the queue is full the event is silently dropped.
** Se la coda è piena e si riceve un evento, questo viene scartato in modo silenzioso.
** Avoid sending link_messages to large numbers of scripts simultaneously as it can cause lag spike. This most often happens when using the multi-prim LINK_* flags and can cause script execution to slow or halts.
** Evitate di inviare simultaneamente link_messages a grandi quantità di script poiché ciò può causare picchi di lag. Questo generalmente accade mentre si usano i flag multi-prim LINK_* e può causare l'esecuzione lenta dello script o portare ad arresti.
** Avoid sending link_messages to a target faster than they can be handled. Doing so risks filling the event queue and subsequent messages being silently discarded.
** Evitate di inviare link_messages a un obiettivo più velocemente di quanto questi possano essere gestiti. Farlo significa rischiare di riempire la coda eventi e di portare allo scarto silenzioso dei messaggi seguenti.
* When a script [[state]] changes, all pending events are deleted, including queued link_messages.
* Quando cambia lo [[state]] di uno script, tutti gli eventi in coda vengono cancellati, compresi i link_messages accodati.
* If '''link_num''' is an invalid link number then the function silently fails.
* Se '''link_num''' è un numero non valido allora la funzione fallisce in modo silenzioso.
* If '''str''' & '''id''' exceed the available memory of a script that catches the resulting link_message event, that script will crash with a [[LSL_Errors#Script_run-time_error:_Stack-Heap_Collision|Stack-Heap Collision]].
* Se '''str''' e '''id''' eccedono la memoria disponibile di uno script che prende l'evento link_message risultante, quello script crasherà con una [[LSL_Errors#Script_run-time_error:_Stack-Heap_Collision|Collisione Stack-Heap]].
|examples=<lsl>default
|examples=<lsl>default
{  
{  
     // assumptions // object name: LSLWiki // script name: _lslwiki
     // presupposti // nome oggetto: LSLWiki // nome script: _lslwiki
     state_entry()  
     state_entry()  
     {
     {
Line 32: Line 32:
     {
     {
         llOwnerSay(msg);
         llOwnerSay(msg);
         // the owner of object LSLWiki will hear
         // il proprietario dell'oggetto sentirà
         // LSLWiki:_lslwiki
         // LSLWiki:_lslwiki
     }     
     }     
}</lsl>
}</lsl>


=== Infinite Loop ===
=== Circolo infinito ===


<lsl>Message_Control(integer l, integer n) // Message_Total_Lack_Of_Control
<lsl>Controllo_Messaggio(integer l, integer n) // Mancanza_Assoluta_di_Controllo_del_Messaggio
{
{
     integer r = (++n); // Increment the value of n.
     integer r = (++n); // Aumenta il valore di n.
     llMessageLinked( l, r, "", ""); // Send the result to l
     llMessageLinked( l, r, "", ""); // Invia il risultato a l
}
}


Line 49: Line 49:
     state_entry()
     state_entry()
     {
     {
         Message_Control(LINK_SET, 0); // Tell all the scripts in the object that we have state_entered.
         Controllo_Messaggio(LINK_SET, 0); // Comunica a tutti gli script nell'oggetto che siamo entrati nello stato.
     }
     }
     link_message(integer Sender, integer Number, string String, key Key) // This script is in the object too.
 
     link_message(integer Mittente, integer Numero, string Stringa, key Chiave) // Anche questo script è nell'oggetto.
     {
     {
         Message_Control(Sender, Number); // No filtering condition exists.
         Controllo_Messaggio(Mittente, Numero); // Non esistono condizioni filtranti.
         llOwnerSay(((string)Number)); // Look at all the pretty numbers!
         llOwnerSay(((string)Numero)); // Guardate tutti quei bei numeri!
     }
     }
}</lsl>
}</lsl>
|helpers=<lsl>default
|helpers=<lsl>default
{  
{  
     // Quick and dirty debugging link_messages
     // Correzione veloce e sporca dei link_messages
     link_message(integer sender_num, integer num, string msg, key id)  
     link_message(integer sender_num, integer num, string msg, key id)  
     {
     {
Line 65: Line 66:
     }
     }
}</lsl>
}</lsl>
<lsl>// This is just an example script, you shouldn't handle link message within single script this way.
<lsl>// Questo è solo uno script di esempio, non dovreste gestire i messaggi collegati all'interno del medesimo script in questo modo.


default
default
{  
{  
     // To propagate an unlimted number of arguments of any type.
     // Per diffondere un numero illimitato di argomenti di qualsiasi tipo.
     // Presumed, the separator string isn't used in any source string!
     // Presupposto, la stringa separatrice non viene utilizzata in nessuna stringa sorgente!
     state_entry()  
     state_entry()  
     {
     {
         list my_list = [1, 2.0, "a string", <1, 2, 3>, <1, 2, 3, 4>, llGetOwner()];   
         list mia_lista = [1, 2.0, "una stringa", <1, 2, 3>, <1, 2, 3, 4>, llGetOwner()];   
         string list_parameter = llDumpList2String(my_list, "|"); // Convert the list to a string
         string parametro_lista = llDumpList2String(mia_lista, "|"); // Converte la lista in una stringa
         llMessageLinked(LINK_THIS, 0, list_parameter, "")
         llMessageLinked(LINK_THIS, 0, parametro_lista, "")
     }
     }


     link_message(integer sender_num, integer num, string list_argument, key id)  
     link_message(integer sender_num, integer num, string list_argument, key id)  
     {
     {
         list re_list = llParseString2List(list_argument, ["|"], []); // Parse the string back to a list
         list ri_elenca = llParseString2List(parametro_lista, ["|"], []); // elabora nuovamente la stringa in una lista
     }
     }
}</lsl>
}</lsl>
|also_header
|also_header
|also_events={{LSL DefineRow||[[link_message]]|}}
|also_events={{LSL DefineRow||[[link_message/it]]|}}
|also_functions
|also_functions
|also_articles
|also_articles
|also_footer
|also_footer
|notes=*Using llMessageLinked in a single prim object allows developers to mitigate some LSL limits by breaking up functionality between cooperating scripts and synchronizing actions. When you do this, be extremely careful not to create infinite loops as mentioned above.
|notes=*Utilizzare llMessageLinked in un unico oggetto permette agli sviluppatori di alleviare alcuni limiti del LSL spartendo le funzionalità tra script cooperanti e sincronizzando le azioni. Quando lo fate, siate estremamente attenti a non creare circoli infiniti come descritto prima.
*Estimated .25-.50 delay between receiving and sending of llLinkedMessage has been observed by some users
*Alcuni utenti hanno osservato un ritardo di .25-.50 tra la ricezione e l'invio di llLinkedMessage
*Some users have noted occasional failures of linked messages when sending a message to a large number of receiving scripts in different prims using [[LINK_SET]], [[LINK_ALL_OTHERS]], & [[LINK_ALL_CHILDREN]]. If you encounter this problem, a workaround is to place all child prim scripts in a single prim, using targeted functions like [[llSetLinkPrimitiveParams]] to modify the prim in which the script previously resided. -- [[User:Void Singer|Void Singer]]
*Alcuni utenti hanno notato fallimenti sporadici di messaggi collegati quando si invia un messaggio a grandi quantità di script riceventi in prim differenti usando [[LINK_SET]], [[LINK_ALL_OTHERS]], e [[LINK_ALL_CHILDREN]]. Se incontrate questo problema, un trucco è mettere tutti gli script dei prim collegati in un singolo prim, e usare funzioni mirate come [[llSetLinkPrimitiveParams]] per modificare il prim in cui lo script stava precedentemente. -- [[User:Void Singer|Void Singer]]
|cat1=Communications
|cat1=Communications
|cat2=Link
|cat2=Link

Latest revision as of 10:43, 15 January 2012

Sommario

Function: llMessageLinked( integer linknum, integer num, string str, key id );
164 ID funzione
0.0 Ritardo
10.0 Energia

Lo scopo di questa funzione è di permettere la comunicazione tra gli script in uno stesso oggetto. Fà scattare un evento link_message con i medesimi parametri num, str, e id in tutti gli script nel/i prim definito/i da linknum.

• integer linknum Link number (0: unlinked, 1: root prim, >1: child prims and seated avatars) or a LINK_* flag, controlla quale/i prim riceve/ono il link_message.
• integer num Valore del secondo parametro dell'evento link_message risultante.
• string str Valore del terzo parametro dell'evento link_message risultante.
• key id Valore del quarto parametro dell'evento link_message risultante.

Potete utilizzare id come campo stringa secondario[2]. Le dimensioni di str e id sono limitate solamente dalla memoria script disponibile.
Flag Description
LINK_ROOT 1 refers to the root prim in a multi-prim linked set[1]
LINK_SET -1 refers to all prims
LINK_ALL_OTHERS -2 refers to all other prims
Flag Description
LINK_ALL_CHILDREN -3 refers to all children, (everything but the root)
LINK_THIS -4 refers to the prim the script is in

Avvertimenti

  • Uno script può ascoltare i suoi stessi link_messages se linknum ha come obiettivo il prim in cui è lo script[3]. Ciò crea la possibilità di un circolo vizioso infinito (cosa cattiva); state molto attenti a come i messaggi vengono gestiti e passati.
  • I messaggi inviati tramite llMessageLinked a uno script che è in sonno, è rinviato, o laggato, sono messi in coda fino al termine del rinvio. La coda eventi può contenere 64 eventi.
    • Se la coda è piena e si riceve un evento, questo viene scartato in modo silenzioso.
    • Evitate di inviare simultaneamente link_messages a grandi quantità di script poiché ciò può causare picchi di lag. Questo generalmente accade mentre si usano i flag multi-prim LINK_* e può causare l'esecuzione lenta dello script o portare ad arresti.
    • Evitate di inviare link_messages a un obiettivo più velocemente di quanto questi possano essere gestiti. Farlo significa rischiare di riempire la coda eventi e di portare allo scarto silenzioso dei messaggi seguenti.
  • Quando cambia lo state di uno script, tutti gli eventi in coda vengono cancellati, compresi i link_messages accodati.
  • Se link_num è un numero non valido allora la funzione fallisce in modo silenzioso.
  • Se str e id eccedono la memoria disponibile di uno script che prende l'evento link_message risultante, quello script crasherà con una Collisione Stack-Heap.
All Issues ~ Search JIRA for related Bugs

Esempi

<lsl>default {

   // presupposti  // nome oggetto: LSLWiki // nome script: _lslwiki
   state_entry() 
   {
       llMessageLinked(LINK_THIS, 0, llGetScriptName(), "");
   }
   link_message(integer sender_num, integer num, string msg, key id) 
   {
       llOwnerSay(msg);
       // il proprietario dell'oggetto sentirà
       // LSLWiki:_lslwiki
   }    

}</lsl>

Circolo infinito

<lsl>Controllo_Messaggio(integer l, integer n) // Mancanza_Assoluta_di_Controllo_del_Messaggio {

   integer r = (++n); // Aumenta il valore di n.
   llMessageLinked( l, r, "", ""); // Invia il risultato a l

}

default {

   state_entry()
   {
       Controllo_Messaggio(LINK_SET, 0); // Comunica a tutti gli script nell'oggetto che siamo entrati nello stato.
   }
   link_message(integer Mittente, integer Numero, string Stringa, key Chiave) // Anche questo script è nell'oggetto.
   {
       Controllo_Messaggio(Mittente, Numero); // Non esistono condizioni filtranti.
       llOwnerSay(((string)Numero)); // Guardate tutti quei bei numeri!
   }
}</lsl>

Ritagli di codice utili

<lsl>default {

   // Correzione veloce e sporca dei link_messages
   link_message(integer sender_num, integer num, string msg, key id) 
   {
       llSay(DEBUG_CHANNEL, llList2CSV([sender_num, num, msg, id]));
   }

}</lsl> <lsl>// Questo è solo uno script di esempio, non dovreste gestire i messaggi collegati all'interno del medesimo script in questo modo.

default {

   // Per diffondere un numero illimitato di argomenti di qualsiasi tipo.
   // Presupposto, la stringa separatrice non viene utilizzata in nessuna stringa sorgente!
   state_entry() 
   {
       list mia_lista = [1, 2.0, "una stringa", <1, 2, 3>, <1, 2, 3, 4>, llGetOwner()];  
       string parametro_lista = llDumpList2String(mia_lista, "

Note

Link Numbers

Each prim that makes up an object has an address, a link number. To access a specific prim in the object, the prim's link number must be known. In addition to prims having link numbers, avatars seated upon the object do as well.

  • If an object consists of only one prim, and there are no avatars seated upon it, the (root) prim's link number is zero.
  • However, if the object is made up of multiple prims or there is an avatar seated upon the object, the root prim's link number is one.

When an avatar sits on an object, it is added to the end of the link set and will have the largest link number. In addition to this, while an avatar is seated upon an object, the object is unable to link or unlink prims without unseating all avatars first.

Counting Prims & Avatars

There are two functions of interest when trying to find the number of prims and avatars on an object.

integer GetPrimCount() { //always returns only the number of prims
    if(llGetAttached())//Is it attached?
        return llGetNumberOfPrims();//returns avatars and prims but attachments can't be sat on.
    return llGetObjectPrimCount(llGetKey());//returns only prims but won't work on attachments.
}
See llGetNumberOfPrims for more about counting prims and avatars.

Errata

If a script located in a child prim erroneously attempts to access link 0, it will get or set the property of the linkset's root prim. This bug (BUG-5049) is preserved for broken legacy scripts.

  • Utilizzare llMessageLinked in un unico oggetto permette agli sviluppatori di alleviare alcuni limiti del LSL spartendo le funzionalità tra script cooperanti e sincronizzando le azioni. Quando lo fate, siate estremamente attenti a non creare circoli infiniti come descritto prima.
  • Alcuni utenti hanno osservato un ritardo di .25-.50 tra la ricezione e l'invio di llLinkedMessage
  • Alcuni utenti hanno notato fallimenti sporadici di messaggi collegati quando si invia un messaggio a grandi quantità di script riceventi in prim differenti usando LINK_SET, LINK_ALL_OTHERS, e LINK_ALL_CHILDREN. Se incontrate questo problema, un trucco è mettere tutti gli script dei prim collegati in un singolo prim, e usare funzioni mirate come llSetLinkPrimitiveParams per modificare il prim in cui lo script stava precedentemente. -- Void Singer

Si veda anche

Eventi

•  link_message/it

Funzioni

•  llGetLinkNumber Returns the link number of the prim the script is in.

Note approfondite

Search JIRA for related Issues

Note a pié pagina

  1. ^ LINK_ROOT does not work on single prim objects. Unless there is an avatar sitting on the object.
  2. ^ In LSL il tipo key è implementato come una string (ma con operatori e restrizioni differenti). La conversione tra tipi stringa e chiave non ha effetto sui dati contenuti.
  3. ^ Uno script ha quattro modi per avere sé stesso come obiettivo: precise link number, LINK_THIS, LINK_SET e LINK_ALL_CHILDREN (se il prim è un prim collegato).

Firma

function void llMessageLinked( integer linknum, integer num, string str, key id );