Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Passing NoteCard in Linked Set

Robins Hermano
Registered User
Join date: 20 Oct 2006
Posts: 18
08-14-2007 17:40
For those more knowledgeable then I, I ask for help.

I have a linked object. One of the objects is supposed to allow a notecard to be dropped on it, but because it is not the root prim, the notecard when dropped goes to the root prim inventory. OK, I dug around the forum and thought I found a solution, use llGiveInventory when a change event (INVENTORY_NOTECARD) is triggered and send that notecard to the prim with the script to read it. I wrote the script and it works, BUT....

because it's a linked object (I guess) as soon as the child prim receives the notecard the script in the root prim with the Changed event fires and I'm in an infinite loop with the root prim giving the notecard to the child prim, creating a changed event in the root prim, and on and on. Here is the script I wrote, maybe there is something wrong with that or maybe someone has another solution (other having the root prim read the notecard, which I just thought of, but I'd rather keep that function separate in the child prim, accessible by Touch).

changed (integer change) {
if (change & CHANGED_INVENTORY) {
integer numbernotes = llGetInventoryNumber(INVENTORY_NOTECARD);
llGiveInventory("e7a2656f-30c6-5b66-dd69-fa1c9c0c10bb", llGetInventoryName(INVENTORY_NOTECARD, numbernotes - 1));
llWhisper(0, "Sending notecard for processing";);
}
}

Now that I look at this perhaps there is something I can do with the change integer in my if statement.... hmmmm

Thanks for any help you might be able to shed on this problem

Robins Hermano
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
08-14-2007 18:17
Dunno if it's the best solution, but in this case you can avoid sending the same notecard twice in a row:

integer gLastNotecardKey; // new integer in the global scope

~~~

changed (integer change) {
if (change & CHANGED_INVENTORY) {
integer numbernotes = llGetInventoryNumber(INVENTORY_NOTECARD);
string inventoryName = llGetInventoryName(INVENTORY_NOTECARD, numbernotes - 1);
key inventoryKey = llGetInventoryKey(inventoryName);
if(inventoryKey != gLastNotecardKey)
{
llGiveInventory("e7a2656f-30c6-5b66-dd69-fa1c9c0c10bb", llGetInventoryName(INVENTORY_NOTECARD, numbernotes - 1));
llWhisper(0, "Sending notecard for processing";);
gLastNotecardKey = inventoryKey;
}
}
}
Robins Hermano
Registered User
Join date: 20 Oct 2006
Posts: 18
Notecard
08-15-2007 10:59
Thanks Day Oh, I'll give that a try.

Robins.
Simil Miles
Creator
Join date: 1 Mar 2007
Posts: 300
08-16-2007 05:31
I hated that infinite loop thing, the wiki was telling wrong and i lost a lot of time.

Here's my fix :

CODE

integer inventory_number;

myInventoryNum(integer type)
{
inventory_number = llGetInventoryNumber(type);
}

default
{
state_entry()
{
inventory_number = llGetInventoryNumber(INVENTORY_SCRIPT);
}

changed(integer change)
{
if (change & CHANGED_INVENTORY && llGetInventoryNumber(INVENTORY_SCRIPT) != inventory_number) // prevent infinite loop
{
myInventoryNum(INVENTORY_SCRIPT);
}
}
}
CODE
_____________________
UnConWTech @ Flo (144, 84, 224) http://unconwtech.free.fr

SL books http://astore.amazon.com/secondlife-sl-20/

Need a beta tester for quality assurance ?
Need a translator for English, French, Spanish ?
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
08-16-2007 10:13
Why move the notecard at all? Just read the notecard via UUID. The root doesn't need to send the notecard, just send a linkmessage with the notecard UUID. llGetInventoryKey is your friend here :)
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
08-16-2007 10:58
Oh snap!! Strife, do you know how awesome that is??