If I have prims that are linked and the notecard with a list is in the parent prim, can I have a script that reads from that notecard in a child prim?
Or does the script and notecard HAVE to be in the same prim?
Thanks,
Thorne
These forums are CLOSED. Please visit the new forums HERE
Reading notecards in another prim? |
|
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
04-06-2006 07:43
If I have prims that are linked and the notecard with a list is in the parent prim, can I have a script that reads from that notecard in a child prim?
Or does the script and notecard HAVE to be in the same prim? Thanks, Thorne |
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
04-06-2006 08:32
I don't *think* you can interact at all with the inventory in a different prim.
However, you could certainly have a notecard-reading script in one prim which responded to link messages from another prim, and sent back the line read using link messages as well. |
|
Barbarra Blair
Short Person
Join date: 18 Apr 2004
Posts: 588
|
04-06-2006 09:11
Haven't tried it, but I'm guessing you could have the parent prim send the notecard's UUID to the child prim.
_____________________
--Obvious Lady
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
04-06-2006 09:27
Mm, I don't think llGetNotecardLine allows reference by key, but worth a try - it would be very useful if it did.
Anyway, here's the sort of thing I meant earlier... CODE // Put this in the prim without the notecard and CODE // Put this in the prim with the notecard in it If you have two linked prims and put the first script in the root, and the second script in a child with a notecard called "Notecard" in it, then touching it will read out the lines of the notecard in sequence. Or should do anyway, not tested. |
|
Champie Jack
Registered User
Join date: 6 Dec 2003
Posts: 1,156
|
please check the LSL wiki before guessing...
04-06-2006 09:36
the following is taken from the LSL wiki page for llGetNotecardLine
key llGetNotecardLine(string name, integer line) This function fetches line number of notecard name and returns the data through the dataserver event. The line count starts at zero. If the requested line is past the end of the notecard, the dataserver event will return the constant EOF ("End Of File" string. You can get the number of lines in a notecard with llGetNumberOfNotecardLines. The key returned by llGetNotecardLine is a unique identifier which will be supplied to the dataserver event as the queryid parameter.name can be either a string containing the name of a notecard in the object's inventory, or a key pointing to a notecard (that can be anywhere and doesn't have to reside in the object). In the latter case. you should keep in mind that any time you edit and save such a notecard, it will get a new key. If name is not a valid notecard, or if the notecard is empty, the object will say, "Couldn't find notecard NAME" where "NAME" is the name of the invalid notecard. Note that lines longer than 255 characters will be truncated without any indication that this has been done. Requests from notecards that contain embedded inventory items will always result in EOF, regardless of the line being requested. Note: This function delays the script for 0.1 seconds. |
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
04-06-2006 09:47
Oh, well, in that case you could just re-initialise a variable with the key of the notecard whenever it was changed, and then read directly from that. You'd probably want the script in the child prim to have a changed() event that checked when the notecard was edited and sent the key again, though.
|
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
I'll give it a try
04-06-2006 10:37
Seems like I should be able to use the name instead of the key according to the WIKI. I am going to give it a try and see what happens.
![]() |
|
FireEyes Fauna
Registered User
Join date: 26 Apr 2004
Posts: 138
|
04-06-2006 10:43
In order to use the notecards name, it must be in the same prim as the script reading it. If you want the notecard to be read from another object, you must use the notecards UUID
![]() |
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
04-06-2006 10:53
No. Unfortunatley that didn't work
![]() So now to explore your suggestion of having the notecard "send it's UUID" to the script. How in Linden's name is that done? I'm clueless on that note ![]() ...I'll give the script that Ordinal posted a try... LOL |
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
04-06-2006 11:07
OK, great! The script works. I am trying to figure out how to manuveur it into my existing script though. I see that the following line reads the notecard in Ordinal's example:
CODE llMessageLinked(LINK_ALL_OTHERS, gLine++, "notecard", NULL_KEY); My script looks more like this and I am not sure where the above should go or should it replace llGetNotecardLine? CODE
|
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
04-06-2006 11:11
and shouldn't this line be in the prim with the notecard? If I am putting the notecards name there, how will it know what I am talking about if it's in some other prim?
CODE touch_start(integer n) |
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
04-06-2006 11:21
What those scripts are doing is:
1. The one in the root prim (without the notecard) is saying to the other one, with the linked message, "look up line X in notecard Y for me". 2. The one in the child prim (with the notecard) hears that and looks up what's on line X in notecard Y in its inventory, and just sends it straight back. 3. The first script receives that message and uses the data however it wants. In my example it just reads out the line, or goes back to the start if it's at the end of the notecard. So really you want to replace calls to llGetNotecardLine in the old root script with llMessageLinked(LINK_ALL_OTHERS, line, "notecard", NULL_KEY) - that tells the child script to read a particular line. And instead of the dataserver event, you use the link_message event to get the data, which, in my example, is in the string str. But otherwise you can process it just the same. Does that help? |
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
04-06-2006 11:40
Ok, I was getting confused because the notecard is actually in the root prim for my purposes LOL. I'll give it a try,
Thanks! |